this._chartjs = new Chartjs(this._canvas[0], this._config);
};
+ /**
+ * Clean data.
+ *
+ * @param {(String|String[])} data A single string or an array of strings.
+ * @returns {(String|String[])}
+ * @protected
+ */
+ Output.prototype._cleanData = function(data) {
+ if (data instanceof Array) {
+ return data.map(function(value) {
+ return $('<span>').html(value).text();
+ });
+ } else {
+ return $('<span>').html(data).text();
+ }
+ };
+
/**
* Get the chart type and handles the Chart.js specific chart types.
*
if (axis.getLabel() !== null) {
scaleData.scaleLabel = {
display: true,
- labelString: axis.getLabel()
+ labelString: this._cleanData(axis.getLabel())
};
}
var config = {
type: this._getChartType(),
data: {
- labels: this._chart.getLabels(),
+ labels: this._cleanData(this._chart.getLabels()),
datasets: this._makeDatasetsConfig()
},
options: {
title: {
display: this._chart.getTitle() !== null,
- text: this._chart.getTitle()
+ text: this._cleanData(this._chart.getTitle())
}
}
};
var sets = this._chart.getSeries().map(function(series) {
var colors = series.hasColoredValues() ? series.getColors() : series.getColor();
var dataset = {
- label: series.getLabel(),
+ label: this._cleanData(series.getLabel()),
data: series.getValues(),
type: series.getType(),
fill: false,
var tooltipData = chartData[tooltipItem.index];
// Build default tooltip.
- var tooltip = serieLabel + ': ' + tooltipData;
+ var tooltip = this._cleanData(serieLabel) + ': ' + tooltipData;
- // Add serie labels to the tooltip if any.
+ // Add series labels to the tooltip if any.
if (serieLabels !== null) {
- tooltip = serieLabels[tooltipItem.index];
+ tooltip = this._cleanData(serieLabels[tooltipItem.index]);
}
return tooltip;