c3js › Timeseries x values not evenly spaced

前端 未结 4 1053
自闭症患者
自闭症患者 2021-01-17 14:54

I am having an issue with the labels assigned to the values of my graph.

The graph is a timeseries. I add values using the \'columns\' property of c3js.

I

4条回答
  •  无人共我
    2021-01-17 15:39

    c3js allows you to specify what ticks will appear on x axis.

    Under axis/x/tick I added this -

    values: [1413936000, 1414195200,1414454400,1414713600,1414972800,1415232000],
    

    I converted your dates in three day intervals with the epoch converter.

    Here's the reference for solution.

    I can only assume if the gridlines don't match these three day ticks then they were pushing into a new day every nth tick - hence your issue. Alternatively, you can place gridlines manually.

    Here's the code for x axis.

            x: {
                label: {
                    text: 'Time [days]'
                },
                type: 'timeseries',
                tick: {
                    values: [1413936000, 1414195200,1414454400,1414713600,1414972800,1415232000],
                    fit: false,
                    //count: 29,
                    rotate: -75,
                    multiline: false,
                    format: function (e, d) {
                        return dateToString(e);
                    }
                },
                height: 100
            },
    

提交回复
热议问题