ng2-charts
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -1044,2 +1044,468 @@ (function (global, factory) { | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
var helpers = Chart.helpers; | ||
/** @type {?} */ | ||
var defaults = Chart.defaults; | ||
/** @type {?} */ | ||
var valueOrDefault = helpers.valueOrDefault; | ||
/** | ||
* @param {?} labelOpts | ||
* @param {?} fontSize | ||
* @return {?} | ||
*/ | ||
function getBoxWidth(labelOpts, fontSize) { | ||
return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? | ||
fontSize : | ||
labelOpts.boxWidth; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function fit() { | ||
/** @type {?} */ | ||
var me = this; | ||
/** @type {?} */ | ||
var opts = me.options; | ||
/** @type {?} */ | ||
var labelOpts = opts.labels; | ||
/** @type {?} */ | ||
var display = opts.display; | ||
/** @type {?} */ | ||
var ctx = me.ctx; | ||
/** @type {?} */ | ||
var labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
var fontSize = labelFont.size; | ||
// Reset hit boxes | ||
/** @type {?} */ | ||
var hitboxes = me.legendHitBoxes = []; | ||
/** @type {?} */ | ||
var minSize = me.minSize; | ||
/** @type {?} */ | ||
var isHorizontal = me.isHorizontal(); | ||
if (isHorizontal) { | ||
minSize.width = me.maxWidth; // fill all the width | ||
minSize.height = display ? 10 : 0; | ||
} | ||
else { | ||
minSize.width = display ? 10 : 0; | ||
minSize.height = me.maxHeight; // fill all the height | ||
} | ||
/** @type {?} */ | ||
var getMaxLineWidth = ( /** | ||
* @param {?} textLines | ||
* @return {?} | ||
*/function (textLines) { | ||
return textLines.map(( /** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/function (textLine) { | ||
return ctx.measureText(textLine).width; | ||
})).reduce(( /** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
}); | ||
// Increase sizes here | ||
if (display) { | ||
ctx.font = labelFont.string; | ||
if (isHorizontal) { | ||
// Labels | ||
// Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one | ||
/** @type {?} */ | ||
var lineWidths_1 = me.lineWidths = [0]; | ||
/** @type {?} */ | ||
var maxHeight_1 = 0; | ||
/** @type {?} */ | ||
var totalHeight_1 = 0; | ||
ctx.textAlign = 'left'; | ||
ctx.textBaseline = 'top'; | ||
helpers.each(me.legendItems, ( /** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/function (legendItem, i) { | ||
/** @type {?} */ | ||
var width; | ||
/** @type {?} */ | ||
var height; | ||
/** @type {?} */ | ||
var grossHeight; | ||
if (helpers.isArray(legendItem.text)) { | ||
width = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
grossHeight = height; | ||
} | ||
else { | ||
width = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
grossHeight = height + labelOpts.padding; | ||
} | ||
width += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
if (grossHeight > maxHeight_1) { | ||
maxHeight_1 = grossHeight; | ||
} | ||
if (lineWidths_1[lineWidths_1.length - 1] + width + 2 * labelOpts.padding > minSize.width) { | ||
totalHeight_1 += maxHeight_1; | ||
maxHeight_1 = 0; | ||
lineWidths_1[lineWidths_1.length - (i > 0 ? 0 : 1)] = 0; | ||
} | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width: width, | ||
height: height, | ||
}; | ||
lineWidths_1[lineWidths_1.length - 1] += width + labelOpts.padding; | ||
})); | ||
minSize.height += totalHeight_1 + maxHeight_1; | ||
} | ||
else { | ||
/** @type {?} */ | ||
var vPadding_1 = labelOpts.padding; | ||
/** @type {?} */ | ||
var columnWidths_1 = me.columnWidths = []; | ||
/** @type {?} */ | ||
var columnHeights_1 = me.columnHeights = []; | ||
/** @type {?} */ | ||
var totalWidth_1 = labelOpts.padding; | ||
/** @type {?} */ | ||
var currentColWidth_1 = 0; | ||
/** @type {?} */ | ||
var currentColHeight_1 = 0; | ||
helpers.each(me.legendItems, ( /** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/function (legendItem, i) { | ||
/** @type {?} */ | ||
var itemWidth; | ||
/** @type {?} */ | ||
var height; | ||
if (helpers.isArray(legendItem.text)) { | ||
itemWidth = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
} | ||
else { | ||
itemWidth = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
} | ||
itemWidth += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
// If too tall, go to new column | ||
if (i > 0 && currentColHeight_1 + fontSize + 2 * vPadding_1 > minSize.height) { | ||
totalWidth_1 += currentColWidth_1 + labelOpts.padding; | ||
columnWidths_1.push(currentColWidth_1); // previous column width | ||
columnHeights_1.push(currentColHeight_1); | ||
currentColWidth_1 = 0; | ||
currentColHeight_1 = 0; | ||
} | ||
// Get max width | ||
currentColWidth_1 = Math.max(currentColWidth_1, itemWidth); | ||
currentColHeight_1 += fontSize + vPadding_1; | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width: itemWidth, | ||
height: height | ||
}; | ||
})); | ||
totalWidth_1 += currentColWidth_1; | ||
columnWidths_1.push(currentColWidth_1); | ||
columnHeights_1.push(currentColHeight_1); | ||
minSize.width += totalWidth_1; | ||
} | ||
} | ||
me.width = minSize.width; | ||
me.height = minSize.height; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function draw() { | ||
/** @type {?} */ | ||
var me = this; | ||
/** @type {?} */ | ||
var opts = me.options; | ||
/** @type {?} */ | ||
var labelOpts = opts.labels; | ||
/** @type {?} */ | ||
var globalDefaults = defaults.global; | ||
/** @type {?} */ | ||
var defaultColor = globalDefaults.defaultColor; | ||
/** @type {?} */ | ||
var lineDefault = globalDefaults.elements.line; | ||
/** @type {?} */ | ||
var legendHeight = me.height; | ||
/** @type {?} */ | ||
var columnHeights = me.columnHeights; | ||
/** @type {?} */ | ||
var legendWidth = me.width; | ||
/** @type {?} */ | ||
var lineWidths = me.lineWidths; | ||
if (opts.display) { | ||
/** @type {?} */ | ||
var ctx_1 = me.ctx; | ||
/** @type {?} */ | ||
var fontColor = valueOrDefault(labelOpts.fontColor, globalDefaults.defaultFontColor); | ||
/** @type {?} */ | ||
var labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
var fontSize_1 = labelFont.size; | ||
/** @type {?} */ | ||
var cursor_1; | ||
// Canvas setup | ||
ctx_1.textAlign = 'left'; | ||
ctx_1.textBaseline = 'middle'; | ||
ctx_1.lineWidth = 0.5; | ||
ctx_1.strokeStyle = fontColor; // for strikethrough effect | ||
ctx_1.fillStyle = fontColor; // render in correct colour | ||
ctx_1.font = labelFont.string; | ||
/** @type {?} */ | ||
var boxWidth_1 = getBoxWidth(labelOpts, fontSize_1); | ||
/** @type {?} */ | ||
var hitboxes_1 = me.legendHitBoxes; | ||
/** @type {?} */ | ||
var maxHeight_2 = hitboxes_1.map(( /** | ||
* @param {?} x | ||
* @return {?} | ||
*/function (x) { | ||
return x.height; | ||
})).reduce(( /** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
// current position | ||
/** @type {?} */ | ||
var drawLegendBox_1 = ( /** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @return {?} | ||
*/function (x, y, legendItem) { | ||
if (isNaN(boxWidth_1) || boxWidth_1 <= 0) { | ||
return; | ||
} | ||
// Set the ctx for the box | ||
ctx_1.save(); | ||
/** @type {?} */ | ||
var lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); | ||
ctx_1.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); | ||
ctx_1.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); | ||
ctx_1.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); | ||
ctx_1.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); | ||
ctx_1.lineWidth = lineWidth; | ||
ctx_1.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); | ||
if (ctx_1.setLineDash) { | ||
// IE 9 and 10 do not support line dash | ||
ctx_1.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); | ||
} | ||
if (opts.labels && opts.labels.usePointStyle) { | ||
// Recalculate x and y for drawPoint() because its expecting | ||
// x and y to be center of figure (instead of top left) | ||
/** @type {?} */ | ||
var radius = boxWidth_1 * Math.SQRT2 / 2; | ||
/** @type {?} */ | ||
var centerX = x + boxWidth_1 / 2; | ||
/** @type {?} */ | ||
var centerY = y + fontSize_1 / 2; | ||
// Draw pointStyle as legend symbol | ||
helpers.canvas.drawPoint(ctx_1, legendItem.pointStyle, radius, centerX, centerY); | ||
} | ||
else { | ||
// Draw box as legend symbol | ||
if (lineWidth !== 0) { | ||
ctx_1.strokeRect(x, y, boxWidth_1, fontSize_1); | ||
} | ||
ctx_1.fillRect(x, y, boxWidth_1, fontSize_1); | ||
} | ||
ctx_1.restore(); | ||
}); | ||
/** @type {?} */ | ||
var drawStrikeThrough_1 = ( /** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @return {?} | ||
*/function (x, y, w) { | ||
ctx_1.beginPath(); | ||
ctx_1.lineWidth = 2; | ||
ctx_1.moveTo(x, y); | ||
ctx_1.lineTo(x + w, y); | ||
ctx_1.stroke(); | ||
}); | ||
/** @type {?} */ | ||
var drawCrossOver_1 = ( /** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @param {?} h | ||
* @return {?} | ||
*/function (x, y, w, h) { | ||
ctx_1.beginPath(); | ||
ctx_1.lineWidth = 2; | ||
ctx_1.moveTo(x, y); | ||
ctx_1.lineTo(x + w, y + h); | ||
ctx_1.moveTo(x, y + h); | ||
ctx_1.lineTo(x + w, y); | ||
ctx_1.stroke(); | ||
}); | ||
/** @type {?} */ | ||
var fillText_1 = ( /** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @param {?} textWidth | ||
* @return {?} | ||
*/function (x, y, legendItem, textWidth) { | ||
/** @type {?} */ | ||
var halfFontSize = fontSize_1 / 2; | ||
/** @type {?} */ | ||
var xLeft = boxWidth_1 + halfFontSize + x; | ||
/** @type {?} */ | ||
var yMiddle = y + halfFontSize; | ||
if (helpers.isArray(legendItem.text)) { | ||
helpers.each(legendItem.text, ( /** | ||
* @param {?} textLine | ||
* @param {?} index | ||
* @return {?} | ||
*/function (textLine, index) { | ||
/** @type {?} */ | ||
var lineOffset = index * fontSize_1; | ||
ctx_1.fillText(textLine, xLeft, yMiddle + lineOffset); | ||
})); | ||
} | ||
else { | ||
ctx_1.fillText(legendItem.text, xLeft, yMiddle); | ||
} | ||
if (legendItem.hidden) { | ||
if (helpers.isArray(legendItem.text)) { | ||
drawCrossOver_1(xLeft, yMiddle, textWidth, (legendItem.text.length - 1) * (fontSize_1 - 1)); | ||
} | ||
else { | ||
drawStrikeThrough_1(xLeft, yMiddle, textWidth); | ||
} | ||
} | ||
}); | ||
/** @type {?} */ | ||
var alignmentOffset_1 = ( /** | ||
* @param {?} dimension | ||
* @param {?} blockSize | ||
* @return {?} | ||
*/function (dimension, blockSize) { | ||
switch (opts.align) { | ||
case 'start': | ||
return labelOpts.padding; | ||
case 'end': | ||
return dimension - blockSize; | ||
default: // center | ||
return (dimension - blockSize + labelOpts.padding) / 2; | ||
} | ||
}); | ||
// Horizontal | ||
/** @type {?} */ | ||
var isHorizontal_1 = me.isHorizontal(); | ||
if (isHorizontal_1) { | ||
cursor_1 = { | ||
x: me.left + alignmentOffset_1(legendWidth, lineWidths[0]), | ||
y: me.top + labelOpts.padding, | ||
line: 0 | ||
}; | ||
} | ||
else { | ||
cursor_1 = { | ||
x: me.left + labelOpts.padding, | ||
y: me.top + alignmentOffset_1(legendHeight, columnHeights[0]), | ||
line: 0 | ||
}; | ||
} | ||
/** @type {?} */ | ||
var itemHeight_1 = maxHeight_2; | ||
helpers.each(me.legendItems, ( /** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/function (legendItem, i) { | ||
/** @type {?} */ | ||
var textWidth; | ||
/** @type {?} */ | ||
var boxTopOffset; | ||
if (helpers.isArray(legendItem.text)) { | ||
textWidth = legendItem.text.map(( /** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/function (textLine) { | ||
return ctx_1.measureText(textLine).width; | ||
})).reduce(( /** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
boxTopOffset = fontSize_1 / 2 * (legendItem.text.length - 1); | ||
} | ||
else { | ||
textWidth = ctx_1.measureText(legendItem.text).width; | ||
boxTopOffset = 0; | ||
} | ||
/** @type {?} */ | ||
var width = boxWidth_1 + (fontSize_1 / 2) + textWidth; | ||
/** @type {?} */ | ||
var x = cursor_1.x; | ||
/** @type {?} */ | ||
var topOffset = Math.trunc((maxHeight_2 - hitboxes_1[i].height) / 2); | ||
/** @type {?} */ | ||
var y = cursor_1.y + topOffset; | ||
// Use (me.left + me.minSize.width) and (me.top + me.minSize.height) | ||
// instead of me.right and me.bottom because me.width and me.height | ||
// may have been changed since me.minSize was calculated | ||
if (isHorizontal_1) { | ||
if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.width) { | ||
y = cursor_1.y += itemHeight_1; | ||
cursor_1.line++; | ||
x = cursor_1.x = me.left + alignmentOffset_1(legendWidth, lineWidths[cursor_1.line]); | ||
} | ||
} | ||
else if (i > 0 && y + itemHeight_1 > me.top + me.minSize.height) { | ||
x = cursor_1.x = x + me.columnWidths[cursor_1.line] + labelOpts.padding; | ||
cursor_1.line++; | ||
y = cursor_1.y = me.top + alignmentOffset_1(legendHeight, columnHeights[cursor_1.line]); | ||
} | ||
drawLegendBox_1(x, y + boxTopOffset, legendItem); | ||
hitboxes_1[i].left = x; | ||
hitboxes_1[i].top = y; | ||
// Fill the actual label | ||
fillText_1(x, y, legendItem, textWidth); | ||
if (isHorizontal_1) { | ||
cursor_1.x += width + labelOpts.padding; | ||
} | ||
else { | ||
cursor_1.y += itemHeight_1; | ||
} | ||
})); | ||
} | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsLegend() { | ||
/** @type {?} */ | ||
var plugins = Chart.plugins.getAll(); | ||
/** @type {?} */ | ||
var legend = plugins.filter(( /** | ||
* @param {?} p | ||
* @return {?} | ||
*/function (p) { return p.id === 'legend'; }))[0]; | ||
legend._element.prototype.fit = fit; | ||
legend._element.prototype.draw = draw; | ||
} | ||
@@ -1050,3 +1516,110 @@ /** | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
var helpers$1 = Chart.helpers; | ||
/** | ||
* @param {?} vm | ||
* @param {?} align | ||
* @return {?} | ||
*/ | ||
function getAlignedX$1(vm, align) { | ||
return align === 'center' | ||
? vm.x + vm.width / 2 | ||
: align === 'right' | ||
? vm.x + vm.width - vm.xPadding | ||
: vm.x + vm.xPadding; | ||
} | ||
/** | ||
* @param {?} pt | ||
* @param {?} vm | ||
* @param {?} ctx | ||
* @return {?} | ||
*/ | ||
function drawBody(pt, vm, ctx) { | ||
/** @type {?} */ | ||
var bodyFontSize = vm.bodyFontSize; | ||
/** @type {?} */ | ||
var bodySpacing = vm.bodySpacing; | ||
/** @type {?} */ | ||
var bodyAlign = vm._bodyAlign; | ||
/** @type {?} */ | ||
var body = vm.body; | ||
/** @type {?} */ | ||
var drawColorBoxes = vm.displayColors; | ||
/** @type {?} */ | ||
var labelColors = vm.labelColors; | ||
/** @type {?} */ | ||
var xLinePadding = 0; | ||
/** @type {?} */ | ||
var colorX = drawColorBoxes ? getAlignedX$1(vm, 'left') : 0; | ||
/** @type {?} */ | ||
var textColor; | ||
ctx.textAlign = bodyAlign; | ||
ctx.textBaseline = 'top'; | ||
ctx.font = helpers$1.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily); | ||
pt.x = getAlignedX$1(vm, bodyAlign); | ||
// Before Body | ||
/** @type {?} */ | ||
var fillLineOfText = ( /** | ||
* @param {?} line | ||
* @return {?} | ||
*/function (line) { | ||
ctx.fillText(line, pt.x + xLinePadding, pt.y); | ||
pt.y += bodyFontSize + bodySpacing; | ||
}); | ||
// Before body lines | ||
ctx.fillStyle = vm.bodyFontColor; | ||
helpers$1.each(vm.beforeBody, fillLineOfText); | ||
xLinePadding = drawColorBoxes && bodyAlign !== 'right' | ||
? bodyAlign === 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize + 2) | ||
: 0; | ||
// Draw body lines now | ||
helpers$1.each(body, ( /** | ||
* @param {?} bodyItem | ||
* @param {?} i | ||
* @return {?} | ||
*/function (bodyItem, i) { | ||
textColor = vm.labelTextColors[i]; | ||
ctx.fillStyle = textColor; | ||
helpers$1.each(bodyItem.before, fillLineOfText); | ||
// Draw Legend-like boxes if needed | ||
if (drawColorBoxes) { | ||
// Fill a white rect so that colours merge nicely if the opacity is < 1 | ||
ctx.fillStyle = vm.legendColorBackground; | ||
ctx.fillRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Border | ||
ctx.lineWidth = 1; | ||
ctx.strokeStyle = labelColors[i].borderColor; | ||
ctx.strokeRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Inner square | ||
ctx.fillStyle = labelColors[i].backgroundColor; | ||
ctx.fillRect(colorX + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2); | ||
ctx.fillStyle = textColor; | ||
} | ||
helpers$1.each(bodyItem.lines, fillLineOfText); | ||
helpers$1.each(bodyItem.after, fillLineOfText); | ||
})); | ||
// Reset back to 0 for after body | ||
xLinePadding = 0; | ||
// After body lines | ||
helpers$1.each(vm.afterBody, fillLineOfText); | ||
pt.y -= bodySpacing; // Remove last body spacing | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsTooltip() { | ||
Chart.Tooltip.prototype.drawBody = drawBody; | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
exports.ChartsModule = ChartsModule; | ||
@@ -1056,2 +1629,4 @@ exports.BaseChartDirective = BaseChartDirective; | ||
exports.ThemeService = ThemeService; | ||
exports.monkeyPatchChartJsLegend = monkeyPatchChartJsLegend; | ||
exports.monkeyPatchChartJsTooltip = monkeyPatchChartJsTooltip; | ||
@@ -1058,0 +1633,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("chart.js"),require("@angular/core"),require("rxjs"),require("lodash")):"function"==typeof define&&define.amd?define("ng2-charts",["exports","chart.js","@angular/core","rxjs","lodash"],r):r(t["ng2-charts"]={},t.chart_js,t.ng.core,t.rxjs,t._)}(this,function(t,e,o,r,n){"use strict";var a=function(){return(a=Object.assign||function(t){for(var r,e=1,o=arguments.length;e<o;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t}).apply(this,arguments)};function s(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var o,a,s=e.call(t),n=[];try{for(;(void 0===r||0<r--)&&!(o=s.next()).done;)n.push(o.value)}catch(i){a={error:i}}finally{try{o&&!o.done&&(e=s["return"])&&e.call(s)}finally{if(a)throw a.error}}return n}var i=[[255,99,132],[54,162,235],[255,206,86],[231,233,237],[75,192,192],[151,187,205],[220,220,220],[247,70,74],[70,191,189],[253,180,92],[148,159,177],[77,83,96]];function h(t,r,e){if("pie"===t||"doughnut"===t)return l(f(e));if("polarArea"===t)return function o(t){return{backgroundColor:t.map(function(t){return d(t,.6)}),borderColor:t.map(function(t){return d(t,1)}),hoverBackgroundColor:t.map(function(t){return d(t,.8)}),hoverBorderColor:t.map(function(t){return d(t,1)})}}(f(e));if("line"===t||"radar"===t)return function a(t){return{backgroundColor:d(t,.4),borderColor:d(t,1),pointBackgroundColor:d(t,1),pointBorderColor:"#fff",pointHoverBackgroundColor:"#fff",pointHoverBorderColor:d(t,.8)}}(p(r));if("bar"===t||"horizontalBar"===t)return function s(t){return{backgroundColor:d(t,.6),borderColor:d(t,1),hoverBackgroundColor:d(t,.8),hoverBorderColor:d(t,1)}}(p(r));if("bubble"===t)return l(f(e));if("scatter"===t)return l(f(e));throw new Error("getColors - Unsupported chart type "+t)}function d(t,r){return"rgba("+t.concat(r).join(",")+")"}function u(t,r){return Math.floor(Math.random()*(r-t+1))+t}function l(t){return{backgroundColor:t.map(function(t){return d(t,.6)}),borderColor:t.map(function(){return"#fff"}),pointBackgroundColor:t.map(function(t){return d(t,1)}),pointBorderColor:t.map(function(){return"#fff"}),pointHoverBackgroundColor:t.map(function(t){return d(t,1)}),pointHoverBorderColor:t.map(function(t){return d(t,1)})}}function c(){return[u(0,255),u(0,255),u(0,255)]}function p(t){return i[t]||c()}function f(t){for(var r=new Array(t),e=0;e<t;e++)r[e]=i[e]||c();return r}var g=function(){function t(){this.pColorschemesOptions={},this.colorschemesOptions=new r.BehaviorSubject({})}return t.prototype.setColorschemesOptions=function(t){this.pColorschemesOptions=t,this.colorschemesOptions.next(t)},t.prototype.getColorschemesOptions=function(){return this.pColorschemesOptions},t.decorators=[{type:o.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[]},t.ngInjectableDef=o.defineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}(),y={Default:0,Update:1,Refresh:2};y[y.Default]="Default",y[y.Update]="Update",y[y.Refresh]="Refresh";var b=function(){function t(t,r){this.element=t,this.themeService=r,this.options={},this.chartClick=new o.EventEmitter,this.chartHover=new o.EventEmitter,this.old={dataExists:!1,dataLength:0,datasetsExists:!1,datasetsLength:0,datasetsDataObjects:[],datasetsDataLengths:[],colorsExists:!1,colors:[],labelsExist:!1,labels:[]},this.subs=[]}return t.registerPlugin=function(t){e.Chart.plugins.register(t)},t.unregisterPlugin=function(t){e.Chart.plugins.unregister(t)},t.prototype.ngOnInit=function(){var r=this;this.ctx=this.element.nativeElement.getContext("2d"),this.refresh(),this.subs.push(this.themeService.colorschemesOptions.subscribe(function(t){return r.themeChanged(t)}))},t.prototype.themeChanged=function(t){this.refresh()},t.prototype.ngDoCheck=function(){var e=this;if(this.chart){var r=y.Default,t=function(t){r=r<t?t:r};switch(!!this.data!==this.old.dataExists&&(this.propagateDataToDatasets(this.data),this.old.dataExists=!!this.data,t(y.Update)),this.data&&this.data.length!==this.old.dataLength&&(this.old.dataLength=this.data&&this.data.length||0,t(y.Update)),!!this.datasets!==this.old.datasetsExists&&(this.old.datasetsExists=!!this.datasets,t(y.Update)),this.datasets&&this.datasets.length!==this.old.datasetsLength&&(this.old.datasetsLength=this.datasets&&this.datasets.length||0,t(y.Update)),this.datasets&&this.datasets.filter(function(t,r){return t.data!==e.old.datasetsDataObjects[r]}).length&&(this.old.datasetsDataObjects=this.datasets.map(function(t){return t.data}),t(y.Update)),this.datasets&&this.datasets.filter(function(t,r){return t.data.length!==e.old.datasetsDataLengths[r]}).length&&(this.old.datasetsDataLengths=this.datasets.map(function(t){return t.data.length}),t(y.Update)),!!this.colors!==this.old.colorsExists&&(this.old.colorsExists=!!this.colors,this.updateColors(),t(y.Update)),this.colors&&this.colors.filter(function(t,r){return!e.colorsEqual(t,e.old.colors[r])}).length&&(this.old.colors=this.colors.map(function(t){return e.copyColor(t)}),this.updateColors(),t(y.Update)),!!this.labels!==this.old.labelsExist&&(this.old.labelsExist=!!this.labels,t(y.Update)),this.labels&&this.labels.filter(function(t,r){return!e.labelsEqual(t,e.old.labels[r])}).length&&(this.old.labels=this.labels.map(function(t){return e.copyLabel(t)}),t(y.Update)),r){case y.Default:break;case y.Update:this.update();break;case y.Refresh:this.refresh()}}},t.prototype.copyLabel=function(t){return Array.isArray(t)?function e(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(s(arguments[r]));return t}(t):t},t.prototype.labelsEqual=function(t,e){return Array.isArray(t)===Array.isArray(e)&&(Array.isArray(t)||t===e)&&(!Array.isArray(t)||t.length===e.length)&&(!Array.isArray(t)||0===t.filter(function(t,r){return t!==e[r]}).length)},t.prototype.copyColor=function(t){return{backgroundColor:t.backgroundColor,borderWidth:t.borderWidth,borderColor:t.borderColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,pointBorderColor:t.pointBorderColor,pointBackgroundColor:t.pointBackgroundColor,pointBorderWidth:t.pointBorderWidth,pointRadius:t.pointRadius,pointHoverRadius:t.pointHoverRadius,pointHitRadius:t.pointHitRadius,pointHoverBackgroundColor:t.pointHoverBackgroundColor,pointHoverBorderColor:t.pointHoverBorderColor,pointHoverBorderWidth:t.pointHoverBorderWidth,pointStyle:t.pointStyle,hoverBackgroundColor:t.hoverBackgroundColor,hoverBorderColor:t.hoverBorderColor,hoverBorderWidth:t.hoverBorderWidth}},t.prototype.colorsEqual=function(t,r){return!t==!r&&(!t||t.backgroundColor===r.backgroundColor&&t.borderWidth===r.borderWidth&&t.borderColor===r.borderColor&&t.borderCapStyle===r.borderCapStyle&&t.borderDash===r.borderDash&&t.borderDashOffset===r.borderDashOffset&&t.borderJoinStyle===r.borderJoinStyle&&t.pointBorderColor===r.pointBorderColor&&t.pointBackgroundColor===r.pointBackgroundColor&&t.pointBorderWidth===r.pointBorderWidth&&t.pointRadius===r.pointRadius&&t.pointHoverRadius===r.pointHoverRadius&&t.pointHitRadius===r.pointHitRadius&&t.pointHoverBackgroundColor===r.pointHoverBackgroundColor&&t.pointHoverBorderColor===r.pointHoverBorderColor&&t.pointHoverBorderWidth===r.pointHoverBorderWidth&&t.pointStyle===r.pointStyle&&t.hoverBackgroundColor===r.hoverBackgroundColor&&t.hoverBorderColor===r.hoverBorderColor&&t.hoverBorderWidth===r.hoverBorderWidth)},t.prototype.updateColors=function(){var e=this;this.datasets.forEach(function(t,r){e.colors&&e.colors[r]?Object.assign(t,e.colors[r]):Object.assign(t,h(e.chartType,r,t.data.length),a({},t))})},t.prototype.ngOnChanges=function(t){var r=y.Default,e=function(t){r=r<t?t:r};switch(t.hasOwnProperty("data")&&t.data.currentValue&&(this.propagateDataToDatasets(t.data.currentValue),e(y.Update)),t.hasOwnProperty("datasets")&&t.datasets.currentValue&&(this.propagateDatasetsToData(t.datasets.currentValue),e(y.Update)),t.hasOwnProperty("labels")&&(this.chart&&(this.chart.data.labels=t.labels.currentValue),e(y.Update)),t.hasOwnProperty("legend")&&(this.chart&&(this.chart.config.options.legend.display=t.legend.currentValue,this.chart.generateLegend()),e(y.Update)),t.hasOwnProperty("options")&&e(y.Refresh),r){case y.Update:this.update();break;case y.Refresh:case y.Default:this.refresh()}},t.prototype.ngOnDestroy=function(){this.chart&&(this.chart.destroy(),this.chart=void 0),this.subs.forEach(function(t){return t.unsubscribe()})},t.prototype.update=function(t,r){if(this.chart)return this.chart.update(t,r)},t.prototype.hideDataset=function(t,r){this.chart.getDatasetMeta(t).hidden=r,this.chart.update()},t.prototype.isDatasetHidden=function(t){return this.chart.getDatasetMeta(t).hidden},t.prototype.toBase64Image=function(){return this.chart.toBase64Image()},t.prototype.getChartConfiguration=function(){var e=this,t=this.getDatasets(),r=Object.assign({},this.options);!1===this.legend&&(r.legend={display:!1}),r.hover=r.hover||{},r.hover.onHover||(r.hover.onHover=function(t,r){r&&!r.length||e.chartHover.emit({event:t,active:r})}),r.onClick||(r.onClick=function(t,r){e.chartClick.emit({event:t,active:r})});var o=this.smartMerge(r,this.themeService.getColorschemesOptions());return{type:this.chartType,data:{labels:this.labels||[],datasets:t},plugins:this.plugins,options:o}},t.prototype.getChartBuilder=function(t){var r=this.getChartConfiguration();return new e.Chart(t,r)},t.prototype.smartMerge=function(e,o,a){var s=this;if(void 0===a&&(a=0),0===a&&(e=n.cloneDeep(e)),Object.keys(o).forEach(function(r){if(Array.isArray(o[r])){var t=e[r];t&&t.forEach(function(t){s.smartMerge(t,o[r][0],a+1)})}else"object"==typeof o[r]?(r in e||(e[r]={}),s.smartMerge(e[r],o[r],a+1)):e[r]=o[r]}),0===a)return e},t.prototype.isMultiLineLabel=function(t){return Array.isArray(t)},t.prototype.joinLabel=function(t){return t?this.isMultiLineLabel(t)?t.join(" "):t:null},t.prototype.propagateDatasetsToData=function(t){this.data=this.datasets.map(function(t){return t.data}),this.chart&&(this.chart.data.datasets=t),this.updateColors()},t.prototype.propagateDataToDatasets=function(e){var o=this;this.isMultiDataSet(e)?this.datasets&&e.length===this.datasets.length?this.datasets.forEach(function(t,r){t.data=e[r]}):(this.datasets=e.map(function(t,r){return{data:t,label:o.joinLabel(o.labels[r])||"Label "+r}}),this.chart&&(this.chart.data.datasets=this.datasets)):this.datasets?(this.datasets[0].data=e,this.datasets.splice(1)):(this.datasets=[{data:e}],this.chart&&(this.chart.data.datasets=this.datasets)),this.updateColors()},t.prototype.isMultiDataSet=function(t){return Array.isArray(t[0])},t.prototype.getDatasets=function(){if(!this.datasets&&!this.data)throw new Error("ng-charts configuration error, data or datasets field are required to render chart "+this.chartType);return this.datasets?(this.propagateDatasetsToData(this.datasets),this.datasets):this.data?(this.propagateDataToDatasets(this.data),this.datasets):void 0},t.prototype.refresh=function(){this.chart&&(this.chart.destroy(),this.chart=void 0),this.ctx&&(this.chart=this.getChartBuilder(this.ctx))},t.decorators=[{type:o.Directive,args:[{selector:"canvas[baseChart]",exportAs:"base-chart"}]}],t.ctorParameters=function(){return[{type:o.ElementRef},{type:g}]},t.propDecorators={data:[{type:o.Input}],datasets:[{type:o.Input}],labels:[{type:o.Input}],options:[{type:o.Input}],chartType:[{type:o.Input}],colors:[{type:o.Input}],legend:[{type:o.Input}],plugins:[{type:o.Input}],chartClick:[{type:o.Output}],chartHover:[{type:o.Output}]},t}(),C=function(){function t(){}return t.decorators=[{type:o.NgModule,args:[{declarations:[b],imports:[],exports:[b]}]}],t}();t.ChartsModule=C,t.BaseChartDirective=b,t.defaultColors=i,t.ThemeService=g,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("@angular/core"),require("rxjs"),require("lodash")):"function"==typeof define&&define.amd?define("ng2-charts",["exports","chart.js","@angular/core","rxjs","lodash"],e):e(t["ng2-charts"]={},t.chart_js,t.ng.core,t.rxjs,t._)}(this,function(t,r,o,e,i){"use strict";var a=function(){return(a=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t}).apply(this,arguments)};function n(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,a,n=r.call(t),i=[];try{for(;(void 0===e||0<e--)&&!(o=n.next()).done;)i.push(o.value)}catch(s){a={error:s}}finally{try{o&&!o.done&&(r=n["return"])&&r.call(n)}finally{if(a)throw a.error}}return i}var s=[[255,99,132],[54,162,235],[255,206,86],[231,233,237],[75,192,192],[151,187,205],[220,220,220],[247,70,74],[70,191,189],[253,180,92],[148,159,177],[77,83,96]];function l(t,e,r){if("pie"===t||"doughnut"===t)return u(f(r));if("polarArea"===t)return function o(t){return{backgroundColor:t.map(function(t){return h(t,.6)}),borderColor:t.map(function(t){return h(t,1)}),hoverBackgroundColor:t.map(function(t){return h(t,.8)}),hoverBorderColor:t.map(function(t){return h(t,1)})}}(f(r));if("line"===t||"radar"===t)return function a(t){return{backgroundColor:h(t,.4),borderColor:h(t,1),pointBackgroundColor:h(t,1),pointBorderColor:"#fff",pointHoverBackgroundColor:"#fff",pointHoverBorderColor:h(t,.8)}}(p(e));if("bar"===t||"horizontalBar"===t)return function n(t){return{backgroundColor:h(t,.6),borderColor:h(t,1),hoverBackgroundColor:h(t,.8),hoverBorderColor:h(t,1)}}(p(e));if("bubble"===t)return u(f(r));if("scatter"===t)return u(f(r));throw new Error("getColors - Unsupported chart type "+t)}function h(t,e){return"rgba("+t.concat(e).join(",")+")"}function d(t,e){return Math.floor(Math.random()*(e-t+1))+t}function u(t){return{backgroundColor:t.map(function(t){return h(t,.6)}),borderColor:t.map(function(){return"#fff"}),pointBackgroundColor:t.map(function(t){return h(t,1)}),pointBorderColor:t.map(function(){return"#fff"}),pointHoverBackgroundColor:t.map(function(t){return h(t,1)}),pointHoverBorderColor:t.map(function(t){return h(t,1)})}}function c(){return[d(0,255),d(0,255),d(0,255)]}function p(t){return s[t]||c()}function f(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=s[r]||c();return e}var g=function(){function t(){this.pColorschemesOptions={},this.colorschemesOptions=new e.BehaviorSubject({})}return t.prototype.setColorschemesOptions=function(t){this.pColorschemesOptions=t,this.colorschemesOptions.next(t)},t.prototype.getColorschemesOptions=function(){return this.pColorschemesOptions},t.decorators=[{type:o.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[]},t.ngInjectableDef=o.defineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}(),y={Default:0,Update:1,Refresh:2};y[y.Default]="Default",y[y.Update]="Update",y[y.Refresh]="Refresh";var b=function(){function t(t,e){this.element=t,this.themeService=e,this.options={},this.chartClick=new o.EventEmitter,this.chartHover=new o.EventEmitter,this.old={dataExists:!1,dataLength:0,datasetsExists:!1,datasetsLength:0,datasetsDataObjects:[],datasetsDataLengths:[],colorsExists:!1,colors:[],labelsExist:!1,labels:[]},this.subs=[]}return t.registerPlugin=function(t){r.Chart.plugins.register(t)},t.unregisterPlugin=function(t){r.Chart.plugins.unregister(t)},t.prototype.ngOnInit=function(){var e=this;this.ctx=this.element.nativeElement.getContext("2d"),this.refresh(),this.subs.push(this.themeService.colorschemesOptions.subscribe(function(t){return e.themeChanged(t)}))},t.prototype.themeChanged=function(t){this.refresh()},t.prototype.ngDoCheck=function(){var r=this;if(this.chart){var e=y.Default,t=function(t){e=e<t?t:e};switch(!!this.data!==this.old.dataExists&&(this.propagateDataToDatasets(this.data),this.old.dataExists=!!this.data,t(y.Update)),this.data&&this.data.length!==this.old.dataLength&&(this.old.dataLength=this.data&&this.data.length||0,t(y.Update)),!!this.datasets!==this.old.datasetsExists&&(this.old.datasetsExists=!!this.datasets,t(y.Update)),this.datasets&&this.datasets.length!==this.old.datasetsLength&&(this.old.datasetsLength=this.datasets&&this.datasets.length||0,t(y.Update)),this.datasets&&this.datasets.filter(function(t,e){return t.data!==r.old.datasetsDataObjects[e]}).length&&(this.old.datasetsDataObjects=this.datasets.map(function(t){return t.data}),t(y.Update)),this.datasets&&this.datasets.filter(function(t,e){return t.data.length!==r.old.datasetsDataLengths[e]}).length&&(this.old.datasetsDataLengths=this.datasets.map(function(t){return t.data.length}),t(y.Update)),!!this.colors!==this.old.colorsExists&&(this.old.colorsExists=!!this.colors,this.updateColors(),t(y.Update)),this.colors&&this.colors.filter(function(t,e){return!r.colorsEqual(t,r.old.colors[e])}).length&&(this.old.colors=this.colors.map(function(t){return r.copyColor(t)}),this.updateColors(),t(y.Update)),!!this.labels!==this.old.labelsExist&&(this.old.labelsExist=!!this.labels,t(y.Update)),this.labels&&this.labels.filter(function(t,e){return!r.labelsEqual(t,r.old.labels[e])}).length&&(this.old.labels=this.labels.map(function(t){return r.copyLabel(t)}),t(y.Update)),e){case y.Default:break;case y.Update:this.update();break;case y.Refresh:this.refresh()}}},t.prototype.copyLabel=function(t){return Array.isArray(t)?function r(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t}(t):t},t.prototype.labelsEqual=function(t,r){return Array.isArray(t)===Array.isArray(r)&&(Array.isArray(t)||t===r)&&(!Array.isArray(t)||t.length===r.length)&&(!Array.isArray(t)||0===t.filter(function(t,e){return t!==r[e]}).length)},t.prototype.copyColor=function(t){return{backgroundColor:t.backgroundColor,borderWidth:t.borderWidth,borderColor:t.borderColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,pointBorderColor:t.pointBorderColor,pointBackgroundColor:t.pointBackgroundColor,pointBorderWidth:t.pointBorderWidth,pointRadius:t.pointRadius,pointHoverRadius:t.pointHoverRadius,pointHitRadius:t.pointHitRadius,pointHoverBackgroundColor:t.pointHoverBackgroundColor,pointHoverBorderColor:t.pointHoverBorderColor,pointHoverBorderWidth:t.pointHoverBorderWidth,pointStyle:t.pointStyle,hoverBackgroundColor:t.hoverBackgroundColor,hoverBorderColor:t.hoverBorderColor,hoverBorderWidth:t.hoverBorderWidth}},t.prototype.colorsEqual=function(t,e){return!t==!e&&(!t||t.backgroundColor===e.backgroundColor&&t.borderWidth===e.borderWidth&&t.borderColor===e.borderColor&&t.borderCapStyle===e.borderCapStyle&&t.borderDash===e.borderDash&&t.borderDashOffset===e.borderDashOffset&&t.borderJoinStyle===e.borderJoinStyle&&t.pointBorderColor===e.pointBorderColor&&t.pointBackgroundColor===e.pointBackgroundColor&&t.pointBorderWidth===e.pointBorderWidth&&t.pointRadius===e.pointRadius&&t.pointHoverRadius===e.pointHoverRadius&&t.pointHitRadius===e.pointHitRadius&&t.pointHoverBackgroundColor===e.pointHoverBackgroundColor&&t.pointHoverBorderColor===e.pointHoverBorderColor&&t.pointHoverBorderWidth===e.pointHoverBorderWidth&&t.pointStyle===e.pointStyle&&t.hoverBackgroundColor===e.hoverBackgroundColor&&t.hoverBorderColor===e.hoverBorderColor&&t.hoverBorderWidth===e.hoverBorderWidth)},t.prototype.updateColors=function(){var r=this;this.datasets.forEach(function(t,e){r.colors&&r.colors[e]?Object.assign(t,r.colors[e]):Object.assign(t,l(r.chartType,e,t.data.length),a({},t))})},t.prototype.ngOnChanges=function(t){var e=y.Default,r=function(t){e=e<t?t:e};switch(t.hasOwnProperty("data")&&t.data.currentValue&&(this.propagateDataToDatasets(t.data.currentValue),r(y.Update)),t.hasOwnProperty("datasets")&&t.datasets.currentValue&&(this.propagateDatasetsToData(t.datasets.currentValue),r(y.Update)),t.hasOwnProperty("labels")&&(this.chart&&(this.chart.data.labels=t.labels.currentValue),r(y.Update)),t.hasOwnProperty("legend")&&(this.chart&&(this.chart.config.options.legend.display=t.legend.currentValue,this.chart.generateLegend()),r(y.Update)),t.hasOwnProperty("options")&&r(y.Refresh),e){case y.Update:this.update();break;case y.Refresh:case y.Default:this.refresh()}},t.prototype.ngOnDestroy=function(){this.chart&&(this.chart.destroy(),this.chart=void 0),this.subs.forEach(function(t){return t.unsubscribe()})},t.prototype.update=function(t,e){if(this.chart)return this.chart.update(t,e)},t.prototype.hideDataset=function(t,e){this.chart.getDatasetMeta(t).hidden=e,this.chart.update()},t.prototype.isDatasetHidden=function(t){return this.chart.getDatasetMeta(t).hidden},t.prototype.toBase64Image=function(){return this.chart.toBase64Image()},t.prototype.getChartConfiguration=function(){var r=this,t=this.getDatasets(),e=Object.assign({},this.options);!1===this.legend&&(e.legend={display:!1}),e.hover=e.hover||{},e.hover.onHover||(e.hover.onHover=function(t,e){e&&!e.length||r.chartHover.emit({event:t,active:e})}),e.onClick||(e.onClick=function(t,e){r.chartClick.emit({event:t,active:e})});var o=this.smartMerge(e,this.themeService.getColorschemesOptions());return{type:this.chartType,data:{labels:this.labels||[],datasets:t},plugins:this.plugins,options:o}},t.prototype.getChartBuilder=function(t){var e=this.getChartConfiguration();return new r.Chart(t,e)},t.prototype.smartMerge=function(r,o,a){var n=this;if(void 0===a&&(a=0),0===a&&(r=i.cloneDeep(r)),Object.keys(o).forEach(function(e){if(Array.isArray(o[e])){var t=r[e];t&&t.forEach(function(t){n.smartMerge(t,o[e][0],a+1)})}else"object"==typeof o[e]?(e in r||(r[e]={}),n.smartMerge(r[e],o[e],a+1)):r[e]=o[e]}),0===a)return r},t.prototype.isMultiLineLabel=function(t){return Array.isArray(t)},t.prototype.joinLabel=function(t){return t?this.isMultiLineLabel(t)?t.join(" "):t:null},t.prototype.propagateDatasetsToData=function(t){this.data=this.datasets.map(function(t){return t.data}),this.chart&&(this.chart.data.datasets=t),this.updateColors()},t.prototype.propagateDataToDatasets=function(r){var o=this;this.isMultiDataSet(r)?this.datasets&&r.length===this.datasets.length?this.datasets.forEach(function(t,e){t.data=r[e]}):(this.datasets=r.map(function(t,e){return{data:t,label:o.joinLabel(o.labels[e])||"Label "+e}}),this.chart&&(this.chart.data.datasets=this.datasets)):this.datasets?(this.datasets[0].data=r,this.datasets.splice(1)):(this.datasets=[{data:r}],this.chart&&(this.chart.data.datasets=this.datasets)),this.updateColors()},t.prototype.isMultiDataSet=function(t){return Array.isArray(t[0])},t.prototype.getDatasets=function(){if(!this.datasets&&!this.data)throw new Error("ng-charts configuration error, data or datasets field are required to render chart "+this.chartType);return this.datasets?(this.propagateDatasetsToData(this.datasets),this.datasets):this.data?(this.propagateDataToDatasets(this.data),this.datasets):void 0},t.prototype.refresh=function(){this.chart&&(this.chart.destroy(),this.chart=void 0),this.ctx&&(this.chart=this.getChartBuilder(this.ctx))},t.decorators=[{type:o.Directive,args:[{selector:"canvas[baseChart]",exportAs:"base-chart"}]}],t.ctorParameters=function(){return[{type:o.ElementRef},{type:g}]},t.propDecorators={data:[{type:o.Input}],datasets:[{type:o.Input}],labels:[{type:o.Input}],options:[{type:o.Input}],chartType:[{type:o.Input}],colors:[{type:o.Input}],legend:[{type:o.Input}],plugins:[{type:o.Input}],chartClick:[{type:o.Output}],chartHover:[{type:o.Output}]},t}(),v=function(){function t(){}return t.decorators=[{type:o.NgModule,args:[{declarations:[b],imports:[],exports:[b]}]}],t}(),O=Chart.helpers,H=Chart.defaults,A=O.valueOrDefault;function T(t,e){return t.usePointStyle&&t.boxWidth>e?e:t.boxWidth}function C(){var t=this,e=t.options,n=e.labels,r=e.display,i=t.ctx,o=O.options._parseFont(n),s=o.size,l=t.legendHitBoxes=[],h=t.minSize,a=t.isHorizontal();h.height=a?(h.width=t.maxWidth,r?10:0):(h.width=r?10:0,t.maxHeight);var d=function(t){return t.map(function(t){return i.measureText(t).width}).reduce(function(t,e){return t<e?e:t},0)};if(r)if(i.font=o.string,a){var u=t.lineWidths=[0],c=0,p=0;i.textAlign="left",i.textBaseline="top",O.each(t.legendItems,function(t,e){var r,o,a;a=O.isArray(t.text)?(r=d(t.text),o=s*t.text.length):(r=i.measureText(t.text).width,(o=s)+n.padding),r+=T(n,s)+s/2,c<a&&(c=a),u[u.length-1]+r+2*n.padding>h.width&&(p+=c,c=0,u[u.length-(0<e?0:1)]=0),l[e]={left:0,top:0,width:r,height:o},u[u.length-1]+=r+n.padding}),h.height+=p+c}else{var f=n.padding,g=t.columnWidths=[],y=t.columnHeights=[],b=n.padding,v=0,C=0;O.each(t.legendItems,function(t,e){var r,o;o=O.isArray(t.text)?(r=d(t.text),s*t.text.length):(r=i.measureText(t.text).width,s),r+=T(n,s)+s/2,0<e&&C+s+2*f>h.height&&(b+=v+n.padding,g.push(v),y.push(C),C=v=0),v=Math.max(v,r),C+=s+f,l[e]={left:0,top:0,width:r,height:o}}),b+=v,g.push(v),y.push(C),h.width+=b}t.width=h.width,t.height=h.height}function m(){var l=this,h=l.options,d=h.labels,t=H.global,u=t.defaultColor,c=t.elements.line,p=l.height,f=l.columnHeights,g=l.width,y=l.lineWidths;if(h.display){var b,v=l.ctx,e=A(d.fontColor,t.defaultFontColor),r=O.options._parseFont(d),C=r.size;v.textAlign="left",v.textBaseline="middle",v.lineWidth=.5,v.strokeStyle=e,v.fillStyle=e,v.font=r.string;var m=T(d,C),x=l.legendHitBoxes,B=x.map(function(t){return t.height}).reduce(function(t,e){return t<e?e:t},0),D=function(t,e,r,o){var a,n,i,s,l,h,d,u=C/2,c=m+u+t,p=e+u;O.isArray(r.text)?O.each(r.text,function(t,e){var r=e*C;v.fillText(t,c,p+r)}):v.fillText(r.text,c,p),r.hidden&&(O.isArray(r.text)?(s=c,l=p,h=o,d=(r.text.length-1)*(C-1),v.beginPath(),v.lineWidth=2,v.moveTo(s,l),v.lineTo(s+h,l+d),v.moveTo(s,l+d),v.lineTo(s+h,l)):(a=c,n=p,i=o,v.beginPath(),v.lineWidth=2,v.moveTo(a,n),v.lineTo(a+i,n)),v.stroke())},k=function(t,e){switch(h.align){case"start":return d.padding;case"end":return t-e;default:return(t-e+d.padding)/2}},S=l.isHorizontal();b=S?{x:l.left+k(g,y[0]),y:l.top+d.padding,line:0}:{x:l.left+d.padding,y:l.top+k(p,f[0]),line:0};var w=B;O.each(l.legendItems,function(t,e){var r,o;o=O.isArray(t.text)?(r=t.text.map(function(t){return v.measureText(t).width}).reduce(function(t,e){return t<e?e:t},0),C/2*(t.text.length-1)):(r=v.measureText(t.text).width,0);var a=m+C/2+r,n=b.x,i=Math.trunc((B-x[e].height)/2),s=b.y+i;S?0<e&&n+a+d.padding>l.left+l.minSize.width&&(s=b.y+=w,b.line++,n=b.x=l.left+k(g,y[b.line])):0<e&&s+w>l.top+l.minSize.height&&(n=b.x=n+l.columnWidths[b.line]+d.padding,b.line++,s=b.y=l.top+k(p,f[b.line])),function(t,e,r){if(!(isNaN(m)||m<=0)){v.save();var o=A(r.lineWidth,c.borderWidth);if(v.fillStyle=A(r.fillStyle,u),v.lineCap=A(r.lineCap,c.borderCapStyle),v.lineDashOffset=A(r.lineDashOffset,c.borderDashOffset),v.lineJoin=A(r.lineJoin,c.borderJoinStyle),v.lineWidth=o,v.strokeStyle=A(r.strokeStyle,u),v.setLineDash&&v.setLineDash(A(r.lineDash,c.borderDash)),h.labels&&h.labels.usePointStyle){var a=m*Math.SQRT2/2,n=t+m/2,i=e+C/2;O.canvas.drawPoint(v,r.pointStyle,a,n,i)}else 0!==o&&v.strokeRect(t,e,m,C),v.fillRect(t,e,m,C);v.restore()}}(n,s+o,t),x[e].left=n,x[e].top=s,D(n,s,t,r),S?b.x+=a+d.padding:b.y+=w})}}var x=Chart.helpers;function B(t,e){return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-t.xPadding:t.x+t.xPadding}function D(r,o,a){var n,i=o.bodyFontSize,e=o.bodySpacing,t=o._bodyAlign,s=o.body,l=o.displayColors,h=o.labelColors,d=0,u=l?B(o,"left"):0;a.textAlign=t,a.textBaseline="top",a.font=x.fontString(i,o._bodyFontStyle,o._bodyFontFamily),r.x=B(o,t);var c=function(t){a.fillText(t,r.x+d,r.y),r.y+=i+e};a.fillStyle=o.bodyFontColor,x.each(o.beforeBody,c),d=l&&"right"!==t?"center"===t?i/2+1:i+2:0,x.each(s,function(t,e){n=o.labelTextColors[e],a.fillStyle=n,x.each(t.before,c),l&&(a.fillStyle=o.legendColorBackground,a.fillRect(u,r.y,i,i),a.lineWidth=1,a.strokeStyle=h[e].borderColor,a.strokeRect(u,r.y,i,i),a.fillStyle=h[e].backgroundColor,a.fillRect(u+1,r.y+1,i-2,i-2),a.fillStyle=n),x.each(t.lines,c),x.each(t.after,c)}),d=0,x.each(o.afterBody,c),r.y-=e}t.ChartsModule=v,t.BaseChartDirective=b,t.defaultColors=s,t.ThemeService=g,t.monkeyPatchChartJsLegend=function k(){var t=Chart.plugins.getAll().filter(function(t){return"legend"===t.id})[0];t._element.prototype.fit=C,t._element.prototype.draw=m},t.monkeyPatchChartJsTooltip=function S(){Chart.Tooltip.prototype.drawBody=D},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ng2-charts.umd.min.js.map |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmcyLWNoYXJ0cy5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJuZzItY2hhcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw4RUFBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG4iXX0= | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmcyLWNoYXJ0cy5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJuZzItY2hhcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxtSUFBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG4iXX0= |
@@ -14,2 +14,4 @@ /** | ||
export { ThemeService } from './lib/theme.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyxtQ0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxlQUFjLGFBQWEsQ0FBQztBQUM1QixlQUFjLGNBQWMsQ0FBQztBQUM3Qiw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyw2QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZzItY2hhcnRzXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hhcnRzLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2Jhc2UtY2hhcnQuZGlyZWN0aXZlJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY29sb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb2xvcnMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9kZWZhdWx0LWNvbG9ycyc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3RoZW1lLnNlcnZpY2UnO1xyXG4iXX0= | ||
export { monkeyPatchChartJsLegend } from './lib/monkey-patch-chart-js-legend'; | ||
export { monkeyPatchChartJsTooltip } from './lib/monkey-patch-chart-js-tooltip'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyxtQ0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxlQUFjLGFBQWEsQ0FBQztBQUM1QixlQUFjLGNBQWMsQ0FBQztBQUM3Qiw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyx5Q0FBYyxvQ0FBb0MsQ0FBQztBQUNuRCwwQ0FBYyxxQ0FBcUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZzItY2hhcnRzXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hhcnRzLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2Jhc2UtY2hhcnQuZGlyZWN0aXZlJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY29sb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb2xvcnMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9kZWZhdWx0LWNvbG9ycyc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3RoZW1lLnNlcnZpY2UnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9tb25rZXktcGF0Y2gtY2hhcnQtanMtbGVnZW5kJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9ua2V5LXBhdGNoLWNoYXJ0LWpzLXRvb2x0aXAnO1xyXG4iXX0= |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmcyLWNoYXJ0cy5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJuZzItY2hhcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw4RUFBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG4iXX0= | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmcyLWNoYXJ0cy5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJuZzItY2hhcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxtSUFBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG4iXX0= |
@@ -14,2 +14,4 @@ /** | ||
export { ThemeService } from './lib/theme.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyxtQ0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxlQUFjLGFBQWEsQ0FBQztBQUM1QixlQUFjLGNBQWMsQ0FBQztBQUM3Qiw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyw2QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZzItY2hhcnRzXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hhcnRzLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2Jhc2UtY2hhcnQuZGlyZWN0aXZlJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY29sb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb2xvcnMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9kZWZhdWx0LWNvbG9ycyc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3RoZW1lLnNlcnZpY2UnO1xyXG4iXX0= | ||
export { monkeyPatchChartJsLegend } from './lib/monkey-patch-chart-js-legend'; | ||
export { monkeyPatchChartJsTooltip } from './lib/monkey-patch-chart-js-tooltip'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nMi1jaGFydHMvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyxtQ0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxlQUFjLGFBQWEsQ0FBQztBQUM1QixlQUFjLGNBQWMsQ0FBQztBQUM3Qiw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyw2QkFBYyxxQkFBcUIsQ0FBQztBQUNwQyx5Q0FBYyxvQ0FBb0MsQ0FBQztBQUNuRCwwQ0FBYyxxQ0FBcUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZzItY2hhcnRzXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hhcnRzLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2Jhc2UtY2hhcnQuZGlyZWN0aXZlJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvY29sb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb2xvcnMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9kZWZhdWx0LWNvbG9ycyc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3RoZW1lLnNlcnZpY2UnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9tb25rZXktcGF0Y2gtY2hhcnQtanMtbGVnZW5kJztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9ua2V5LXBhdGNoLWNoYXJ0LWpzLXRvb2x0aXAnO1xyXG4iXX0= |
@@ -1,2 +0,2 @@ | ||
import { Chart } from 'chart.js'; | ||
import { Chart as Chart$1 } from 'chart.js'; | ||
import { Injectable, NgModule, Directive, Input, Output, EventEmitter, ElementRef, defineInjectable } from '@angular/core'; | ||
@@ -269,3 +269,3 @@ import { BehaviorSubject } from 'rxjs'; | ||
static registerPlugin(plugin) { | ||
Chart.plugins.register(plugin); | ||
Chart$1.plugins.register(plugin); | ||
} | ||
@@ -277,3 +277,3 @@ /** | ||
static unregisterPlugin(plugin) { | ||
Chart.plugins.unregister(plugin); | ||
Chart$1.plugins.unregister(plugin); | ||
} | ||
@@ -665,3 +665,3 @@ /** | ||
const chartConfig = this.getChartConfiguration(); | ||
return new Chart(ctx, chartConfig); | ||
return new Chart$1(ctx, chartConfig); | ||
} | ||
@@ -898,2 +898,485 @@ /** | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
const helpers = Chart.helpers; | ||
/** @type {?} */ | ||
const defaults = Chart.defaults; | ||
/** @type {?} */ | ||
const valueOrDefault = helpers.valueOrDefault; | ||
/** | ||
* @param {?} labelOpts | ||
* @param {?} fontSize | ||
* @return {?} | ||
*/ | ||
function getBoxWidth(labelOpts, fontSize) { | ||
return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? | ||
fontSize : | ||
labelOpts.boxWidth; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function fit() { | ||
/** @type {?} */ | ||
const me = this; | ||
/** @type {?} */ | ||
const opts = me.options; | ||
/** @type {?} */ | ||
const labelOpts = opts.labels; | ||
/** @type {?} */ | ||
const display = opts.display; | ||
/** @type {?} */ | ||
const ctx = me.ctx; | ||
/** @type {?} */ | ||
const labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
const fontSize = labelFont.size; | ||
// Reset hit boxes | ||
/** @type {?} */ | ||
const hitboxes = me.legendHitBoxes = []; | ||
/** @type {?} */ | ||
const minSize = me.minSize; | ||
/** @type {?} */ | ||
const isHorizontal = me.isHorizontal(); | ||
if (isHorizontal) { | ||
minSize.width = me.maxWidth; // fill all the width | ||
minSize.height = display ? 10 : 0; | ||
} | ||
else { | ||
minSize.width = display ? 10 : 0; | ||
minSize.height = me.maxHeight; // fill all the height | ||
} | ||
/** @type {?} */ | ||
const getMaxLineWidth = (/** | ||
* @param {?} textLines | ||
* @return {?} | ||
*/ | ||
textLines => { | ||
return textLines.map((/** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/ | ||
textLine => { | ||
return ctx.measureText(textLine).width; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
(acc, v) => { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
}); | ||
// Increase sizes here | ||
if (display) { | ||
ctx.font = labelFont.string; | ||
if (isHorizontal) { | ||
// Labels | ||
// Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one | ||
/** @type {?} */ | ||
const lineWidths = me.lineWidths = [0]; | ||
/** @type {?} */ | ||
let maxHeight = 0; | ||
/** @type {?} */ | ||
let totalHeight = 0; | ||
ctx.textAlign = 'left'; | ||
ctx.textBaseline = 'top'; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
(legendItem, i) => { | ||
/** @type {?} */ | ||
let width; | ||
/** @type {?} */ | ||
let height; | ||
/** @type {?} */ | ||
let grossHeight; | ||
if (helpers.isArray(legendItem.text)) { | ||
width = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
grossHeight = height; | ||
} | ||
else { | ||
width = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
grossHeight = height + labelOpts.padding; | ||
} | ||
width += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
if (grossHeight > maxHeight) { | ||
maxHeight = grossHeight; | ||
} | ||
if (lineWidths[lineWidths.length - 1] + width + 2 * labelOpts.padding > minSize.width) { | ||
totalHeight += maxHeight; | ||
maxHeight = 0; | ||
lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0; | ||
} | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width, | ||
height, | ||
}; | ||
lineWidths[lineWidths.length - 1] += width + labelOpts.padding; | ||
})); | ||
minSize.height += totalHeight + maxHeight; | ||
} | ||
else { | ||
/** @type {?} */ | ||
const vPadding = labelOpts.padding; | ||
/** @type {?} */ | ||
const columnWidths = me.columnWidths = []; | ||
/** @type {?} */ | ||
const columnHeights = me.columnHeights = []; | ||
/** @type {?} */ | ||
let totalWidth = labelOpts.padding; | ||
/** @type {?} */ | ||
let currentColWidth = 0; | ||
/** @type {?} */ | ||
let currentColHeight = 0; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
(legendItem, i) => { | ||
/** @type {?} */ | ||
let itemWidth; | ||
/** @type {?} */ | ||
let height; | ||
if (helpers.isArray(legendItem.text)) { | ||
itemWidth = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
} | ||
else { | ||
itemWidth = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
} | ||
itemWidth += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
// If too tall, go to new column | ||
if (i > 0 && currentColHeight + fontSize + 2 * vPadding > minSize.height) { | ||
totalWidth += currentColWidth + labelOpts.padding; | ||
columnWidths.push(currentColWidth); // previous column width | ||
columnHeights.push(currentColHeight); | ||
currentColWidth = 0; | ||
currentColHeight = 0; | ||
} | ||
// Get max width | ||
currentColWidth = Math.max(currentColWidth, itemWidth); | ||
currentColHeight += fontSize + vPadding; | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width: itemWidth, | ||
height | ||
}; | ||
})); | ||
totalWidth += currentColWidth; | ||
columnWidths.push(currentColWidth); | ||
columnHeights.push(currentColHeight); | ||
minSize.width += totalWidth; | ||
} | ||
} | ||
me.width = minSize.width; | ||
me.height = minSize.height; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function draw() { | ||
/** @type {?} */ | ||
const me = this; | ||
/** @type {?} */ | ||
const opts = me.options; | ||
/** @type {?} */ | ||
const labelOpts = opts.labels; | ||
/** @type {?} */ | ||
const globalDefaults = defaults.global; | ||
/** @type {?} */ | ||
const defaultColor = globalDefaults.defaultColor; | ||
/** @type {?} */ | ||
const lineDefault = globalDefaults.elements.line; | ||
/** @type {?} */ | ||
const legendHeight = me.height; | ||
/** @type {?} */ | ||
const columnHeights = me.columnHeights; | ||
/** @type {?} */ | ||
const legendWidth = me.width; | ||
/** @type {?} */ | ||
const lineWidths = me.lineWidths; | ||
if (opts.display) { | ||
/** @type {?} */ | ||
const ctx = me.ctx; | ||
/** @type {?} */ | ||
const fontColor = valueOrDefault(labelOpts.fontColor, globalDefaults.defaultFontColor); | ||
/** @type {?} */ | ||
const labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
const fontSize = labelFont.size; | ||
/** @type {?} */ | ||
let cursor; | ||
// Canvas setup | ||
ctx.textAlign = 'left'; | ||
ctx.textBaseline = 'middle'; | ||
ctx.lineWidth = 0.5; | ||
ctx.strokeStyle = fontColor; // for strikethrough effect | ||
ctx.fillStyle = fontColor; // render in correct colour | ||
ctx.font = labelFont.string; | ||
/** @type {?} */ | ||
const boxWidth = getBoxWidth(labelOpts, fontSize); | ||
/** @type {?} */ | ||
const hitboxes = me.legendHitBoxes; | ||
/** @type {?} */ | ||
const maxHeight = hitboxes.map((/** | ||
* @param {?} x | ||
* @return {?} | ||
*/ | ||
x => { | ||
return x.height; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
(acc, v) => { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
// current position | ||
/** @type {?} */ | ||
const drawLegendBox = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @return {?} | ||
*/ | ||
(x, y, legendItem) => { | ||
if (isNaN(boxWidth) || boxWidth <= 0) { | ||
return; | ||
} | ||
// Set the ctx for the box | ||
ctx.save(); | ||
/** @type {?} */ | ||
const lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); | ||
ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); | ||
ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); | ||
ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); | ||
ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); | ||
ctx.lineWidth = lineWidth; | ||
ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); | ||
if (ctx.setLineDash) { | ||
// IE 9 and 10 do not support line dash | ||
ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); | ||
} | ||
if (opts.labels && opts.labels.usePointStyle) { | ||
// Recalculate x and y for drawPoint() because its expecting | ||
// x and y to be center of figure (instead of top left) | ||
/** @type {?} */ | ||
const radius = boxWidth * Math.SQRT2 / 2; | ||
/** @type {?} */ | ||
const centerX = x + boxWidth / 2; | ||
/** @type {?} */ | ||
const centerY = y + fontSize / 2; | ||
// Draw pointStyle as legend symbol | ||
helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY); | ||
} | ||
else { | ||
// Draw box as legend symbol | ||
if (lineWidth !== 0) { | ||
ctx.strokeRect(x, y, boxWidth, fontSize); | ||
} | ||
ctx.fillRect(x, y, boxWidth, fontSize); | ||
} | ||
ctx.restore(); | ||
}); | ||
/** @type {?} */ | ||
const drawStrikeThrough = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @return {?} | ||
*/ | ||
(x, y, w) => { | ||
ctx.beginPath(); | ||
ctx.lineWidth = 2; | ||
ctx.moveTo(x, y); | ||
ctx.lineTo(x + w, y); | ||
ctx.stroke(); | ||
}); | ||
/** @type {?} */ | ||
const drawCrossOver = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @param {?} h | ||
* @return {?} | ||
*/ | ||
(x, y, w, h) => { | ||
ctx.beginPath(); | ||
ctx.lineWidth = 2; | ||
ctx.moveTo(x, y); | ||
ctx.lineTo(x + w, y + h); | ||
ctx.moveTo(x, y + h); | ||
ctx.lineTo(x + w, y); | ||
ctx.stroke(); | ||
}); | ||
/** @type {?} */ | ||
const fillText = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @param {?} textWidth | ||
* @return {?} | ||
*/ | ||
(x, y, legendItem, textWidth) => { | ||
/** @type {?} */ | ||
const halfFontSize = fontSize / 2; | ||
/** @type {?} */ | ||
const xLeft = boxWidth + halfFontSize + x; | ||
/** @type {?} */ | ||
const yMiddle = y + halfFontSize; | ||
if (helpers.isArray(legendItem.text)) { | ||
helpers.each(legendItem.text, (/** | ||
* @param {?} textLine | ||
* @param {?} index | ||
* @return {?} | ||
*/ | ||
(textLine, index) => { | ||
/** @type {?} */ | ||
const lineOffset = index * fontSize; | ||
ctx.fillText(textLine, xLeft, yMiddle + lineOffset); | ||
})); | ||
} | ||
else { | ||
ctx.fillText(legendItem.text, xLeft, yMiddle); | ||
} | ||
if (legendItem.hidden) { | ||
if (helpers.isArray(legendItem.text)) { | ||
drawCrossOver(xLeft, yMiddle, textWidth, (legendItem.text.length - 1) * (fontSize - 1)); | ||
} | ||
else { | ||
drawStrikeThrough(xLeft, yMiddle, textWidth); | ||
} | ||
} | ||
}); | ||
/** @type {?} */ | ||
const alignmentOffset = (/** | ||
* @param {?} dimension | ||
* @param {?} blockSize | ||
* @return {?} | ||
*/ | ||
(dimension, blockSize) => { | ||
switch (opts.align) { | ||
case 'start': | ||
return labelOpts.padding; | ||
case 'end': | ||
return dimension - blockSize; | ||
default: // center | ||
return (dimension - blockSize + labelOpts.padding) / 2; | ||
} | ||
}); | ||
// Horizontal | ||
/** @type {?} */ | ||
const isHorizontal = me.isHorizontal(); | ||
if (isHorizontal) { | ||
cursor = { | ||
x: me.left + alignmentOffset(legendWidth, lineWidths[0]), | ||
y: me.top + labelOpts.padding, | ||
line: 0 | ||
}; | ||
} | ||
else { | ||
cursor = { | ||
x: me.left + labelOpts.padding, | ||
y: me.top + alignmentOffset(legendHeight, columnHeights[0]), | ||
line: 0 | ||
}; | ||
} | ||
/** @type {?} */ | ||
const itemHeight = maxHeight; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
(legendItem, i) => { | ||
/** @type {?} */ | ||
let textWidth; | ||
/** @type {?} */ | ||
let boxTopOffset; | ||
if (helpers.isArray(legendItem.text)) { | ||
textWidth = legendItem.text.map((/** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/ | ||
textLine => { | ||
return ctx.measureText(textLine).width; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
(acc, v) => { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
boxTopOffset = fontSize / 2 * (legendItem.text.length - 1); | ||
} | ||
else { | ||
textWidth = ctx.measureText(legendItem.text).width; | ||
boxTopOffset = 0; | ||
} | ||
/** @type {?} */ | ||
const width = boxWidth + (fontSize / 2) + textWidth; | ||
/** @type {?} */ | ||
let x = cursor.x; | ||
/** @type {?} */ | ||
const topOffset = Math.trunc((maxHeight - hitboxes[i].height) / 2); | ||
/** @type {?} */ | ||
let y = cursor.y + topOffset; | ||
// Use (me.left + me.minSize.width) and (me.top + me.minSize.height) | ||
// instead of me.right and me.bottom because me.width and me.height | ||
// may have been changed since me.minSize was calculated | ||
if (isHorizontal) { | ||
if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.width) { | ||
y = cursor.y += itemHeight; | ||
cursor.line++; | ||
x = cursor.x = me.left + alignmentOffset(legendWidth, lineWidths[cursor.line]); | ||
} | ||
} | ||
else if (i > 0 && y + itemHeight > me.top + me.minSize.height) { | ||
x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding; | ||
cursor.line++; | ||
y = cursor.y = me.top + alignmentOffset(legendHeight, columnHeights[cursor.line]); | ||
} | ||
drawLegendBox(x, y + boxTopOffset, legendItem); | ||
hitboxes[i].left = x; | ||
hitboxes[i].top = y; | ||
// Fill the actual label | ||
fillText(x, y, legendItem, textWidth); | ||
if (isHorizontal) { | ||
cursor.x += width + labelOpts.padding; | ||
} | ||
else { | ||
cursor.y += itemHeight; | ||
} | ||
})); | ||
} | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsLegend() { | ||
/** @type {?} */ | ||
const plugins = Chart.plugins.getAll(); | ||
/** @type {?} */ | ||
const legend = plugins.filter((/** | ||
* @param {?} p | ||
* @return {?} | ||
*/ | ||
p => p.id === 'legend'))[0]; | ||
legend._element.prototype.fit = fit; | ||
legend._element.prototype.draw = draw; | ||
} | ||
@@ -904,5 +1387,114 @@ /** | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
const helpers$1 = Chart.helpers; | ||
/** | ||
* @param {?} vm | ||
* @param {?} align | ||
* @return {?} | ||
*/ | ||
function getAlignedX$1(vm, align) { | ||
return align === 'center' | ||
? vm.x + vm.width / 2 | ||
: align === 'right' | ||
? vm.x + vm.width - vm.xPadding | ||
: vm.x + vm.xPadding; | ||
} | ||
/** | ||
* @param {?} pt | ||
* @param {?} vm | ||
* @param {?} ctx | ||
* @return {?} | ||
*/ | ||
function drawBody(pt, vm, ctx) { | ||
/** @type {?} */ | ||
const bodyFontSize = vm.bodyFontSize; | ||
/** @type {?} */ | ||
const bodySpacing = vm.bodySpacing; | ||
/** @type {?} */ | ||
const bodyAlign = vm._bodyAlign; | ||
/** @type {?} */ | ||
const body = vm.body; | ||
/** @type {?} */ | ||
const drawColorBoxes = vm.displayColors; | ||
/** @type {?} */ | ||
const labelColors = vm.labelColors; | ||
/** @type {?} */ | ||
let xLinePadding = 0; | ||
/** @type {?} */ | ||
const colorX = drawColorBoxes ? getAlignedX$1(vm, 'left') : 0; | ||
/** @type {?} */ | ||
let textColor; | ||
ctx.textAlign = bodyAlign; | ||
ctx.textBaseline = 'top'; | ||
ctx.font = helpers$1.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily); | ||
pt.x = getAlignedX$1(vm, bodyAlign); | ||
// Before Body | ||
/** @type {?} */ | ||
const fillLineOfText = (/** | ||
* @param {?} line | ||
* @return {?} | ||
*/ | ||
line => { | ||
ctx.fillText(line, pt.x + xLinePadding, pt.y); | ||
pt.y += bodyFontSize + bodySpacing; | ||
}); | ||
// Before body lines | ||
ctx.fillStyle = vm.bodyFontColor; | ||
helpers$1.each(vm.beforeBody, fillLineOfText); | ||
xLinePadding = drawColorBoxes && bodyAlign !== 'right' | ||
? bodyAlign === 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize + 2) | ||
: 0; | ||
// Draw body lines now | ||
helpers$1.each(body, (/** | ||
* @param {?} bodyItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
(bodyItem, i) => { | ||
textColor = vm.labelTextColors[i]; | ||
ctx.fillStyle = textColor; | ||
helpers$1.each(bodyItem.before, fillLineOfText); | ||
// Draw Legend-like boxes if needed | ||
if (drawColorBoxes) { | ||
// Fill a white rect so that colours merge nicely if the opacity is < 1 | ||
ctx.fillStyle = vm.legendColorBackground; | ||
ctx.fillRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Border | ||
ctx.lineWidth = 1; | ||
ctx.strokeStyle = labelColors[i].borderColor; | ||
ctx.strokeRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Inner square | ||
ctx.fillStyle = labelColors[i].backgroundColor; | ||
ctx.fillRect(colorX + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2); | ||
ctx.fillStyle = textColor; | ||
} | ||
helpers$1.each(bodyItem.lines, fillLineOfText); | ||
helpers$1.each(bodyItem.after, fillLineOfText); | ||
})); | ||
// Reset back to 0 for after body | ||
xLinePadding = 0; | ||
// After body lines | ||
helpers$1.each(vm.afterBody, fillLineOfText); | ||
pt.y -= bodySpacing; // Remove last body spacing | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsTooltip() { | ||
Chart.Tooltip.prototype.drawBody = drawBody; | ||
} | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService }; | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip }; | ||
//# sourceMappingURL=ng2-charts.js.map |
import { __spread, __assign } from 'tslib'; | ||
import { Chart } from 'chart.js'; | ||
import { Injectable, NgModule, defineInjectable, EventEmitter, Directive, ElementRef, Input, Output } from '@angular/core'; | ||
import { Chart as Chart$1 } from 'chart.js'; | ||
import { Injectable, NgModule, EventEmitter, Directive, ElementRef, Input, Output, defineInjectable } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
@@ -282,3 +282,3 @@ import { cloneDeep } from 'lodash'; | ||
function (plugin) { | ||
Chart.plugins.register(plugin); | ||
Chart$1.plugins.register(plugin); | ||
}; | ||
@@ -294,3 +294,3 @@ /** | ||
function (plugin) { | ||
Chart.plugins.unregister(plugin); | ||
Chart$1.plugins.unregister(plugin); | ||
}; | ||
@@ -749,3 +749,3 @@ /** | ||
var chartConfig = this.getChartConfiguration(); | ||
return new Chart(ctx, chartConfig); | ||
return new Chart$1(ctx, chartConfig); | ||
}; | ||
@@ -1028,2 +1028,485 @@ /** | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
var helpers = Chart.helpers; | ||
/** @type {?} */ | ||
var defaults = Chart.defaults; | ||
/** @type {?} */ | ||
var valueOrDefault = helpers.valueOrDefault; | ||
/** | ||
* @param {?} labelOpts | ||
* @param {?} fontSize | ||
* @return {?} | ||
*/ | ||
function getBoxWidth(labelOpts, fontSize) { | ||
return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? | ||
fontSize : | ||
labelOpts.boxWidth; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function fit() { | ||
/** @type {?} */ | ||
var me = this; | ||
/** @type {?} */ | ||
var opts = me.options; | ||
/** @type {?} */ | ||
var labelOpts = opts.labels; | ||
/** @type {?} */ | ||
var display = opts.display; | ||
/** @type {?} */ | ||
var ctx = me.ctx; | ||
/** @type {?} */ | ||
var labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
var fontSize = labelFont.size; | ||
// Reset hit boxes | ||
/** @type {?} */ | ||
var hitboxes = me.legendHitBoxes = []; | ||
/** @type {?} */ | ||
var minSize = me.minSize; | ||
/** @type {?} */ | ||
var isHorizontal = me.isHorizontal(); | ||
if (isHorizontal) { | ||
minSize.width = me.maxWidth; // fill all the width | ||
minSize.height = display ? 10 : 0; | ||
} | ||
else { | ||
minSize.width = display ? 10 : 0; | ||
minSize.height = me.maxHeight; // fill all the height | ||
} | ||
/** @type {?} */ | ||
var getMaxLineWidth = (/** | ||
* @param {?} textLines | ||
* @return {?} | ||
*/ | ||
function (textLines) { | ||
return textLines.map((/** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/ | ||
function (textLine) { | ||
return ctx.measureText(textLine).width; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
}); | ||
// Increase sizes here | ||
if (display) { | ||
ctx.font = labelFont.string; | ||
if (isHorizontal) { | ||
// Labels | ||
// Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one | ||
/** @type {?} */ | ||
var lineWidths_1 = me.lineWidths = [0]; | ||
/** @type {?} */ | ||
var maxHeight_1 = 0; | ||
/** @type {?} */ | ||
var totalHeight_1 = 0; | ||
ctx.textAlign = 'left'; | ||
ctx.textBaseline = 'top'; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
function (legendItem, i) { | ||
/** @type {?} */ | ||
var width; | ||
/** @type {?} */ | ||
var height; | ||
/** @type {?} */ | ||
var grossHeight; | ||
if (helpers.isArray(legendItem.text)) { | ||
width = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
grossHeight = height; | ||
} | ||
else { | ||
width = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
grossHeight = height + labelOpts.padding; | ||
} | ||
width += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
if (grossHeight > maxHeight_1) { | ||
maxHeight_1 = grossHeight; | ||
} | ||
if (lineWidths_1[lineWidths_1.length - 1] + width + 2 * labelOpts.padding > minSize.width) { | ||
totalHeight_1 += maxHeight_1; | ||
maxHeight_1 = 0; | ||
lineWidths_1[lineWidths_1.length - (i > 0 ? 0 : 1)] = 0; | ||
} | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width: width, | ||
height: height, | ||
}; | ||
lineWidths_1[lineWidths_1.length - 1] += width + labelOpts.padding; | ||
})); | ||
minSize.height += totalHeight_1 + maxHeight_1; | ||
} | ||
else { | ||
/** @type {?} */ | ||
var vPadding_1 = labelOpts.padding; | ||
/** @type {?} */ | ||
var columnWidths_1 = me.columnWidths = []; | ||
/** @type {?} */ | ||
var columnHeights_1 = me.columnHeights = []; | ||
/** @type {?} */ | ||
var totalWidth_1 = labelOpts.padding; | ||
/** @type {?} */ | ||
var currentColWidth_1 = 0; | ||
/** @type {?} */ | ||
var currentColHeight_1 = 0; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
function (legendItem, i) { | ||
/** @type {?} */ | ||
var itemWidth; | ||
/** @type {?} */ | ||
var height; | ||
if (helpers.isArray(legendItem.text)) { | ||
itemWidth = getMaxLineWidth(legendItem.text); | ||
height = fontSize * legendItem.text.length; | ||
} | ||
else { | ||
itemWidth = ctx.measureText(legendItem.text).width; | ||
height = fontSize; | ||
} | ||
itemWidth += getBoxWidth(labelOpts, fontSize) + (fontSize / 2); | ||
// If too tall, go to new column | ||
if (i > 0 && currentColHeight_1 + fontSize + 2 * vPadding_1 > minSize.height) { | ||
totalWidth_1 += currentColWidth_1 + labelOpts.padding; | ||
columnWidths_1.push(currentColWidth_1); // previous column width | ||
columnHeights_1.push(currentColHeight_1); | ||
currentColWidth_1 = 0; | ||
currentColHeight_1 = 0; | ||
} | ||
// Get max width | ||
currentColWidth_1 = Math.max(currentColWidth_1, itemWidth); | ||
currentColHeight_1 += fontSize + vPadding_1; | ||
// Store the hitbox width and height here. Final position will be updated in `draw` | ||
hitboxes[i] = { | ||
left: 0, | ||
top: 0, | ||
width: itemWidth, | ||
height: height | ||
}; | ||
})); | ||
totalWidth_1 += currentColWidth_1; | ||
columnWidths_1.push(currentColWidth_1); | ||
columnHeights_1.push(currentColHeight_1); | ||
minSize.width += totalWidth_1; | ||
} | ||
} | ||
me.width = minSize.width; | ||
me.height = minSize.height; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function draw() { | ||
/** @type {?} */ | ||
var me = this; | ||
/** @type {?} */ | ||
var opts = me.options; | ||
/** @type {?} */ | ||
var labelOpts = opts.labels; | ||
/** @type {?} */ | ||
var globalDefaults = defaults.global; | ||
/** @type {?} */ | ||
var defaultColor = globalDefaults.defaultColor; | ||
/** @type {?} */ | ||
var lineDefault = globalDefaults.elements.line; | ||
/** @type {?} */ | ||
var legendHeight = me.height; | ||
/** @type {?} */ | ||
var columnHeights = me.columnHeights; | ||
/** @type {?} */ | ||
var legendWidth = me.width; | ||
/** @type {?} */ | ||
var lineWidths = me.lineWidths; | ||
if (opts.display) { | ||
/** @type {?} */ | ||
var ctx_1 = me.ctx; | ||
/** @type {?} */ | ||
var fontColor = valueOrDefault(labelOpts.fontColor, globalDefaults.defaultFontColor); | ||
/** @type {?} */ | ||
var labelFont = helpers.options._parseFont(labelOpts); | ||
/** @type {?} */ | ||
var fontSize_1 = labelFont.size; | ||
/** @type {?} */ | ||
var cursor_1; | ||
// Canvas setup | ||
ctx_1.textAlign = 'left'; | ||
ctx_1.textBaseline = 'middle'; | ||
ctx_1.lineWidth = 0.5; | ||
ctx_1.strokeStyle = fontColor; // for strikethrough effect | ||
ctx_1.fillStyle = fontColor; // render in correct colour | ||
ctx_1.font = labelFont.string; | ||
/** @type {?} */ | ||
var boxWidth_1 = getBoxWidth(labelOpts, fontSize_1); | ||
/** @type {?} */ | ||
var hitboxes_1 = me.legendHitBoxes; | ||
/** @type {?} */ | ||
var maxHeight_2 = hitboxes_1.map((/** | ||
* @param {?} x | ||
* @return {?} | ||
*/ | ||
function (x) { | ||
return x.height; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
// current position | ||
/** @type {?} */ | ||
var drawLegendBox_1 = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @return {?} | ||
*/ | ||
function (x, y, legendItem) { | ||
if (isNaN(boxWidth_1) || boxWidth_1 <= 0) { | ||
return; | ||
} | ||
// Set the ctx for the box | ||
ctx_1.save(); | ||
/** @type {?} */ | ||
var lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); | ||
ctx_1.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); | ||
ctx_1.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); | ||
ctx_1.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); | ||
ctx_1.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); | ||
ctx_1.lineWidth = lineWidth; | ||
ctx_1.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); | ||
if (ctx_1.setLineDash) { | ||
// IE 9 and 10 do not support line dash | ||
ctx_1.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); | ||
} | ||
if (opts.labels && opts.labels.usePointStyle) { | ||
// Recalculate x and y for drawPoint() because its expecting | ||
// x and y to be center of figure (instead of top left) | ||
/** @type {?} */ | ||
var radius = boxWidth_1 * Math.SQRT2 / 2; | ||
/** @type {?} */ | ||
var centerX = x + boxWidth_1 / 2; | ||
/** @type {?} */ | ||
var centerY = y + fontSize_1 / 2; | ||
// Draw pointStyle as legend symbol | ||
helpers.canvas.drawPoint(ctx_1, legendItem.pointStyle, radius, centerX, centerY); | ||
} | ||
else { | ||
// Draw box as legend symbol | ||
if (lineWidth !== 0) { | ||
ctx_1.strokeRect(x, y, boxWidth_1, fontSize_1); | ||
} | ||
ctx_1.fillRect(x, y, boxWidth_1, fontSize_1); | ||
} | ||
ctx_1.restore(); | ||
}); | ||
/** @type {?} */ | ||
var drawStrikeThrough_1 = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @return {?} | ||
*/ | ||
function (x, y, w) { | ||
ctx_1.beginPath(); | ||
ctx_1.lineWidth = 2; | ||
ctx_1.moveTo(x, y); | ||
ctx_1.lineTo(x + w, y); | ||
ctx_1.stroke(); | ||
}); | ||
/** @type {?} */ | ||
var drawCrossOver_1 = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} w | ||
* @param {?} h | ||
* @return {?} | ||
*/ | ||
function (x, y, w, h) { | ||
ctx_1.beginPath(); | ||
ctx_1.lineWidth = 2; | ||
ctx_1.moveTo(x, y); | ||
ctx_1.lineTo(x + w, y + h); | ||
ctx_1.moveTo(x, y + h); | ||
ctx_1.lineTo(x + w, y); | ||
ctx_1.stroke(); | ||
}); | ||
/** @type {?} */ | ||
var fillText_1 = (/** | ||
* @param {?} x | ||
* @param {?} y | ||
* @param {?} legendItem | ||
* @param {?} textWidth | ||
* @return {?} | ||
*/ | ||
function (x, y, legendItem, textWidth) { | ||
/** @type {?} */ | ||
var halfFontSize = fontSize_1 / 2; | ||
/** @type {?} */ | ||
var xLeft = boxWidth_1 + halfFontSize + x; | ||
/** @type {?} */ | ||
var yMiddle = y + halfFontSize; | ||
if (helpers.isArray(legendItem.text)) { | ||
helpers.each(legendItem.text, (/** | ||
* @param {?} textLine | ||
* @param {?} index | ||
* @return {?} | ||
*/ | ||
function (textLine, index) { | ||
/** @type {?} */ | ||
var lineOffset = index * fontSize_1; | ||
ctx_1.fillText(textLine, xLeft, yMiddle + lineOffset); | ||
})); | ||
} | ||
else { | ||
ctx_1.fillText(legendItem.text, xLeft, yMiddle); | ||
} | ||
if (legendItem.hidden) { | ||
if (helpers.isArray(legendItem.text)) { | ||
drawCrossOver_1(xLeft, yMiddle, textWidth, (legendItem.text.length - 1) * (fontSize_1 - 1)); | ||
} | ||
else { | ||
drawStrikeThrough_1(xLeft, yMiddle, textWidth); | ||
} | ||
} | ||
}); | ||
/** @type {?} */ | ||
var alignmentOffset_1 = (/** | ||
* @param {?} dimension | ||
* @param {?} blockSize | ||
* @return {?} | ||
*/ | ||
function (dimension, blockSize) { | ||
switch (opts.align) { | ||
case 'start': | ||
return labelOpts.padding; | ||
case 'end': | ||
return dimension - blockSize; | ||
default: // center | ||
return (dimension - blockSize + labelOpts.padding) / 2; | ||
} | ||
}); | ||
// Horizontal | ||
/** @type {?} */ | ||
var isHorizontal_1 = me.isHorizontal(); | ||
if (isHorizontal_1) { | ||
cursor_1 = { | ||
x: me.left + alignmentOffset_1(legendWidth, lineWidths[0]), | ||
y: me.top + labelOpts.padding, | ||
line: 0 | ||
}; | ||
} | ||
else { | ||
cursor_1 = { | ||
x: me.left + labelOpts.padding, | ||
y: me.top + alignmentOffset_1(legendHeight, columnHeights[0]), | ||
line: 0 | ||
}; | ||
} | ||
/** @type {?} */ | ||
var itemHeight_1 = maxHeight_2; | ||
helpers.each(me.legendItems, (/** | ||
* @param {?} legendItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
function (legendItem, i) { | ||
/** @type {?} */ | ||
var textWidth; | ||
/** @type {?} */ | ||
var boxTopOffset; | ||
if (helpers.isArray(legendItem.text)) { | ||
textWidth = legendItem.text.map((/** | ||
* @param {?} textLine | ||
* @return {?} | ||
*/ | ||
function (textLine) { | ||
return ctx_1.measureText(textLine).width; | ||
})).reduce((/** | ||
* @param {?} acc | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
function (acc, v) { | ||
return v > acc ? v : acc; | ||
}), 0); | ||
boxTopOffset = fontSize_1 / 2 * (legendItem.text.length - 1); | ||
} | ||
else { | ||
textWidth = ctx_1.measureText(legendItem.text).width; | ||
boxTopOffset = 0; | ||
} | ||
/** @type {?} */ | ||
var width = boxWidth_1 + (fontSize_1 / 2) + textWidth; | ||
/** @type {?} */ | ||
var x = cursor_1.x; | ||
/** @type {?} */ | ||
var topOffset = Math.trunc((maxHeight_2 - hitboxes_1[i].height) / 2); | ||
/** @type {?} */ | ||
var y = cursor_1.y + topOffset; | ||
// Use (me.left + me.minSize.width) and (me.top + me.minSize.height) | ||
// instead of me.right and me.bottom because me.width and me.height | ||
// may have been changed since me.minSize was calculated | ||
if (isHorizontal_1) { | ||
if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.width) { | ||
y = cursor_1.y += itemHeight_1; | ||
cursor_1.line++; | ||
x = cursor_1.x = me.left + alignmentOffset_1(legendWidth, lineWidths[cursor_1.line]); | ||
} | ||
} | ||
else if (i > 0 && y + itemHeight_1 > me.top + me.minSize.height) { | ||
x = cursor_1.x = x + me.columnWidths[cursor_1.line] + labelOpts.padding; | ||
cursor_1.line++; | ||
y = cursor_1.y = me.top + alignmentOffset_1(legendHeight, columnHeights[cursor_1.line]); | ||
} | ||
drawLegendBox_1(x, y + boxTopOffset, legendItem); | ||
hitboxes_1[i].left = x; | ||
hitboxes_1[i].top = y; | ||
// Fill the actual label | ||
fillText_1(x, y, legendItem, textWidth); | ||
if (isHorizontal_1) { | ||
cursor_1.x += width + labelOpts.padding; | ||
} | ||
else { | ||
cursor_1.y += itemHeight_1; | ||
} | ||
})); | ||
} | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsLegend() { | ||
/** @type {?} */ | ||
var plugins = Chart.plugins.getAll(); | ||
/** @type {?} */ | ||
var legend = plugins.filter((/** | ||
* @param {?} p | ||
* @return {?} | ||
*/ | ||
function (p) { return p.id === 'legend'; }))[0]; | ||
legend._element.prototype.fit = fit; | ||
legend._element.prototype.draw = draw; | ||
} | ||
@@ -1034,5 +1517,114 @@ /** | ||
*/ | ||
// tslint:disable:variable-name | ||
/** @type {?} */ | ||
var helpers$1 = Chart.helpers; | ||
/** | ||
* @param {?} vm | ||
* @param {?} align | ||
* @return {?} | ||
*/ | ||
function getAlignedX$1(vm, align) { | ||
return align === 'center' | ||
? vm.x + vm.width / 2 | ||
: align === 'right' | ||
? vm.x + vm.width - vm.xPadding | ||
: vm.x + vm.xPadding; | ||
} | ||
/** | ||
* @param {?} pt | ||
* @param {?} vm | ||
* @param {?} ctx | ||
* @return {?} | ||
*/ | ||
function drawBody(pt, vm, ctx) { | ||
/** @type {?} */ | ||
var bodyFontSize = vm.bodyFontSize; | ||
/** @type {?} */ | ||
var bodySpacing = vm.bodySpacing; | ||
/** @type {?} */ | ||
var bodyAlign = vm._bodyAlign; | ||
/** @type {?} */ | ||
var body = vm.body; | ||
/** @type {?} */ | ||
var drawColorBoxes = vm.displayColors; | ||
/** @type {?} */ | ||
var labelColors = vm.labelColors; | ||
/** @type {?} */ | ||
var xLinePadding = 0; | ||
/** @type {?} */ | ||
var colorX = drawColorBoxes ? getAlignedX$1(vm, 'left') : 0; | ||
/** @type {?} */ | ||
var textColor; | ||
ctx.textAlign = bodyAlign; | ||
ctx.textBaseline = 'top'; | ||
ctx.font = helpers$1.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily); | ||
pt.x = getAlignedX$1(vm, bodyAlign); | ||
// Before Body | ||
/** @type {?} */ | ||
var fillLineOfText = (/** | ||
* @param {?} line | ||
* @return {?} | ||
*/ | ||
function (line) { | ||
ctx.fillText(line, pt.x + xLinePadding, pt.y); | ||
pt.y += bodyFontSize + bodySpacing; | ||
}); | ||
// Before body lines | ||
ctx.fillStyle = vm.bodyFontColor; | ||
helpers$1.each(vm.beforeBody, fillLineOfText); | ||
xLinePadding = drawColorBoxes && bodyAlign !== 'right' | ||
? bodyAlign === 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize + 2) | ||
: 0; | ||
// Draw body lines now | ||
helpers$1.each(body, (/** | ||
* @param {?} bodyItem | ||
* @param {?} i | ||
* @return {?} | ||
*/ | ||
function (bodyItem, i) { | ||
textColor = vm.labelTextColors[i]; | ||
ctx.fillStyle = textColor; | ||
helpers$1.each(bodyItem.before, fillLineOfText); | ||
// Draw Legend-like boxes if needed | ||
if (drawColorBoxes) { | ||
// Fill a white rect so that colours merge nicely if the opacity is < 1 | ||
ctx.fillStyle = vm.legendColorBackground; | ||
ctx.fillRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Border | ||
ctx.lineWidth = 1; | ||
ctx.strokeStyle = labelColors[i].borderColor; | ||
ctx.strokeRect(colorX, pt.y, bodyFontSize, bodyFontSize); | ||
// Inner square | ||
ctx.fillStyle = labelColors[i].backgroundColor; | ||
ctx.fillRect(colorX + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2); | ||
ctx.fillStyle = textColor; | ||
} | ||
helpers$1.each(bodyItem.lines, fillLineOfText); | ||
helpers$1.each(bodyItem.after, fillLineOfText); | ||
})); | ||
// Reset back to 0 for after body | ||
xLinePadding = 0; | ||
// After body lines | ||
helpers$1.each(vm.afterBody, fillLineOfText); | ||
pt.y -= bodySpacing; // Remove last body spacing | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function monkeyPatchChartJsTooltip() { | ||
Chart.Tooltip.prototype.drawBody = drawBody; | ||
} | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService }; | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { ChartsModule, BaseChartDirective, defaultColors, ThemeService, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip }; | ||
//# sourceMappingURL=ng2-charts.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"ChartsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"BaseChartDirective"}],"imports":[],"exports":[{"__symbolic":"reference","name":"BaseChartDirective"}]}]}],"members":{}},"SingleDataSet":{"__symbolic":"interface"},"MultiDataSet":{"__symbolic":"interface"},"SingleOrMultiDataSet":{"__symbolic":"interface"},"PluginServiceGlobalRegistrationAndOptions":{"__symbolic":"interface"},"SingleLineLabel":{"__symbolic":"interface"},"MultiLineLabel":{"__symbolic":"interface"},"Label":{"__symbolic":"interface"},"BaseChartDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":47,"character":1},"arguments":[{"selector":"canvas[baseChart]","exportAs":"base-chart"}]}],"members":{"data":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":53,"character":3}}]}],"datasets":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":54,"character":3}}]}],"labels":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":55,"character":3}}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":56,"character":3}}]}],"chartType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":57,"character":3}}]}],"colors":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":58,"character":3}}]}],"legend":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":59,"character":3}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":60,"character":3}}]}],"chartClick":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":62,"character":3}}]}],"chartHover":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":63,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":95,"character":21},{"__symbolic":"reference","name":"ThemeService"}]}],"ngOnInit":[{"__symbolic":"method"}],"themeChanged":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"copyLabel":[{"__symbolic":"method"}],"labelsEqual":[{"__symbolic":"method"}],"copyColor":[{"__symbolic":"method"}],"colorsEqual":[{"__symbolic":"method"}],"updateColors":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"hideDataset":[{"__symbolic":"method"}],"isDatasetHidden":[{"__symbolic":"method"}],"toBase64Image":[{"__symbolic":"method"}],"getChartConfiguration":[{"__symbolic":"method"}],"getChartBuilder":[{"__symbolic":"method"}],"smartMerge":[{"__symbolic":"method"}],"isMultiLineLabel":[{"__symbolic":"method"}],"joinLabel":[{"__symbolic":"method"}],"propagateDatasetsToData":[{"__symbolic":"method"}],"propagateDataToDatasets":[{"__symbolic":"method"}],"isMultiDataSet":[{"__symbolic":"method"}],"getDatasets":[{"__symbolic":"method"}],"refresh":[{"__symbolic":"method"}]}},"Color":{"__symbolic":"interface"},"Colors":{"__symbolic":"interface"},"defaultColors":[[255,99,132],[54,162,235],[255,206,86],[231,233,237],[75,192,192],[151,187,205],[220,220,220],[247,70,74],[70,191,189],[253,180,92],[148,159,177],[77,83,96]],"ThemeService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":4,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"setColorschemesOptions":[{"__symbolic":"method"}],"getColorschemesOptions":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}}},"origins":{"ChartsModule":"./lib/charts.module","SingleDataSet":"./lib/base-chart.directive","MultiDataSet":"./lib/base-chart.directive","SingleOrMultiDataSet":"./lib/base-chart.directive","PluginServiceGlobalRegistrationAndOptions":"./lib/base-chart.directive","SingleLineLabel":"./lib/base-chart.directive","MultiLineLabel":"./lib/base-chart.directive","Label":"./lib/base-chart.directive","BaseChartDirective":"./lib/base-chart.directive","Color":"./lib/color","Colors":"./lib/colors","defaultColors":"./lib/default-colors","ThemeService":"./lib/theme.service"},"importAs":"ng2-charts"} | ||
{"__symbolic":"module","version":4,"metadata":{"ChartsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"BaseChartDirective"}],"imports":[],"exports":[{"__symbolic":"reference","name":"BaseChartDirective"}]}]}],"members":{}},"SingleDataSet":{"__symbolic":"interface"},"MultiDataSet":{"__symbolic":"interface"},"SingleOrMultiDataSet":{"__symbolic":"interface"},"PluginServiceGlobalRegistrationAndOptions":{"__symbolic":"interface"},"SingleLineLabel":{"__symbolic":"interface"},"MultiLineLabel":{"__symbolic":"interface"},"Label":{"__symbolic":"interface"},"BaseChartDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":47,"character":1},"arguments":[{"selector":"canvas[baseChart]","exportAs":"base-chart"}]}],"members":{"data":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":53,"character":3}}]}],"datasets":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":54,"character":3}}]}],"labels":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":55,"character":3}}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":56,"character":3}}]}],"chartType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":57,"character":3}}]}],"colors":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":58,"character":3}}]}],"legend":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":59,"character":3}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":60,"character":3}}]}],"chartClick":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":62,"character":3}}]}],"chartHover":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":63,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":95,"character":21},{"__symbolic":"reference","name":"ThemeService"}]}],"ngOnInit":[{"__symbolic":"method"}],"themeChanged":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"copyLabel":[{"__symbolic":"method"}],"labelsEqual":[{"__symbolic":"method"}],"copyColor":[{"__symbolic":"method"}],"colorsEqual":[{"__symbolic":"method"}],"updateColors":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"hideDataset":[{"__symbolic":"method"}],"isDatasetHidden":[{"__symbolic":"method"}],"toBase64Image":[{"__symbolic":"method"}],"getChartConfiguration":[{"__symbolic":"method"}],"getChartBuilder":[{"__symbolic":"method"}],"smartMerge":[{"__symbolic":"method"}],"isMultiLineLabel":[{"__symbolic":"method"}],"joinLabel":[{"__symbolic":"method"}],"propagateDatasetsToData":[{"__symbolic":"method"}],"propagateDataToDatasets":[{"__symbolic":"method"}],"isMultiDataSet":[{"__symbolic":"method"}],"getDatasets":[{"__symbolic":"method"}],"refresh":[{"__symbolic":"method"}]}},"Color":{"__symbolic":"interface"},"Colors":{"__symbolic":"interface"},"defaultColors":[[255,99,132],[54,162,235],[255,206,86],[231,233,237],[75,192,192],[151,187,205],[220,220,220],[247,70,74],[70,191,189],[253,180,92],[148,159,177],[77,83,96]],"ThemeService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":4,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"setColorschemesOptions":[{"__symbolic":"method"}],"getColorschemesOptions":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"monkeyPatchChartJsLegend":{"__symbolic":"function"},"monkeyPatchChartJsTooltip":{"__symbolic":"function"}},"origins":{"ChartsModule":"./lib/charts.module","SingleDataSet":"./lib/base-chart.directive","MultiDataSet":"./lib/base-chart.directive","SingleOrMultiDataSet":"./lib/base-chart.directive","PluginServiceGlobalRegistrationAndOptions":"./lib/base-chart.directive","SingleLineLabel":"./lib/base-chart.directive","MultiLineLabel":"./lib/base-chart.directive","Label":"./lib/base-chart.directive","BaseChartDirective":"./lib/base-chart.directive","Color":"./lib/color","Colors":"./lib/colors","defaultColors":"./lib/default-colors","ThemeService":"./lib/theme.service","monkeyPatchChartJsLegend":"./lib/monkey-patch-chart-js-legend","monkeyPatchChartJsTooltip":"./lib/monkey-patch-chart-js-tooltip"},"importAs":"ng2-charts"} |
{ | ||
"name": "ng2-charts", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular/common": "^7.2.0", |
@@ -7,1 +7,3 @@ export * from './lib/charts.module'; | ||
export * from './lib/theme.service'; | ||
export * from './lib/monkey-patch-chart-js-legend'; | ||
export * from './lib/monkey-patch-chart-js-tooltip'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
788453
44
8335