vendor/assets/javascripts/chart.js in flashgrid-ext-2.1.2 vs vendor/assets/javascripts/chart.js in flashgrid-ext-2.2.0
- old
+ new
@@ -861,11 +861,13 @@
yMax,
xMin,
yMin;
helpers.each(this.datasets, function(dataset){
dataCollection = dataset.points || dataset.bars || dataset.segments;
- Elements.push(dataCollection[dataIndex]);
+ if (dataCollection[dataIndex]){
+ Elements.push(dataCollection[dataIndex]);
+ }
});
helpers.each(Elements, function(element) {
xPositions.push(element.x);
yPositions.push(element.y);
@@ -1030,28 +1032,31 @@
Chart.Element.extend = inherits;
Chart.Point = Chart.Element.extend({
+ display : true,
inRange : function(chartX,chartY){
var hitDetectionRange = this.hitDetectionRadius + this.radius;
return ((Math.pow(chartX-this.x, 2)+Math.pow(chartY-this.y, 2)) < Math.pow(hitDetectionRange,2));
},
draw : function(){
- var ctx = this.ctx;
- ctx.beginPath();
+ if (this.display){
+ var ctx = this.ctx;
+ ctx.beginPath();
- ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);
- ctx.closePath();
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);
+ ctx.closePath();
- ctx.strokeStyle = this.strokeColor;
- ctx.lineWidth = this.strokeWidth;
+ ctx.strokeStyle = this.strokeColor;
+ ctx.lineWidth = this.strokeWidth;
- ctx.fillStyle = this.fillColor;
+ ctx.fillStyle = this.fillColor;
- ctx.fill();
- ctx.stroke();
+ ctx.fill();
+ ctx.stroke();
+ }
//Quick debug for bezier curve splining
//Highlights control points and the line between them.
@@ -1859,10 +1864,12 @@
if (amd) {
define(function(){
return Chart;
});
+ } else if (typeof module === 'object' && module.exports) {
+ module.exports = Chart;
}
root.Chart = Chart;
Chart.noConflict = function(){
@@ -1980,10 +1987,11 @@
if (helpers.isNumber(dataPoint)){
//Add a new point for each piece of data, passing any required data to draw.
datasetObject.bars.push(new this.BarClass({
value : dataPoint,
label : data.labels[index],
+ datasetLabel: dataset.label,
strokeColor : dataset.strokeColor,
fillColor : dataset.fillColor,
highlightFill : dataset.highlightFill || dataset.fillColor,
highlightStroke : dataset.highlightStroke || dataset.strokeColor
}));
@@ -2407,10 +2415,11 @@
initialize: function(data){
//Declare the extension of the default point, to cater for the options passed in to the constructor
this.PointClass = Chart.Point.extend({
strokeWidth : this.options.pointDotStrokeWidth,
radius : this.options.pointDotRadius,
+ display : this.options.pointDot,
hitDetectionRadius : this.options.pointHitDetectionRadius,
ctx : this.chart.ctx,
inRange : function(mouseX){
return (Math.pow(mouseX-this.x, 2) < Math.pow(this.radius + this.hitDetectionRadius,2));
}
@@ -2455,10 +2464,11 @@
datasetObject.points.push(new this.PointClass({
value : dataPoint,
label : data.labels[index],
// x: this.scale.calculateX(index),
// y: this.scale.endPoint,
+ datasetLabel: dataset.label,
strokeColor : dataset.pointStrokeColor,
fillColor : dataset.pointColor,
highlightFill : dataset.pointHighlightFill || dataset.pointColor,
highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor
}));
@@ -3011,10 +3021,11 @@
initialize: function(data){
this.PointClass = Chart.Point.extend({
strokeWidth : this.options.pointDotStrokeWidth,
radius : this.options.pointDotRadius,
+ display : this.options.pointDot,
hitDetectionRadius : this.options.pointHitDetectionRadius,
ctx : this.chart.ctx
});
this.datasets = [];
@@ -3042,10 +3053,11 @@
helpers.each(data.datasets,function(dataset){
var datasetObject = {
label: dataset.label || null,
fillColor : dataset.fillColor,
+ datasetLabel: dataset.label,
strokeColor : dataset.strokeColor,
pointColor : dataset.pointColor,
pointStrokeColor : dataset.pointStrokeColor,
points : []
};
@@ -3215,9 +3227,10 @@
},
update : function(){
this.eachPoints(function(point){
point.save();
});
+ this.reflow();
this.render();
},
reflow: function(){
helpers.extend(this.scale, {
width : this.chart.width,
\ No newline at end of file