javascript - Highcharts 设置系列文本颜色

标签 javascript json highcharts

这听起来像是一个非常简单的问题,但我花了几个小时试图完成这个任务,这让我感到非常沮丧。

请问有人可以告诉我如何设置系列中名称的颜色吗? 我能够完全配置图表的所有其他方面,但系列名称仍为黑色。

我在这里保存了一个 Highchart 示例 http://jsfiddle.net/ktnexbcr/如何将系列中的文本“气象数据”设置为蓝色或红色或黑色以外的任何内容。

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        name: 'Meteorological data',
        color: "red",
        font-color: "blue" ??? <-- how
}]

这根本不可能吗?

谢谢,

最佳答案

Legend 是您所追求的,您需要查看文档 http://www.highcharts.com/docs/chart-design-and-style/themes

$(function () {
    $('#container').highcharts({
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],

        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            name: 'Meteorological data',
            color: "red",

        }],

        legend: {
        itemStyle: {
            color: 'blue'
        }  
    }
    });
});

fiddle here

关于javascript - Highcharts 设置系列文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30195936/

相关文章:

javascript - 在 javascript 中,我使用 EventListener 并得到 TypeError xyz = null

javascript 将参数作为对象或类似的东西传递

javascript - 将日期从一种给定格式转换为另一种给定格式

jquery ajax调用返回200,有效的json,触发错误事件

javascript - 如何使用 API 和选定值检索 json 数据

javascript - 在页面加载时启动模式

json - Postgresql更新json数据属性

highcharts - 在 HighChart Solid Gauge 中隐藏 YAxis 值

highcharts - 高库存线宽

javascript - 如何在 Highcharts 中将不同类别的值放在 X 轴上