dimple/examples/advanced_price_range_lollip...

48 lines
2.0 KiB
HTML
Raw Normal View History

2013-09-12 13:53:11 +04:00
<!----------------------------------------------------------------->
<!-- AUTOMATICALLY GENERATED CODE - PLEASE EDIT TEMPLATE INSTEAD -->
<!----------------------------------------------------------------->
2013-05-21 15:42:17 +04:00
<div id="chartContainer">
2013-09-11 22:06:40 +04:00
<script src="/lib/d3.v3.min.js"></script>
2014-04-02 22:46:49 +04:00
<script src="/dist/dimple.v1.2.0.js"></script>
2013-05-21 15:42:17 +04:00
<script type="text/javascript">
var svg = dimple.newSvg("#chartContainer", 590, 400);
d3.tsv("/data/example_data.tsv", function (data) {
2013-05-30 04:52:46 +04:00
// Filter the data for a single channel
2013-05-21 15:42:17 +04:00
data = dimple.filterData(data, "Channel", "Hypermarkets");
2013-05-30 04:52:46 +04:00
// Create the chart
2013-05-21 15:42:17 +04:00
var myChart = new dimple.chart(svg, data);
2013-05-31 18:47:30 +04:00
myChart.setBounds(60, 30, 470, 300)
2013-05-30 04:52:46 +04:00
// Add an x and 2 y-axes. When using multiple axes it's
// important to assign them to variables to pass to the series
2013-05-21 15:42:17 +04:00
var x = myChart.addCategoryAxis("x", "Brand");
var y1 = myChart.addMeasureAxis("y", "Price");
var y2 = myChart.addMeasureAxis("y", "Sales Value");
2013-06-15 02:22:24 +04:00
// Order the x axis by sales value desc
x.addOrderRule("Sales Value", true);
2013-05-30 04:52:46 +04:00
// Color the sales bars to be highly transparent
2013-05-21 15:42:17 +04:00
myChart.assignColor("Sales", "#222222", "#000000", 0.1);
2013-05-30 04:52:46 +04:00
// Add the bars mapped to the second y axis
2013-05-21 15:42:17 +04:00
myChart.addSeries("Sales", dimple.plot.bar, [x, y2]);
2013-05-30 04:52:46 +04:00
// Add series for minimum, average and maximum price
var min = myChart.addSeries("Min", dimple.plot.bubble, [x, y1]);
min.aggregate = dimple.aggregateMethod.min;
var avg = myChart.addSeries("Avg", dimple.plot.bubble, [x, y1]);
avg.aggregate = dimple.aggregateMethod.avg;
var max = myChart.addSeries("Max", dimple.plot.bubble, [x, y1]);
max.aggregate = dimple.aggregateMethod.max;
2014-04-16 17:07:17 +04:00
2013-05-30 04:52:46 +04:00
// Animate the chart for every date value, any dimension can be passed
// here and dimple will animate over its values.
myChart.setStoryboard("Date");
2013-05-21 15:42:17 +04:00
myChart.draw();
});
</script>
</div>