我在服务器端使用High曲线图-转换am来创建PDF图表。我想为列图(http://api.highcharts.com/highcharts#plotOptions.column.dataLabels)设置http://api.highcharts.com/highcharts#plotOptions.column.dataLabels格式化程序。因为这是一个函数,所以我不能在输出json文件中写入它,而json文件是High曲线图的输入-转换器is。因此,我想我需要把它放在我的callback.js中,并称之为:
高图表-转换. -infile infile.js -outfile outfile.pdf -width 1000 -callback callback.js
但是我不能在callback.js中设置格式化程序函数。我试过这个:
function( chart ) {
var labelFormatter = function(p) {
if (this.y == 0) {
return '';
}
else {
return this.y
}
};
chart.series.dataLabels.formatter = labelFormatter;
}但这给了我一个错误:
TypeError: 'undefined' is not an object (evaluating 'chart.series.dataLabels.formatter = labelFormatter')我试着将格式化程序函数放在回调定义之外,但是High曲线图-转换‘t不会接受这一点。我如何设置一个dataLabel格式化程序回调的高级图表-转换. do?
发布于 2014-04-22 09:59:16
嗯,高级图表导出服务器的输入文件不一定是真正的JSON。通常,支持JSON中的函数。就以它为例:
{"series": [{"data": [29.9, 71.5, 106.4], "dataLabels": { "enabled": true, "formatter":function(p) {if (this.y == 0) {return '';} else {return this.y+'a';}}}}]}发布于 2016-06-21 05:26:15
如果在服务器端使用回调函数,请使用以下命令。
function (chart) {
options = chart.options;
var labelFormatter = function() {
if (this.y == 0) return '';
else return this.y;
}
options.yAxis[0].labels = new Object();
options.yAxis[0].labels.formatter = labelFormatter;
chart = new Highcharts.Chart(options);
chart.redraw();}
https://stackoverflow.com/questions/23203303
复制相似问题