Charts become config blocks (themes, if you will :)

This commit is contained in:
Tanner Linsley 2015-06-14 19:30:02 -06:00
parent d811812356
commit 43f2c015f3

View File

@ -5,7 +5,8 @@
Chart = root.Chart,
helpers = Chart.helpers;
var defaultConfig = {
Chart.defaults.bar = {
hover: {
mode: "label"
},
@ -27,49 +28,48 @@
},
};
// Chart.Type.extend({
// name: "Bar",
// defaults: defaultConfig,
// initialize: function() {
// this.elementController = new Chart.RectangularElementController(this);
// this.canvasController = new Chart.RectangularCanvasController(this, this.elementController);
Chart.Type.extend({
name: "Bar",
defaults: defaultConfig,
initialize: function() {
this.elementController = new Chart.RectangularElementController(this);
this.canvasController = new Chart.RectangularCanvasController(this, this.elementController);
// //Create a new bar for each piece of data
// helpers.each(this.data.datasets, function(dataset, datasetIndex) {
// helpers.each(dataset.data, function(dataPoint, index) {
// this.elementController.addRectangle(dataset, datasetIndex, index);
// }, this);
//Create a new bar for each piece of data
helpers.each(this.data.datasets, function(dataset, datasetIndex) {
helpers.each(dataset.data, function(dataPoint, index) {
this.elementController.addRectangle(dataset, datasetIndex, index);
}, this);
// // The bar chart only supports a single x axis because the x axis is always a category axis
// dataset.xAxisID = this.options.scales.xAxes[0].id;
// The bar chart only supports a single x axis because the x axis is always a category axis
dataset.xAxisID = this.options.scales.xAxes[0].id;
// if (!dataset.yAxisID) {
// dataset.yAxisID = this.options.scales.yAxes[0].id;
// }
// }, this);
if (!dataset.yAxisID) {
dataset.yAxisID = this.options.scales.yAxes[0].id;
}
}, this);
// this.canvasController.initialize();
// },
// draw: function(ease) {
this.canvasController.initialize();
},
draw: function(ease) {
// var easingDecimal = ease || 1;
// this.clear();
var easingDecimal = ease || 1;
this.clear();
// // Draw all the scales
// helpers.each(this.scales, function(scale) {
// scale.draw(this.chartArea);
// }, this);
// Draw all the scales
helpers.each(this.scales, function(scale) {
scale.draw(this.chartArea);
}, this);
// //Draw all the bars for each dataset
// this.eachElement(function(bar, index, datasetIndex) {
// bar.transition(easingDecimal).draw();
// }, this);
//Draw all the bars for each dataset
this.eachElement(function(bar, index, datasetIndex) {
bar.transition(easingDecimal).draw();
}, this);
// Finally draw the tooltip
this.tooltip.transition(easingDecimal).draw();
},
});
// // Finally draw the tooltip
// this.tooltip.transition(easingDecimal).draw();
// },
// });
}).call(this);