Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitry Voytsekhovskiy
committed
Apr 25, 2018
1 parent
19165e6
commit 7fd1e75
Showing
4 changed files
with
163 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<meta charset="utf-8" /> | ||
<!-- <link rel="stylesheet" href="../../../node_modules/interactive-data-display/dist/idd.css" /> | ||
<script src="../../../node_modules/jquery/dist/jquery.js"></script> | ||
<script src="../../../node_modules/npm-modernizr/modernizr.js"></script> | ||
<script src="../../../node_modules/rx/dist/rx.all.js"></script> | ||
<script src="../../../node_modules/jqueryui/jquery-ui.js"></script> | ||
<script src="../../../node_modules/interactive-data-display/dist/idd.js"></script> | ||
<script src="../../../node_modules/jquery-mousewheel/jquery.mousewheel.js"></script> | ||
<script src="../../../node_modules/datatables.net/js/jquery.dataTables.js"></script> | ||
<link href="../../../dist/angara.tablejs.css" rel="stylesheet" /> | ||
<link href="../styles/samples.css" rel="stylesheet" /> | ||
<script src="../../../dist/Chart.js"></script> --> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.js"></script> | ||
|
||
<script type="text/javascript"> | ||
var source = { | ||
"layout": "Lean", | ||
"plots": [ | ||
{ | ||
"displayName": "Tu-tu-ruu", | ||
"kind": "markers", | ||
"properties": { | ||
"borderColor": "black", | ||
"color": "red", | ||
"shape": "box", | ||
"size": 10.0, | ||
"x": [ 0, 0.1, 0.3, 0.5, 0.8, 1.0], | ||
"y": [ 0.5, 0.6, 0.4, 0.1, 0.2, 0.8] | ||
}, | ||
"titles": { | ||
"x": "Xtutu", | ||
"y": "YY"} | ||
}, | ||
{ | ||
"displayName": "line", | ||
"kind": "line", | ||
"properties": { | ||
"fill_68": "#1F497D", | ||
"fill_95": "#1F497D", | ||
"stroke": "#1F497D", | ||
"thickness": 1.0, | ||
"treatAs": "1", | ||
"x": [ 0, 0.1, 0.3, 0.5, 0.8, 1.0], | ||
"y": [ 0.5, 0.6, 0.4, 0.1, 0.2, 0.8] | ||
}, | ||
"titles": { | ||
"x": "XV", | ||
"y": "YY" | ||
} | ||
} | ||
], | ||
"xAxis": { | ||
"angle": 35.0, | ||
"labels": [ | ||
"Alpha", | ||
"bEtHaNy", | ||
"F\nT" | ||
], | ||
"ticks:double array": [0, 0.5, 1.0] | ||
}, | ||
"yAxis": {} | ||
}; | ||
|
||
require.config({ | ||
baseUrl: "../../../dist", | ||
paths: { | ||
'jquery': '../node_modules/jquery/dist/jquery', | ||
'idd.umd': '../node_modules/interactive-data-display/dist/idd.umd', | ||
'idd-css': '../node_modules/interactive-data-display/dist/idd.umd', | ||
'rx': '../node_modules/rx/dist/rx.lite', | ||
'svg': '../node_modules/svg.js/dist/svg', | ||
'filesaver': '../node_modules/file-saver/FileSaver', | ||
'css': '../node_modules/require-css/css', | ||
'jquery-ui': '../node_modules/jqueryui/jquery-ui', | ||
'jquery-mousewheel': '../node_modules/jquery-mousewheel/jquery.mousewheel' | ||
} | ||
}); | ||
require(["../../../dist/Chart.js"], function(Viewer) { | ||
Viewer.Show(source, $("#cv")); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Chart Viewer</h2> | ||
<div id="cv" style="width:800px; height: 500px;"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,67 @@ | ||
define(["jquery", "idd.umd", "exports"], function ($, Charting, exports) { | ||
exports.Show = function (plots, container) { | ||
var plotMap = {}; | ||
for (var i = 0; i < plots.length; i++) { | ||
var pi = plots[i]; | ||
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; | ||
} | ||
Charting.InteractiveDataDisplay.show(container, plotMap); | ||
|
||
if(chartInfo["layout"] && chartInfo["layout"] === "Lean") | ||
{ | ||
$(container).css("overflow", "hidden"); | ||
var navigationPanel = $("<div></div>").css("float", "right").width(65); | ||
var chartElement = $("<div data-idd-plot='chart'></div>").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('<div style="font-size: larger; text-align: center"></div>', "bottom")) | ||
xAxisTitle.text(titlesX) | ||
} | ||
if (titlesY != "") { | ||
var yAxisTitle = | ||
$(chart.addDiv('<div class="idd-verticalTitle" style="font-size: larger;"></div>', "left")); | ||
yAxisTitle.text(titlesY); | ||
} | ||
} | ||
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; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters