jQuery UI Widgets Forums Chart Chart xAxis Offset with Date type

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 8 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Chart xAxis Offset with Date type #83935

    Stephen
    Participant

    I’m trying to make my x-axis display correctly by choosing exactly where the labels should be. For example, if I’m showing data that starts one week ago (defined as now minus 7 days) and ends now, I want the xaxis intervals to be on midnight of each day.

    It seems the easy way to do this is to set the baseunit to day and the interval to 1, but that doesn’t work as it places the first tick on the left edge and increments from there. This leads to the labels appearing at an arbitrary point in the day depending on when the chart is loaded. Another solution is to change the baseunit to hour and use formatFunction to return an empty string if we’re not on midnight, but this solution still results in labels being visibly off, results in extra tickmarks, and for some timescales can result in thousands of labels with empty strings which is horrible for performance.

    Is there a feature to offset the labels for the xAxis so that they fall on predictable marks?

    Thank you.

    Chart xAxis Offset with Date type #83965

    Hristo
    Participant

    Hello Stephen,

    You could use different approach. If you use ‘hours’ for baseUnit you could try to set suitable unitInterval.
    Also in another case could try to use labels: { offset: { x: 0, y: 0 } } to set the exact position.
    Please, take a look this demo could be helpful too:
    http://jqwidgets.com/jquery-widgets-demo/demos/jqxchart/javascript_chart_custom_offsets.htm

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Chart xAxis Offset with Date type #83969

    Hristo
    Participant

    Hello Stephen,

    Update:
    Easier way to achieve this is to get first record from the data source. Manipulate it to be in hour ‘0:0:0’.
    Next step is to set minValue of the xAxis with this record.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.