javascript jqPlot 和命名系列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10895957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:24:31  来源:igfitidea点击:

jqPlot and naming series

javascriptjqueryjqplot

提问by Pelle

I'm trying out jqPlot, but I can't figure out how to set the name of the different series.

我正在尝试 jqPlot,但我不知道如何设置不同系列的名称。

Currently, my code looks like this:

目前,我的代码如下所示:

$(document).ready(function () {
    $.jqplot('chartdiv', [
        [[201201, 10], [201202, 20], [201203, 30], [201204, 60], [201205, 40]], 
        [[201201, 5], [201202, 10], [201203, 7], [201204, 8], [201205, 11]]
    ], {
        axes: {
            xaxis: {
                label: "Year/month",
                pad: 0
            },
            yaxis: {
                label: "Amount (Kr)"
            }
        },
        legend: {
            show: true
        }
    });
});

It renders the diagram, but the series are named series 1 and series 2. Is there any way that I can control the naming of the series?

它呈现图表,但系列被命名为系列 1 和系列 2。有什么方法可以控制系列的命名?

回答by Boro

To have names for series you must set 'label' which is under 'series'. Please see here for documentation.

要为系列命名,您必须设置“系列”下的“标签”。请参阅此处获取文档。

Example code presenting its use is available here.

此处提供了展示其使用的示例代码。