Plotly.js: Cannot show full categorical x-axis

前端 未结 1 623
忘掉有多难
忘掉有多难 2021-01-28 15:51

I have to plot a line chart with x-axis about time. The x-axis is like [\"00:00\", \"00:05\", \"00:10:, ... , \"23:55\"], making it not numeric but categorical. However, I may n

1条回答
  •  礼貌的吻别
    2021-01-28 16:23

    I had a similar problem, using plotly.js version plotly.js v1.28.3. I was able to display a full set of x and y axis values by using the categoryorder attribute and categoryarray attributes the following is an example that worked for me:

    var layout = {
             xaxis: {
                 title: 'x Axis Label'
                 , autorange: false
                 , type: 'category'
                 , categoryorder: 'array'
                 , categoryarray: ['0001','0002','0003']
             },
             yaxis: {
                 title: 'Y Axis Label  %>'
                 , autorange: false
                 , type: 'category'
                 , categoryorder: 'array'
                 , categoryarray: ['one','two','three', 'etc']
             },
        };
    

    0 讨论(0)
提交回复
热议问题