Home Forums Chart Support Date Labels on X-axis not matching Chart data

Date Labels on X-axis not matching Chart data

Viewing 5 posts - 1 through 5 (of 5 total)
  • #41375

    I am currently rendering a stackedArea chart that has a date range (startDate and endDate) that renders across the X axis. I set the intervalType to “week”, and am able to successfully render the correct data on the chart itself. However my concern is that MY data points land on Saturday’s (the last day of the week in America), but canvasjs label by default shows the Sunday of that week (the last day of the week for most countries). I need the label to land on a Saturday and match the chart data. Is there a way to change this using your platform?

    My thought is that these dates are fundamentally in ISO, which is always Monday-Sunday. So, I’d like to convert this potentially using the labelFormater property like so

    labelFormatter: function ( e ) {
    return e.value – 1day
    }

    Here is a jsfiddle of my issue. http://jsfiddle.net/2r9ufknt/16/ Notice how the axisX labels do not match the data points on the chart.

    #41598

    @justin-greerservicemob-com,

    Sorry, it’s not possible to define the position of first & last labels in the axis as of now. However, you can use label instead of x values to show the axis labels as per your requirement.

    —-
    Manoj Mohan
    Team CanvasJS

    #41603

    Hi Manoj, is there any other workaround you can think of? I am unable to render the label for data points that have multiple key value pairs.

    Ex.: `”dataPoints”: [
    { x: new Date(“2022-07-02T07:00:00.000Z”), y: 80, label: “cat0” },
    { x: new Date(“2022-07-09T07:00:00.000Z”), y: 44, label: “cat1” },
    { x: new Date(“2022-07-16T07:00:00.000Z”), y: 77, label: “cat3” } ,
    { x: new Date(“2022-07-23T07:00:00.000Z”), y: 56, label: “cat4” },
    ]`

    Is there a better workaround using the label functionality? Or can you please send me a fiddle of this working as I should expect it too?

    Thank you for your time and assistance!
    Justin

    #41691

    Justin,

    Please take a look at this JSFiddle that shows an example of using labels to show date instead of x-values.

    —-
    Manoj Mohan
    Team CanvasJS

    #41746

    Manoj,

    Thank you so much, this was a huge fix for me!

    All the best,
    Justin

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

You must be logged in to reply to this topic.