'./src/controllers/**',
'./src/scales/**',
'./src/elements/**',
- './src/charts/chart.bar.js',
+ './src/charts/**',
'./node_modules/color/dist/color.min.js'
],
isCustom = !!(util.env.types),
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
- window.myBar = new Chart(ctx, {
- type: 'bar',
+ window.myBar = Chart.Bar(ctx, {
data: barChartData,
options: {
responsive: true,
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
- window.myLine = new Chart(ctx).Line({
+ window.myLine = Chart.Line(ctx, {
data: lineChartData,
options: {
responsive: true,
};
var config = {
- type: 'polarArea',
data: {
datasets: [{
data: [
window.onload = function() {
var ctx = document.getElementById("chart-area");
- window.myPolarArea = new Chart(ctx, config);
+ window.myPolarArea = Chart.PolarArea(ctx, config);
};
$('#randomizeData').click(function() {
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
- window.myScatter = new Chart(ctx).Scatter({
+ window.myScatter = Chart.Scatter(ctx, {
data: scatterChartData,
options: {
responsive: true,
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
- window.myScatter = new Chart(ctx).Scatter({
+ window.myScatter = Chart.Scatter(ctx, {
data: scatterChartData,
options: {
- responsive: true,
- hoverMode: 'single', // should always use single for a scatter chart
scales: {
xAxes: [{
+ position: 'top',
gridLines: {
- zeroLineColor: "rgba(0,0,0,1)"
+ zeroLineColor: "rgba(0,255,0,1)"
}
}]
}
--- /dev/null
+(function() {
+ "use strict";
+
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
+
+ Chart.Bar = function(context, config) {
+ config.type = 'bar';
+
+ return new Chart(context, config);
+ }
+
+}).call(this);
--- /dev/null
+(function() {
+ "use strict";
+
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
+
+ Chart.Doughnut = function(context, config) {
+ config.type = 'doughnut';
+
+ return new Chart(context, config);
+ }
+
+}).call(this);
--- /dev/null
+(function() {
+ "use strict";
+
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
+
+ Chart.Line = function(context, config) {
+ config.type = 'line';
+
+ return new Chart(context, config);
+ }
+
+}).call(this);
--- /dev/null
+(function() {
+ "use strict";
+
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
+
+ Chart.PolarArea = function(context, config) {
+ config.type = 'polarArea';
+
+ return new Chart(context, config);
+ }
+
+}).call(this);
--- /dev/null
+(function() {
+ "use strict";
+
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
+
+ Chart.Radar = function(context, config) {
+ config.type = 'radar';
+
+ return new Chart(context, config);
+ }
+
+}).call(this);
(function() {
"use strict";
- return;
-
- var root = this,
- Chart = root.Chart,
- helpers = Chart.helpers;
+ var root = this;
+ var Chart = root.Chart;
+ var helpers = Chart.helpers;
var defaultConfig = {
hover: {
};
-
- Chart.types.Line.extend({
- name: "Scatter",
- defaults: defaultConfig,
- });
-}).call(this);
+ Chart.Scatter = function(context, config) {
+ config.options = helpers.configMerge(defaultConfig, config.options);
+ config.type = 'line';
+ return new Chart(context, config);
+ }
+
+}).call(this);
\ No newline at end of file
scales: {
xAxes: [{
type: "category",
+ id: 'x-axis-0'
}],
yAxes: [{
type: "linear",
+ id: 'y-axis-0'
}],
},
};
// Make sure controllers are built first so that each dataset is bound to an axis before the scales
// are built
+ this.ensureScalesHaveIDs();
this.buildControllers();
this.buildScales();
this.resetElements();
return this;
},
+ ensureScalesHaveIDs: function ensureScalesHaveIDs() {
+ var defaultXAxisID = 'x-axis-';
+ var defaultYAxisID = 'y-axis-';
+ if (this.options.scales) {
+ if (this.options.scales.xAxes && this.options.scales.xAxes.length) {
+ helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) {
+ xAxisOptions.id = xAxisOptions.id || (defaultXAxisID + index);
+ }, this);
+ }
+
+ if (this.options.scales.yAxes && this.options.scales.yAxes.length) {
+ // Build the y axes
+ helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) {
+ yAxisOptions.id = yAxisOptions.id || (defaultYAxisID + index);
+ }, this);
+ }
+ }
+ },
buildScales: function buildScales() {
// Map of scale ID to scale object so we can lookup later
this.scales = {};
// Build the x axes
if (this.options.scales) {
if (this.options.scales.xAxes && this.options.scales.xAxes.length) {
- helpers.each(this.options.scales.xAxes, function(xAxisOptions) {
+ helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) {
var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type);
var scale = new ScaleClass({
ctx: this.chart.ctx,
if (this.options.scales.yAxes && this.options.scales.yAxes.length) {
// Build the y axes
- helpers.each(this.options.scales.yAxes, function(yAxisOptions) {
+ helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) {
var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type);
var scale = new ScaleClass({
ctx: this.chart.ctx,
var defaultConfig = {
display: true,
position: "bottom",
- id: "x-axis-1", // need an ID so datasets can reference the scale
// grid line settings
gridLines: {
var defaultConfig = {
display: true,
position: "left",
- id: "y-axis-1",
// grid line settings
gridLines: {