在Highcharts.js中将数据标签添加到面积图 [英] Add dataLabel to Area chart in Highcharts.js

查看:460
本文介绍了在Highcharts.js中将数据标签添加到面积图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在区域图表中向特定点添加数据标签。我使用'Highchart'制作图表。我想在图表设计中的数据标签如下图所示。我应该尝试什么?我试图在'线'图中定义的dataLabel,但它应用dataLabel到图表中的每个点。我想要它应用于特定点。此外,它不应该显示该点的值作为dataLabel,但它应该在该点上显示series.name。

I want to add a data label to specific point in the 'Area' chart. I'm using 'Highchart' for making graph. I want a data label in chart design as following image. What should I try ? I tried dataLabel defined in 'line' chart but it applies dataLabel to each point in the chart. I want it to be applied for specific point. Also, it should not show value of that point as a dataLabel but it should show series.name on that point.

推荐答案

对于数据中的相关点,使用对象符号和启用的数据标签。您可以使用 格式 格式化程序 显示所需的信息。

For the relevant point in your data use the object notation and enabled data labels. You can use format and formatter to display the desired information.

您的系列示例如下:

series: [{
    name: 'My series name',
    data: [5, 10, 30, 100, 200, 300, 600,
        { 
            y: 900, 
            dataLabels: {
               enabled: true,
               format: '{series.name}'
            }
        },
        700, 400, 100]
}]

或参阅这个更详细的JSFiddle示例

这篇关于在Highcharts.js中将数据标签添加到面积图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆