Highcharts DataLabel格式化程序仅显示非零不工作的值

时间:2013-11-22 16:30:33

标签: highcharts formatter

我目前有这个,

data.dataLabels = { formatter : function(){ if( this.point.y != 0 ){ return this.point.y; } } };
chart = new Highcharts.Chart(data);

这是在question中建议的,我尝试使用上面提到的但是它不起作用,它仍然显示值为0.任何帮助?提前谢谢。

修改

我的实际代码如下所示,

            jQuery.ajax({
            url:"charts/bar_chart.php",
            dataType: "json",
            cache: false,
            data:{"tid":"<?php print $q4tid ?>"}
        }).done(
            function(data) {
                data.chart["renderTo"] = "q4chart";
                <?php if($q4title!="") { ?> 
                        data.title["text"] = "<?php print $q4title ?>";
                <?php } ?>

                //calculate approximate heigt of chart. this is needed because
                //highchart calcluate chart height based on offset height.
                var ah = data.xAxis.categories.length * (data.series.length*15);
                jQuery("#q4chart").css("height", ah+"px");

                data.dataLabels = { formatter : function(){ if( this.point.y != 0 ){ return this.point.y; } } };
                chart = new Highcharts.Chart(data);

                //resize parent frame
                resizeFrame();
            }
        ).fail(
            function(jqXHR, textStatus, errorThrown) {
                jQuery("#q4chart").html("Error loading Q4 chart, please contact administrator.<br />" + errorThrown);
                //alert("Error loading Q4 Bar chart:" + errorThrown);
            }
        );

0 个答案:

没有答案