Home Forums Chart Support label showing up as null on labelFormatter

label showing up as null on labelFormatter

Viewing 4 posts - 1 through 4 (of 4 total)
  • #33966

    I want to use a custom label supplied on my data, but I cannot seem to access this data, it comes up as null on the labelFormatter. I have attached a JSFiddle that demonstrates this problem. Thanks for your help!

    #33983

    @van-rebosura,

    Displaying labels at a specific position(say every midnight) on the axes depends upon the very first label that is rendered, subsequent labels are just rendered at a defined interval(auto-calculated/user-defined) from there. As of now, we do not have control over the starting label on the axes. However in your case, you can show axis labels by passing the year as numeric value instead of datetime as shown in this code snippet.

    dataPoints: [
      { x: 2020, y: 71, label: "label 1" },
      { x: 2021, y: 55, label: "label 2" },
      { x: 2022, y: 50, label: "label 3" },
      { x: 2023, y: 65, label: "label 4" },
      { x: 2024, y: 95, label: "label 5" },
      { x: 2025, y: 68, label: "label 6" },
      { x: 2026, y: 28, label: "label 7" },
      { x: 2027, y: 34, label: "label 8" },
      { x: 2028, y: 14, label: "label 9" }
    ]

    Also, take a look at this JSFiddle for an updated example.

    Display labels over Axis X

    —-
    Manoj Mohan
    Team CanvasJS

    #33989

    Hi @manoj-mohan,

    Thank you for your response, my given fiddle was actually a simplified version of what I want to achieve. I actually need to use full fledged dates (ie new Date("2021-01-01 08:00:00")`). Is this use case of having date objects on the x axis with a custom label planned to be implemented to canvasJS?

    Thanks!

    • This reply was modified 3 weeks, 6 days ago by van-rebosura.
    #34029

    @van-rebosura,

    The labels on axis-x are displayed at a specific interval and not for each dataPoint. However, if you like to show labels for each dataPoint, you can use label property instead of x-value.

    Custom label on axisX

    ___________
    Indranil Deo
    Team CanvasJS

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

You must be logged in to reply to this topic.