Home Forums Chart Support Cannot set a string array to x-axis in a responsive chart

Cannot set a string array to x-axis in a responsive chart

Viewing 7 posts - 1 through 7 (of 7 total)
  • #24050

    While my responsive chart worked well when I set digit arrays to both X and Y axis. it didn’t show any line when I changed the x axis value to a string array. I’m wondering if it’s possible to set string to the x axis because I want to get a responsive chart with x-axis showing the time and y-axis showing the corresponding data.

    #24055

    @kris,

    You can achieve the above requirement by passing dataPoint x-value as Date Object and the corresponding y-value as numeric. Please take a look at this documentation page to render a chart with Date & Time axis.

    ___________
    Indranil Deo,
    Team CanvasJS

    #24065

    Hi Indranil,

    Thanks for your timely reply. It works but with a format problem. I gave values in x as dateTime stamps and tried those values in the page you gave me last time where it showed correct time. But when it comes to the responsive chart, x axis values are a little strange which showed numbers like 200ms, 600ms, only the last one showing the correct time. I’m not quite sure how to solve this problem and wondering if you could give me some advice on it.

    Thanks in advance.

    #24066

    @kris,

    Can you please create and share a JSFiddle reproducing the issue, so that we can look into your code, understand it better and help you out.

    ___________
    Indranil Deo,
    Team CanvasJS

    #24069

    Hi Indranil,

    Thanks again for your kind help. I created my JSFiddle and the URL is https://jsfiddle.net/v072b9hz/ .

    By the way, I know I shouldn’t set a static array as the data to a responsive chart, but later I’ll change data source to a variable including only one datetime and its corresponding temperature which I’ll get from the server every second. Before that, I just want to make sure everything should work.

    #24077

    @kris,

    Since the difference in the consecutive timestamp is in terms of milliseconds, the corresponding labels displayed on the Axis X are in milliseconds. Setting the valueFormatString of the Axis X to “MMM DD YYYY hh:mm:ss” will work fine in your case.

    Please take a look at this updated jsfiddle.

    ___________
    Indranil Deo,
    Team CanvasJS

    #24079

    Hi Indranil,

    Thanks so much for your help. It works well now.

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

You must be logged in to reply to this topic.