From dc0135639c105185a9a78b77b158eb29ef4ddfee Mon Sep 17 00:00:00 2001 From: Dmitry Kats Date: Sat, 28 Apr 2018 12:36:36 +0300 Subject: [PATCH] Release 0.3.1 --- dist/Chart.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 dist/Chart.js diff --git a/dist/Chart.js b/dist/Chart.js new file mode 100644 index 0000000..b74d5f0 --- /dev/null +++ b/dist/Chart.js @@ -0,0 +1,75 @@ +define(["jquery", "idd.umd", "exports"], function ($, Charting, exports) { + exports.Show = function (chartInfo, container /*HTMLElement*/) { + var idd = Charting.InteractiveDataDisplay; + + var plotMap = []; + for (var i = 0; i < chartInfo.plots.length; i++) { + var pi = chartInfo.plots[i]; + var props = $.extend(true, {}, pi.properties); + props["kind"] = pi.kind; + props["displayName"] = pi.displayName; + props["titles"] = pi.titles; + plotMap[i] = props; + } + + if(chartInfo["layout"] && chartInfo["layout"] === "Lean") + { + $(container).css("overflow", "hidden"); + var navigationPanel = $("
").css("float", "right").width(65); + var chartElement = $("
").css("float", "none").width("auto").css("overflow", "hidden"); + $(container).append(navigationPanel); // the order of adding is important! + $(container).append(chartElement); + chartElement.height($(container).height()); + + var chart = idd.asPlot(chartElement); + var panel = new idd.NavigationPanel(chart, navigationPanel); + + var viewState = new idd.PersistentViewState(); + for (var i = 0; i < plotMap.length; i++) { + var p = plotMap[i]; + var factory = idd.PlotRegistry[p.kind] ? idd.PlotRegistry[p.kind] : idd.PlotRegistry["fallback"]; + factory.draw(factory.initialize(p, viewState, chart), p); + } + + var titlesX = getTitles("x", plotMap), titlesY = getTitles("y", plotMap); + if (titlesX != "") { + var xAxisTitle = $(chart.addDiv('
', "bottom")) + xAxisTitle.text(titlesX) + } + if (titlesY != "") { + var yAxisTitle = + $(chart.addDiv('
', "left")); + yAxisTitle.text(titlesY); + } + + if (chartInfo.xAxis && chartInfo.xAxis.ticks) { + chart.changeXAxis("labels", chartInfo.xAxis); + } + + if (chartInfo.yAxis && chartInfo.yAxis.ticks) { + chart.changeYAxis("labels", chartInfo.yAxis); + } + } + else + { + Charting.InteractiveDataDisplay.show(container, plotMap); + } + }; + + function getTitles(axis, plots){ + var title = ""; + var items = []; + for (var i = 0; i < plots.length; i++) { + var p = plots[i]; + if(p["titles"] && p["titles"][axis]){ + var x = p["titles"][axis]; + if(items.indexOf(x) < 0){ + items.push(x); + if(items.length > 1) title += ", "; + title += x; + } + } + } + return title; + } +}); \ No newline at end of file