I am plotting a time graph with echarts. I have only two data points I want to show in the graph. The graph shows those two points correctly, but it shows more than 2 labels on x axis (time axis), which is obviously the uniform time difference between those 2 data points. What I want is to see the time labels only for the data points I have. How can I do that?
I tried passing the time values in xAxis.data
also, but it is not working.
I have created a demo graph for reference here.
Current Result:
Current Result Chart
Expected Result: Time label should be displayed under the bars only.
2
Answers
One option can be to use
splitNumber
which defaults to5
we can set it to4
and it generates the desired output!xAxis. splitNumber = 5 (default)
number
demo
This approach ensures that time labels are displayed only for the data points you have in your ECharts graph. Adjust the condition inside the formatter function if you have multiple series or need to handle additional scenarios.