2

我将以下内容传递给我的图表:

if ($mode == 'margin') {
        $datasets = [[
            'label' => 'Invoiced margin',
            'backgroundColor' => "rgba(122, 208, 94, 0.3)",
            'borderColor' => "rgba(122, 208, 94, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ], [
            'label' => 'Invoiced target',
            'backgroundColor' => "rgba(160, 160, 160, 0.3)",
            'borderColor' => "rgba(160, 160, 160, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ]];
    } else if ($mode == 'activity') {
        $datasets = [[
            'label' => '# of companies targeted',
            'backgroundColor' => "rgba(255, 176, 92, 0.3)",
            'borderColor' => "rgba(255, 176, 92, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => true
        ], [
            'label' => 'Targeted target',
            'backgroundColor' => "rgba(251, 255, 143, 0.3)",
            'borderColor' => "rgba(251, 255, 143, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => true
        ], [
            'label' => 'Stages aquired',
            'backgroundColor' => "rgba(77, 255, 184, 0.3)",
            'borderColor' => "rgba(77, 255, 184, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ], [
            'label' => 'Stage target',
            'backgroundColor' => "rgba(176, 255, 143, 0.3)",
            'borderColor' => "rgba(176, 255, 143, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ], [
            'label' => 'Intros sent',
            'backgroundColor' => "rgba(175, 26, 255, 0.3)",
            'borderColor' => "rgba(175, 26, 255, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => true
        ], [
            'label' => 'Intro target',
            'backgroundColor' => "rgba(214, 138, 255, 0.3)",
            'borderColor' => "rgba(214, 138, 255, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => true
        ]];
    } else if ($mode == 'calls') {
        $datasets = [[
            'label' => 'Outbound call time actual',
            'backgroundColor' => "rgba(255, 176, 92, 0.3)",
            'borderColor' => "rgba(255, 176, 92, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ], [
            'label' => 'Outbound call time target',
            'backgroundColor' => "rgba(251, 255, 143, 0.3)",
            'borderColor' => "rgba(251, 255, 143, 1)",
            'lineTension' => 0.2,
            'data' => [],
            'hidden' => false
        ]];
    }

如果我在“保证金”和“呼叫”模式之间切换,图表顶部的图例标签会正确更改。但是,如果我选择“活动”,我会按预期获得标签,但是当我改回“保证金”或“调用”时,来自“活动”的标签仍保留在顶部,前两个被替换。

这是 ChartJS 的错误吗?我已经尝试以多种不同的方式创建图表,但我仍然遇到这个问题。

关于可能导致这种情况的任何想法?

4

0 回答 0