Commit 0ee1f55e authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[example] xml works

parent 411bbf77
......@@ -32,6 +32,7 @@
<div id="time-axis"></div>
<div id="links"></div>
<div id="reset-zoom">Reset zoom</div>
<div id="xml"></div>
<!-- NOTE: it's important that this is at the end so that the DOM is ready -->
<script type="text/javascript" src="/index.fd532818.js"></script>
......
......@@ -33,6 +33,7 @@
<div id="time-axis"></div>
<div id="links"></div>
<div id="reset-zoom">Reset zoom</div>
<div id="xml"></div>
<!-- NOTE: it's important that this is at the end so that the DOM is ready -->
<script type="text/javascript" src="index.js"></script>
......
......@@ -2549,6 +2549,11 @@ var PS = {};
var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
var FFI_Simple_Globals = $PS["FFI.Simple.Globals"];
var console = FFI_Simple_Globals.unsafeGlobal("console");
var log = function (a) {
return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](console)("log")([ a ]));
});
};
var log2 = function (a) {
return function (b) {
return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
......@@ -2556,6 +2561,7 @@ var PS = {};
});
};
};
exports["log"] = log;
exports["log2"] = log2;
})(PS);
(function(exports) {
......@@ -2820,6 +2826,16 @@ var PS = {};
(function(exports) {
"use strict";
exports.runEffectFn2 = function runEffectFn2(fn) {
return function(a) {
return function(b) {
return function() {
return fn(a, b);
};
};
};
};
exports.runEffectFn3 = function runEffectFn3(fn) {
return function(a) {
return function(b) {
......@@ -2838,23 +2854,9 @@ var PS = {};
$PS["Effect.Uncurried"] = $PS["Effect.Uncurried"] || {};
var exports = $PS["Effect.Uncurried"];
var $foreign = $PS["Effect.Uncurried"];
exports["runEffectFn2"] = $foreign.runEffectFn2;
exports["runEffectFn3"] = $foreign.runEffectFn3;
})(PS);
(function(exports) {
"use strict";
exports.unsafePerformEffect = function (f) {
return f();
};
})(PS["Effect.Unsafe"] = PS["Effect.Unsafe"] || {});
(function($PS) {
// Generated by purs version 0.14.2
"use strict";
$PS["Effect.Unsafe"] = $PS["Effect.Unsafe"] || {};
var exports = $PS["Effect.Unsafe"];
var $foreign = $PS["Effect.Unsafe"];
exports["unsafePerformEffect"] = $foreign.unsafePerformEffect;
})(PS);
(function(exports) {
'use strict';
var d3 =require("d3/dist/d3.js");
......@@ -3002,6 +3004,10 @@ var PS = {};
return handle(row);
});
};
exports.xmlImpl = function(d3, url) {
return d3.xml(url);
};
})(PS["Graphics.D3.Request"] = PS["Graphics.D3.Request"] || {});
(function($PS) {
// Generated by purs version 0.14.2
......@@ -3010,7 +3016,12 @@ var PS = {};
var exports = $PS["Graphics.D3.Request"];
var $foreign = $PS["Graphics.D3.Request"];
var Control_Promise = $PS["Control.Promise"];
var Graphics_D3_Base = $PS["Graphics.D3.Base"];
var Graphics_D3_Base = $PS["Graphics.D3.Base"];
var xml = function (url) {
return Control_Promise.toAffE(function () {
return $foreign.xmlImpl(Graphics_D3_Base.d3, url);
});
};
var csv = function (url) {
return function (handle) {
return Control_Promise.toAffE(function () {
......@@ -3019,6 +3030,7 @@ var PS = {};
};
};
exports["csv"] = csv;
exports["xml"] = xml;
})(PS);
(function($PS) {
// Generated by purs version 0.14.2
......@@ -3101,8 +3113,15 @@ var PS = {};
var Joinable = function (join) {
this.join = join;
};
var Clickable = function (onClick, onDoubleClick) {
this.onClick = onClick;
this.onDoubleClick = onDoubleClick;
};
var Classed = function (classed) {
this.classed = classed;
};
var Callable = function (call) {
this.call = call;
};
var Existing = function (attr, attr$prime, attr$prime$prime, remove, style, style$prime, style$prime$prime, text, text$prime, text$prime$prime) {
this.attr = attr;
......@@ -3128,6 +3147,7 @@ var PS = {};
var unsafeRemove = Graphics_D3_Util.ffi([ "selection", "" ])("selection.remove()");
var unsafeJoin = Graphics_D3_Util.ffi([ "tag", "selection", "" ])("selection.join(tag)");
var unsafeClassed = Graphics_D3_Util.ffi([ "tag", "value", "selection", "" ])("selection.classed(tag, value)");
var unsafeCall = Graphics_D3_Util.ffi([ "what", "func", "selection", "" ])("selection.call(what, func)");
var unsafeAttr$prime$prime = function (dictAttrValue) {
return Graphics_D3_Util.ffi([ "key", "val", "selection", "" ])("selection.attr(key, function (d, i) { return val(d)(i); })");
};
......@@ -3146,6 +3166,9 @@ var PS = {};
};
var selectAll = Graphics_D3_Util.ffi([ "selector", "selection", "" ])("selection.selectAll(selector)");
var rootSelect = Graphics_D3_Util.ffiD3([ "selector", "" ])("d3.select(selector)");
var onClick = function (dict) {
return dict.onClick;
};
var joinableUpdate = new Joinable(unsafeJoin);
var join = function (dict) {
return dict.join;
......@@ -3164,10 +3187,15 @@ var PS = {};
}, function (dictAttrValue) {
return unsafeAttr$prime$prime();
}, unsafeRemove, unsafeStyle, unsafeStyle$prime, unsafeStyle$prime$prime, unsafeText, unsafeText$prime, unsafeText$prime$prime);
var enter = Graphics_D3_Util.ffi([ "update", "" ])("update.enter()");
var enter = Graphics_D3_Util.ffi([ "update", "" ])("update.enter()");
var clickableSelection = new Clickable(Graphics_D3_Util.ffi([ "callback", "clickable", "" ])("clickable.on('click', function(data) { callback(data)(); })"), Graphics_D3_Util.ffi([ "callback", "clickable", "" ])("clickable.on('dblclick', function (data) { callback(data)(); })"));
var classedSelection = new Classed(unsafeClassed);
var classed = function (dict) {
return dict.classed;
};
var callableSelection = new Callable(unsafeCall);
var call = function (dict) {
return dict.call;
};
var bindData = Graphics_D3_Util.ffi([ "array", "selection", "" ])("selection.data(array)");
var attr$prime = function (dict) {
......@@ -3210,6 +3238,7 @@ var PS = {};
exports["selectAll"] = selectAll;
exports["bindData"] = bindData;
exports["enter"] = enter;
exports["call"] = call;
exports["append"] = append;
exports["combineAppend"] = combineAppend;
exports["join"] = join;
......@@ -3219,12 +3248,15 @@ var PS = {};
exports["combineAttr'"] = combineAttr$prime;
exports["style''"] = style$prime$prime;
exports["text'"] = text$prime;
exports["onClick"] = onClick;
exports["callableSelection"] = callableSelection;
exports["appendableSelection"] = appendableSelection;
exports["appendableEnter"] = appendableEnter;
exports["joinableUpdate"] = joinableUpdate;
exports["classedSelection"] = classedSelection;
exports["existingSelection"] = existingSelection;
exports["existingUpdate"] = existingUpdate;
exports["clickableSelection"] = clickableSelection;
})(PS);
(function(exports) {
/* global exports */
......@@ -3251,7 +3283,11 @@ var PS = {};
(function(exports) {
'use strict';
exports.zoomImpl = function(d3) { return d3.zoom(); };
exports.onImpl = function(key, func, z) { return z.on(key, func); };
exports.renderZoomImpl = function(zoom, selection) { return selection.call(zoom); };
})(PS["Graphics.D3.Zoom"] = PS["Graphics.D3.Zoom"] || {});
(function($PS) {
// Generated by purs version 0.14.2
......@@ -3260,25 +3296,32 @@ var PS = {};
var exports = $PS["Graphics.D3.Zoom"];
var $foreign = $PS["Graphics.D3.Zoom"];
var Effect_Uncurried = $PS["Effect.Uncurried"];
var Graphics_D3_Base = $PS["Graphics.D3.Base"];
var Graphics_D3_Util = $PS["Graphics.D3.Util"];
var Transformable = function (transform) {
this.transform = transform;
};
var zoom = Graphics_D3_Util.ffiD3([ "" ])("d3.zoom()");
};
var zoomIdentity = Graphics_D3_Util.ffiD3([ "" ])("d3.zoomIdentity");
var zoom = function () {
return $foreign.zoomImpl(Graphics_D3_Base.d3);
};
var unsafeTransform = Graphics_D3_Util.ffi([ "obj" ])("obj.transform");
var transform = function (dict) {
return dict.transform;
};
var renderZoom = function (dictExisting) {
return Graphics_D3_Util.ffi([ "zoom", "selection", "" ])("selection.call(zoom)");
return Effect_Uncurried.runEffectFn2($foreign.renderZoomImpl);
};
var on = Effect_Uncurried.runEffectFn3($foreign.onImpl);
var on = Effect_Uncurried.runEffectFn3($foreign.onImpl);
var $dollar_TransformableZoom_1 = new Transformable(unsafeTransform);
var $dollar_TransformableZoomE_0 = new Transformable(unsafeTransform);
exports["transform"] = transform;
exports["zoom"] = zoom;
exports["zoomIdentity"] = zoomIdentity;
exports["on"] = on;
exports["renderZoom"] = renderZoom;
exports["$_TransformableZoomE_0"] = $dollar_TransformableZoomE_0;
exports["$_TransformableZoom_1"] = $dollar_TransformableZoom_1;
})(PS);
(function(exports) {
"use strict";
......@@ -3317,6 +3360,42 @@ var PS = {};
var $foreign = $PS["Math"];
exports["remainder"] = $foreign.remainder;
})(PS);
(function(exports) {
"use strict";
exports.getElementsByTagName = function (localName) {
return function (doc) {
return function () {
return doc.getElementsByTagName(localName);
};
};
};
})(PS["Web.DOM.Document"] = PS["Web.DOM.Document"] || {});
(function($PS) {
// Generated by purs version 0.14.2
"use strict";
$PS["Web.DOM.Document"] = $PS["Web.DOM.Document"] || {};
var exports = $PS["Web.DOM.Document"];
var $foreign = $PS["Web.DOM.Document"];
exports["getElementsByTagName"] = $foreign.getElementsByTagName;
})(PS);
(function(exports) {
"use strict";
exports.toArray = function (list) {
return function () {
return [].slice.call(list);
};
};
})(PS["Web.DOM.HTMLCollection"] = PS["Web.DOM.HTMLCollection"] || {});
(function($PS) {
// Generated by purs version 0.14.2
"use strict";
$PS["Web.DOM.HTMLCollection"] = $PS["Web.DOM.HTMLCollection"] || {};
var exports = $PS["Web.DOM.HTMLCollection"];
var $foreign = $PS["Web.DOM.HTMLCollection"];
exports["toArray"] = $foreign.toArray;
})(PS);
(function($PS) {
// Generated by purs version 0.14.2
"use strict";
......@@ -3339,7 +3418,6 @@ var PS = {};
var Effect = $PS["Effect"];
var Effect_Aff = $PS["Effect.Aff"];
var Effect_Class = $PS["Effect.Class"];
var Effect_Unsafe = $PS["Effect.Unsafe"];
var Foreign = $PS["Foreign"];
var Graphics_D3_Base = $PS["Graphics.D3.Base"];
var Graphics_D3_Contour = $PS["Graphics.D3.Contour"];
......@@ -3350,7 +3428,9 @@ var PS = {};
var Graphics_D3_Selection = $PS["Graphics.D3.Selection"];
var Graphics_D3_Time = $PS["Graphics.D3.Time"];
var Graphics_D3_Zoom = $PS["Graphics.D3.Zoom"];
var $$Math = $PS["Math"];
var $$Math = $PS["Math"];
var Web_DOM_Document = $PS["Web.DOM.Document"];
var Web_DOM_HTMLCollection = $PS["Web.DOM.HTMLCollection"];
var main = function __do() {
DOM_Simple_Console.log2("d3")(Graphics_D3_Base.d3)();
var scale = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Scale.linearScale)(Graphics_D3_Scale.domain(Graphics_D3_Scale.scaleLinear)([ -10.0, 10.0 ])))(Graphics_D3_Scale.range(Graphics_D3_Scale.scaleLinear)([ 0.0, 1.0 ])))(Graphics_D3_Scale.toFunction(Graphics_D3_Scale.scaleLinear))();
......@@ -3363,8 +3443,8 @@ var PS = {};
DOM_Simple_Console.log2("simpleData")(simpleData)();
var dataWithAppend = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableEnter)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Selection.rootSelect("#data-with-append"))(Graphics_D3_Selection.selectAll("p")))(Graphics_D3_Selection.bindData(data$prime)))(Graphics_D3_Selection.enter))("p"))(Graphics_D3_Selection["style''"](Graphics_D3_Selection.existingSelection)("color")(function (d) {
return function (idx) {
var $10 = $$Math.remainder(idx)(2.0) === 0.0;
if ($10) {
var $11 = $$Math.remainder(idx)(2.0) === 0.0;
if ($11) {
return "green";
};
return "red";
......@@ -3379,7 +3459,7 @@ var PS = {};
};
var width = (460 - margin.left | 0) - margin.right | 0;
var height = (400 - margin.top | 0) - margin.bottom | 0;
var svg = Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.rootSelect("#contour"))("svg"))(new Data_Tuple.Tuple("width", (width + margin.left | 0) + margin.right | 0)))(new Data_Tuple.Tuple("height", (height + margin.top | 0) + margin.bottom | 0)))("g"))(new Data_Tuple.Tuple("transform", "translate(" + (Data_Show.show(Data_Show.showInt)(margin.left) + (", " + (Data_Show.show(Data_Show.showInt)(margin.top) + ")")))))();
var contour = Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.rootSelect("#contour"))("svg"))(new Data_Tuple.Tuple("width", (width + margin.left | 0) + margin.right | 0)))(new Data_Tuple.Tuple("height", (height + margin.top | 0) + margin.bottom | 0)))("g"))(new Data_Tuple.Tuple("transform", "translate(" + (Data_Show.show(Data_Show.showInt)(margin.left) + (", " + (Data_Show.show(Data_Show.showInt)(margin.top) + ")")))))();
Effect_Aff.launchAff_((function () {
var handleRow = function (d) {
var v = Control_Monad_Except.runExcept(Control_Bind.bindFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Data_Traversable.traverse(Data_Traversable.traversableArray)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Foreign.readNumber(Data_Identity.monadIdentity)))(Foreign.readArray(Data_Identity.monadIdentity)(d)));
......@@ -3411,32 +3491,32 @@ var PS = {};
y: v2.value0.head
};
};
throw new Error("Failed pattern match at Main (line 78, column 40 - line 80, column 64): " + [ v2.constructor.name ]);
throw new Error("Failed pattern match at Main (line 80, column 40 - line 82, column 64): " + [ v2.constructor.name ]);
};
throw new Error("Failed pattern match at Main (line 76, column 15 - line 80, column 64): " + [ v1.constructor.name ]);
throw new Error("Failed pattern match at Main (line 78, column 15 - line 82, column 64): " + [ v1.constructor.name ]);
};
throw new Error("Failed pattern match at Main (line 73, column 11 - line 80, column 64): " + [ v.constructor.name ]);
throw new Error("Failed pattern match at Main (line 75, column 11 - line 82, column 64): " + [ v.constructor.name ]);
};
return Control_Bind.bind(Effect_Aff.bindAff)(Graphics_D3_Request.csv("https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/data_for_density2d.csv")(handleRow))(function (data$prime1) {
return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log2("data'")(data$prime1)))(function () {
return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
var x = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Scale.linearScale)(Graphics_D3_Scale.domain(Graphics_D3_Scale.scaleLinear)([ 5.0, 20.0 ])))(Graphics_D3_Scale.range(Graphics_D3_Scale.scaleLinear)([ 0.0, Data_Int.toNumber(width) ]))();
Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.append(Graphics_D3_Selection.appendableSelection)("g")(svg))(new Data_Tuple.Tuple("transform", "translate(0, " + (Data_Show.show(Data_Show.showInt)(height) + ")")))();
Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.append(Graphics_D3_Selection.appendableSelection)("g")(contour))(new Data_Tuple.Tuple("transform", "translate(0, " + (Data_Show.show(Data_Show.showInt)(height) + ")")))();
var y = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Scale.linearScale)(Graphics_D3_Scale.domain(Graphics_D3_Scale.scaleLinear)([ 5.0, 22.0 ])))(Graphics_D3_Scale.range(Graphics_D3_Scale.scaleLinear)([ Data_Int.toNumber(height), 0.0 ]))();
Control_Bind.bind(Effect.bindEffect)(Control_Applicative.pure(Effect.applicativeEffect)(svg))(Graphics_D3_Selection.append(Graphics_D3_Selection.appendableSelection)("g"))();
Control_Bind.bind(Effect.bindEffect)(Control_Applicative.pure(Effect.applicativeEffect)(contour))(Graphics_D3_Selection.append(Graphics_D3_Selection.appendableSelection)("g"))();
var densityData = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Contour.contourDensity)(Graphics_D3_Contour["x'"](Graphics_D3_Contour.contourDensityContour)(function (d) {
return d.x;
})))(Graphics_D3_Contour["y'"](Graphics_D3_Contour.contourDensityContour)(function (d) {
return d.y;
})))(Graphics_D3_Contour.size(Graphics_D3_Contour.contourDensityContour)([ Data_Int.toNumber(width), Data_Int.toNumber(height) ])))(Graphics_D3_Contour.bandwidth(Graphics_D3_Contour.contourDensityContour)(20.0)))(Graphics_D3_Contour.toFunction(Graphics_D3_Contour.contourDensityContour))();
DOM_Simple_Console.log2("densityData(data')")(densityData(data$prime1))();
Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableEnter)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Applicative.pure(Effect.applicativeEffect)(svg))(Graphics_D3_Selection.selectAll("path")))(Graphics_D3_Selection.bindData(densityData(data$prime1))))(Graphics_D3_Selection.enter))("path"))(new Data_Tuple.Tuple("d", Graphics_D3_Contour.geoPath)))(new Data_Tuple.Tuple("fill", "none")))(new Data_Tuple.Tuple("stroke", "#69b3a2")))(new Data_Tuple.Tuple("stroke-linejoin", "round"))();
Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableEnter)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Control_Applicative.pure(Effect.applicativeEffect)(contour))(Graphics_D3_Selection.selectAll("path")))(Graphics_D3_Selection.bindData(densityData(data$prime1))))(Graphics_D3_Selection.enter))("path"))(new Data_Tuple.Tuple("d", Graphics_D3_Contour.geoPath)))(new Data_Tuple.Tuple("fill", "none")))(new Data_Tuple.Tuple("stroke", "#69b3a2")))(new Data_Tuple.Tuple("stroke-linejoin", "round"))();
return Data_Unit.unit;
});
});
});
})())();
DOM_Simple_Console.log2("svg")(svg)();
DOM_Simple_Console.log2("contour")(contour)();
var axisScale = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Scale.linearScale)(Graphics_D3_Scale.domain(Graphics_D3_Scale.scaleLinear)([ -1.0, 10.0 ])))(Graphics_D3_Scale.range(Graphics_D3_Scale.scaleLinear)([ 0.0, 400.0 ]))();
var xAxis = Graphics_D3_SVG_Axis.axisBottom(Graphics_D3_Scale.scaleLinear)(axisScale)();
var axisSvg = Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAppend(Graphics_D3_Selection.appendableSelection)(Graphics_D3_Selection.rootSelect("#axis"))("svg"))(new Data_Tuple.Tuple("width", 400)))(new Data_Tuple.Tuple("height", 50)))("g"))(Graphics_D3_SVG_Axis.renderAxis(Graphics_D3_Selection.existingSelection)(xAxis))();
......@@ -3505,14 +3585,32 @@ var PS = {};
})))(new Data_Tuple.Tuple("stroke", "black")))(new Data_Tuple.Tuple("font-size", "0.5em"))();
Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Graphics_D3_Selection.combineAttr(Graphics_D3_Selection.existingSelection)()(Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Selection.selectAll("path")(linkG))(Graphics_D3_Selection.bindData(linkNodeData)))(Graphics_D3_Selection.join(Graphics_D3_Selection.joinableUpdate)("path")))(new Data_Tuple.Tuple("d", linkGen)))(new Data_Tuple.Tuple("fill", "none")))(new Data_Tuple.Tuple("stroke", "black"))();
var linkZoom = Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Zoom.zoom)(Graphics_D3_Zoom.on("zoom")(function (ze) {
return Effect_Unsafe.unsafePerformEffect(function __do() {
return function __do() {
DOM_Simple_Console.log2("zoom")(ze)();
Graphics_D3_Selection.attr(Graphics_D3_Selection.existingSelection)()("transform")(Graphics_D3_Zoom.transform(Graphics_D3_Zoom["$_TransformableZoomE_0"])(ze))(linkG)();
return Data_Unit.unit;
});
};
}))();
Graphics_D3_Zoom.renderZoom(Graphics_D3_Selection.existingSelection)(linkZoom)(linkElSvg)();
return DOM_Simple_Console.log2("linkEl")(linkElSvg)();
DOM_Simple_Console.log2("linkEl")(linkElSvg)();
var resetZoomEl = Control_Bind.bind(Effect.bindEffect)(Graphics_D3_Selection.rootSelect("#reset-zoom"))(Graphics_D3_Selection.onClick(Graphics_D3_Selection.clickableSelection)(function (v) {
return function __do() {
Graphics_D3_Selection.call(Graphics_D3_Selection.callableSelection)(Graphics_D3_Zoom.transform(Graphics_D3_Zoom["$_TransformableZoom_1"])(linkZoom))(Graphics_D3_Zoom.zoomIdentity)(linkG)();
return DOM_Simple_Console.log("zoom reset")();
};
}))();
DOM_Simple_Console.log2("resetZoomEl")(resetZoomEl)();
Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Graphics_D3_Request.xml("http://localhost:8888/data/employees.xml"))(function (xmlData) {
return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log2("xml")(xmlData)))(function () {
return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
var selXml = Graphics_D3_Selection.rootSelect("#xml")();
DOM_Simple_Console.log2("selXml")(selXml)();
var rows = Control_Bind.bind(Effect.bindEffect)(Web_DOM_Document.getElementsByTagName("row")(xmlData))(Web_DOM_HTMLCollection.toArray)();
return DOM_Simple_Console.log2("rows")(rows)();
});
});
}))();
return DOM_Simple_Console.log("xml done")();
};
exports["main"] = main;
})(PS);
......
......@@ -99,7 +99,7 @@ in upstream
-------------------------------
-}
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.2/packages.dhall sha256:5f10380b3ca7d3a32ea5c2b7535e4814a5e3f3590c70692f76e596d6ab0687b3
https://github.com/purescript/package-sets/releases/download/psc-0.14.2/packages.dhall sha256:64d7b5a1921e8458589add8a1499a1c82168e726a87fc4f958b3f8760cca2efe
let reactix-d3-additions = ../packages-additions.dhall
......
......@@ -29,6 +29,7 @@ to generate this file without the comments in this block.
, "reactix-d3"
, "transformers"
, "tuples"
, "web-dom"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
......
......@@ -16,6 +16,8 @@ import Effect.Class (liftEffect)
import Effect.Unsafe (unsafePerformEffect)
import Foreign
import Math
import Web.DOM.Document as WDD
import Web.DOM.HTMLCollection as WDH
import Graphics.D3.Base
import Graphics.D3.Contour as Contour
......@@ -62,7 +64,7 @@ main = do
let margin = {top: 20, right: 30, bottom: 30, left: 40}
width = 460 - margin.left - margin.right
height = 400 - margin.top - margin.bottom
svg <- Selection.rootSelect "#contour"
contour <- Selection.rootSelect "#contour"
>=>++ "svg"
>=> Tuple "width" (width + margin.left + margin.right)
>=> Tuple "height" (height + margin.top + margin.bottom)
......@@ -84,14 +86,14 @@ main = do
x <- Scale.linearScale
>>= Scale.domain [5.0, 20.0]
>>= Scale.range [0.0, toNumber width]
_ <- Selection.append "g" svg
_ <- Selection.append "g" contour
>=> Tuple "transform" ("translate(0, " <> show height <> ")")
-- TODO call (d3.axisBottom(x))
y <- Scale.linearScale
>>= Scale.domain [5.0, 22.0]
>>= Scale.range [toNumber height, 0.0]
_ <- pure svg >>= Selection.append "g"
_ <- pure contour >>= Selection.append "g"
-- TODO call (d3.axisLeft(y))
densityData <- Contour.contourDensity
......@@ -103,7 +105,7 @@ main = do
log2 "densityData(data')" $ densityData data'
_ <- pure svg
_ <- pure contour
>>= Selection.selectAll "path"
>>= Selection.bindData (densityData data')
>>= Selection.enter
......@@ -113,7 +115,7 @@ main = do
>=> Tuple "stroke" "#69b3a2"
>=> Tuple "stroke-linejoin" "round"
pure unit
log2 "svg" svg
log2 "contour" contour
-- visualize axis
axisScale <- Scale.linearScale
......@@ -199,13 +201,25 @@ main = do
>=> Tuple "fill" "none"
>=> Tuple "stroke" "black"
linkZoom <- Zoom.zoom
>>= Zoom.on "zoom" (\ze -> unsafePerformEffect $ do
>>= Zoom.on "zoom" (\ze -> do
_ <- log2 "zoom" ze
_ <- Selection.attr "transform" (Zoom.transform ze) linkG
pure unit)
_ <- Zoom.renderZoom linkZoom linkElSvg
-- resetZoomEl <- Selection.selectAll "#reset-zoom"
-- >>= Selection.onClick (\_ -> do
-- _ <- Selection.call (Zoom.transform linkZoom) Zoom.zoomIdentity linkG
-- pure unit)
log2 "linkEl" linkElSvg
resetZoomEl <- Selection.rootSelect "#reset-zoom"
>>= Selection.onClick (\_ -> do
_ <- Selection.call (Zoom.transform linkZoom) Zoom.zoomIdentity linkG
log "zoom reset")
log2 "resetZoomEl" resetZoomEl
launchAff_ $ do
xmlData <- xml "http://localhost:8888/data/employees.xml"
liftEffect $ log2 "xml" xmlData
liftEffect $ do
selXml <- Selection.rootSelect "#xml"
log2 "selXml" selXml
rows <- WDD.getElementsByTagName "row" xmlData >>= WDH.toArray
log2 "rows" rows
log "xml done"
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<Name>John</Name>
<Age>30</Age>
</row>
<row>
<Name>Jane</Name>
<Age>32</Age>
</row>
</root>
var fs = require('fs'),
http = require('http');
var dir = __dirname + '/static';
console.log('Serving at port 8888, dir', dir);
http.createServer(function (req, res) {
fs.readFile(dir + req.url, function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
res.setHeader('Access-Control-Allow-Origin', '*');
res.writeHead(200);
res.end(data);
});
}).listen(8888);
......@@ -5997,6 +5997,14 @@ parallel-transform@^1.1.0:
inherits "^2.0.3"
readable-stream "^2.1.5"
parcel-plugin-static-files-copy@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/parcel-plugin-static-files-copy/-/parcel-plugin-static-files-copy-2.6.0.tgz#06d7d9b6d7e2071b2e261315e94209b522108beb"
integrity sha512-k3YxdnEQWo1aMfCeBfxgUNJWuUE0O730EGiGBcmWEUOto7f1jM/8oxBKXkVZsXDCO1o00dw5X7CsT+yF0JY4qA==
dependencies:
minimatch "3.0.4"
path "0.12.7"
parcel@^2.0.0-beta.2:
version "2.0.0-beta.2"
resolved "https://registry.yarnpkg.com/parcel/-/parcel-2.0.0-beta.2.tgz#0a58f0b810fe2199b35d7bf7a949906568222d75"
......@@ -6122,6 +6130,14 @@ path-to-regexp@2.2.1:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.2.1.tgz#90b617025a16381a879bc82a38d4e8bdeb2bcf45"
integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ==
path@0.12.7:
version "0.12.7"
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
dependencies:
process "^0.11.1"
util "^0.10.3"
pbkdf2@^3.0.3:
version "3.1.2"
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075"
......@@ -6606,7 +6622,7 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
process@^0.11.10, process@~0.11.0:
process@^0.11.1, process@^0.11.10, process@~0.11.0:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
......@@ -8142,6 +8158,13 @@ util@0.10.3:
dependencies:
inherits "2.0.1"
util@^0.10.3, util@~0.10.1:
version "0.10.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
dependencies:
inherits "2.0.3"
util@^0.12.0, util@^0.12.3:
version "0.12.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.12.4.tgz#66121a31420df8f01ca0c464be15dfa1d1850253"
......@@ -8154,13 +8177,6 @@ util@^0.12.0, util@^0.12.3:
safe-buffer "^5.1.2"
which-typed-array "^1.1.2"
util@~0.10.1:
version "0.10.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
dependencies:
inherits "2.0.3"
utils-merge@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
......
{ -- d3 = ../purescript-d3/spago.dhall as Location
d3 =
{ d3 = ../purescript-d3/spago.dhall as Location
{- d3 =
{ dependencies = (https://raw.githubusercontent.com/cgenie/purescript-d3/master/spago.dhall sha256:8b7ccc57d93feec9c8eece52c67318fcd88b9fc3bee0eec3dd1224b5d55a5452).dependencies
, repo = "https://github.com/cgenie/purescript-d3"
, version = "master"
}
-}
, dom-simple =
{ dependencies =
[ "console"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment