Home Forums Chart Support distance between days on the x-axis

distance between days on the x-axis

Viewing 2 posts - 1 through 2 (of 2 total)
  • #61006

    In my project, I am using line charts, but I am encountering the following issue: for a certain period, I collected 96 data points per day, whereas now I only collect 24. The problem is that the distance between days on the x-axis is not constant, which results in a “distorted” chart.
    Is it possible to ensure that the spacing between days on the x-axis remains consistent, regardless of the number of data points?

    #61009

    @elidria-srl-sb,

    The issue you’re facing happens as CanvasJS places each datapoint based on its exact timestamp. When the number of datapoints per day varies—like 96 points on some days and 24 on others—the chart ends up spacing them unevenly since it’s reflecting the actual time intervals between points.

    To get around this and ensure even spacing between datapoints, you have a couple of options. One is to aggregate your data so that each day contributes the same number of points, such as daily averages or fixed hourly intervals. This way, the timestamps will be evenly spaced, and the chart will render more uniformly.

    Another approach is to use the label property instead of actual x values. This turns the x-axis into a category axis, which places each point at equal intervals regardless of its timestamp. It’s especially useful if you don’t need precise time scaling and just want the chart to look balanced visually.


    Ananya Deka
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.