0

I have a chartjs graph with an x-axis consisting of the hours of the past three days. Because it is 3 days, each hour appears in the x-axis 3 times. I want to draw vertical lines at each 12:00am, but I am not sure how to differentiate the first 12:00am with the second and third.

annotation: {                  
      annotations: [{
            type: 'line',
            id: 'vLine',
            mode: 'vertical',
            display: true,
            scaleID: 'x-axis-0',
            value: '12:00am',
            borderWidth: 1,
            borderColor: 'gray',
            label: {
                    enabled: true,
                    position: "center",
                    content: 'day bar'
            }
    }]

}

Here is what the graph currently looks like

Would each time need a unique label, or is it possible to differentiate between the 3 identical x-axis times without changing their x-axis labels?

4

1 回答 1

0

我找到了一个快速解决方案,但仍然想知道是否有更好的解决方案。

我只是在“12:00am”的第二次出现时添加了一个空格,然后在第三次出现时添加了两个空格。这样,它们在用户看来都是一样的,但 chartjs 可以区分它们。

于 2021-01-19T14:55:13.857 回答