vendor/assets/javascripts/chart.js in flashgrid-ext-2.2.0 vs vendor/assets/javascripts/chart.js in flashgrid-ext-2.2.5

- old
+ new

@@ -79,10 +79,13 @@ scaleFontColor: "rgba(158,171,179,1)", // Boolean - whether or not the chart should be responsive and resize when the browser does. responsive: true, + // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container + maintainAspectRatio: true, + // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove showTooltips: true, // Array - Array of string names to attach tooltip events tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], @@ -390,10 +393,16 @@ /* jshint ignore:start */ // Blows up jshint errors based on the new Function constructor //Templating methods //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ template = helpers.template = function(templateString, valuesObject){ + // If templateString is function rather than string-template - call the function for valuesObject + if(templateString instanceof Function) + { + return templateString(valuesObject); + } + var cache = {}; function tmpl(str, data){ // Figure out if we're getting a template, or if we need to // load the template - and be sure to cache the result. var fn = !/\W/.test(str) ? @@ -681,15 +690,21 @@ unbindEvents = helpers.unbindEvents = function (chartInstance, arrayOfEvents) { each(arrayOfEvents, function(handler,eventName){ removeEvent(chartInstance.chart.canvas, eventName, handler); }); }, - getMaximumSize = helpers.getMaximumSize = function(domNode){ + getMaximumWidth = helpers.getMaximumWidth = function(domNode){ var container = domNode.parentNode; // TODO = check cross browser stuff with this. return container.clientWidth; }, + getMaximumHeight = helpers.getMaximumHeight = function(domNode){ + var container = domNode.parentNode; + // TODO = check cross browser stuff with this. + return container.clientHeight; + }, + getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support retinaScale = helpers.retinaScale = function(chart){ var ctx = chart.ctx, width = chart.canvas.width, height = chart.canvas.height; //console.log(width + " x " + height); @@ -764,12 +779,12 @@ return this; }, resize : function(callback){ this.stop(); var canvas = this.chart.canvas, - newWidth = getMaximumSize(this.chart.canvas), - newHeight = newWidth / this.chart.aspectRatio; + newWidth = getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); canvas.width = this.chart.width = newWidth; canvas.height = this.chart.height = newHeight; retinaScale(this.chart); @@ -1876,9 +1891,10 @@ root.Chart = previous; return Chart; }; }).call(this); + (function(){ "use strict"; var root = this, Chart = root.Chart, \ No newline at end of file