Skip to content

Instantly share code, notes, and snippets.

@nikolaswise
Created May 14, 2014 23:43
Show Gist options
  • Save nikolaswise/04cc8152ecf17ea16420 to your computer and use it in GitHub Desktop.
Save nikolaswise/04cc8152ecf17ea16420 to your computer and use it in GitHub Desktop.
Dimple.js line graph directive
.directive('dngLineGraph', function(){
return {
restrict: 'E',
template: '<div class="dng-line-graph" id="line-graph"></div>',
replace: true,
controller: function($scope, $element, $attrs) {
var svg = dimple.newSvg('#line-graph', '100%', '100%');
d3.tsv($attrs.data, function (data) {
var chart = new dimple.chart(svg, data);
var x = chart.addCategoryAxis("x", "Month");
x.addOrderRule("Date");
chart.addMeasureAxis("y", "Unit Sales");
var s = chart.addSeries(null, dimple.plot.line);
chart.draw();
});
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment