dimple/examples/advanced_grouped_mekko.html

56 lines
2.1 KiB
HTML
Raw Permalink Normal View History

2013-09-12 13:56:11 +04:00
<!----------------------------------------------------------------->
<!-- AUTOMATICALLY GENERATED CODE - PLEASE EDIT TEMPLATE INSTEAD -->
<!----------------------------------------------------------------->
2015-07-10 19:41:31 +03:00
<!DOCTYPE html>
<meta charset="utf-8">
<html>
2013-06-16 05:02:47 +04:00
<div id="chartContainer">
2014-07-24 13:58:51 +04:00
<script src="/lib/d3.v3.4.8.js"></script>
2016-03-23 18:19:48 +03:00
<script src="/dist/dimple.v2.2.0.js"></script>
2013-06-16 05:02:47 +04:00
<script type="text/javascript">
var svg = dimple.newSvg("#chartContainer", 590, 400);
d3.tsv("/data/example_data.tsv", function (data) {
2013-06-17 02:32:25 +04:00
// Create and position the chart
2013-06-16 05:02:47 +04:00
var myChart = new dimple.chart(svg, data);
2013-08-29 14:18:59 +04:00
myChart.setBounds(65, 50, 505, 310)
2013-06-17 02:32:25 +04:00
// Add a Grouped Mekko Axis. This will show Brands grouped by owners
// sized by unit sales.
2013-06-16 05:02:47 +04:00
var x = myChart.addAxis("x", ["Owner", "Brand"], "Unit Sales");
x.showPercent = true;
2013-06-17 02:32:25 +04:00
// Add the vertical measure to also show unit sales, which is standard
// for a mekko, but not a requirement in dimple.
2013-06-16 05:02:47 +04:00
myChart.addPctAxis("y", "Unit Sales");
2013-06-17 02:32:25 +04:00
2013-06-17 02:36:38 +04:00
// Color by Unit Sales. By defining this without specifying the color
// range in the second parameter, dimple will assign colors as usual
// and adjust saturation based on the Unit Sales value.
2013-06-16 05:02:47 +04:00
var c = myChart.addColorAxis("Unit Sales");
2013-06-17 02:32:25 +04:00
2013-06-17 02:36:38 +04:00
// Override the minimum axis value to a lower number. By default the
// range of values is used with the minimum being 0 saturation and the
// maximum being 100% this causes the bars to be too washed out in this
// particular case.
2013-06-16 05:02:47 +04:00
c.overrideMin = -10000;
2013-06-17 02:32:25 +04:00
2013-06-17 02:36:38 +04:00
// Draw SKU's for the series, by specifying owner second here, it
// ensures dimple will color by owner rather than SKU. This suits the
// grouping to give blocks of color for each owner faded by the SKU
// unit sales value.
2013-06-16 05:02:47 +04:00
myChart.addSeries(["SKU", "Owner"], dimple.plot.bar);
2013-06-17 02:32:25 +04:00
// Add a legend
2013-06-16 05:02:47 +04:00
myChart.addLegend(240, 10, 330, 20, "right");
2013-06-17 02:32:25 +04:00
// Animate the chart by date values
2013-06-16 05:02:47 +04:00
myChart.setStoryboard("Date");
2013-06-17 02:32:25 +04:00
// Draw the chart
2013-06-16 05:02:47 +04:00
myChart.draw();
});
</script>
2015-07-10 19:41:31 +03:00
</div>
</html>