第二个系列没有在Highcharts中显示

时间:2017-03-16 10:41:18

标签: javascript python django highcharts

我正在尝试创建一个图表来显示系统的性能。我的问题是,由于某种原因,Higcharts不会认识到我有不止一个系列。第一个系列完美展现,但第二个系列无处可见。 我正在使用Django 1.8来循环字典中的数据。

我的系列代码:

series: [
    {% for ID, run in attDict.items|sort %}
    {
        yAxis: 0,
        id: "Run" + {{forloop.counter}},
        name: "RunID " + {{ID}},
        color: getLineColor({{ID}}),
        data: {{run}},
        marker: {
            fillColor: getFillColor({{forloop.counter}}),
        },
        visible: false
        },
    {% endfor %}

    {% for key, task in TaskE.items|sort %}
    {
        yAxis: 1,
        id: "during",
        linkedTo: "Run" + {{forloop.counter}},
        name: "Duringtask for run " + {{key}}
        type: 'area',
        color: '#12e000',
        fillOpacity: 0.3,
        data: {{task}},
        visible: fasle
        }{% if forloop.last %}{% else %},{% endif %}
    {% endfor %}
    ]

输出如下:

series: [
    {
        yAxis: 0,
        id: "Run" + 1,
        name: "RunID " + 250,
        color: getLineColor(250),
        data: [0, 0, 0, 0, 0, 0, 6, 33, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        marker: {
            fillColor: getFillColor(1),
        },
        visible: false
    },

    {
        yAxis: 0,
        id: "Run" + 2,
        name: "RunID " + 256,
        color: getLineColor(256),
        data: [0, 0, 0, 1, 0, 0, 0, 0],
        marker: {
            fillColor: getFillColor(2),
        },
        visible: false
    },

    {
        yAxis: 0,
        id: "Run" + 3,
        name: "RunID " + 257,
        color: getLineColor(257),
        data: [0, 0, 0, 1, 0, 0, 0, 0],
        marker: {
            fillColor: getFillColor(3),
        },
        visible: false
    },

    {
        yAxis: 0,
        id: "Run" + 4,
        name: "RunID " + 265,
        color: getLineColor(265),
        data: [83, 0, 101, 0, 0, 96, 0],
        marker: {
            fillColor: getFillColor(4),
        },
        visible: false
    },

    {
        yAxis: 0,
        id: "Run" + 5,
        name: "RunID " + 295,
        color: getLineColor(295),
        data: [14, 3, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 37, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 3, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        marker: {
            fillColor: getFillColor(5),
        },
        visible: false
    },

    {
        yAxis: 0,
        id: "Run" + 6,
        name: "RunID " + 296,
        color: getLineColor(296),
        data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 0, 28, 15],
        marker: {
            fillColor: getFillColor(6),
        },
        visible: false
    },
]

1 个答案:

答案 0 :(得分:0)

您明确告诉图表不要使用以下内容在图例中显示系列:

linkedTo: "Run" + {{forloop.counter}}
  

当链接两个系列时,只有第一个系列出现在图例中。   切换其可见性也会切换链接系列。

参考:

从第二个循环中删除linkedTo属性,它应该可以正常工作。