ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Date/time format
Posted by Ian Hammond on Aug-22-2024 17:21
Hi Peter,
I have a question regarding changinging the format of the date displayed along the x-axis.
The default appears to be the American format and I wish to change it to day/month/year.

I have used the following statement

c->xAxis()->setLabels(DoubleArray(m_pdXTimeScale, m_XTlen),
"{value | dd/mm/yyyy hh:nn:ss}");

When the graph was displayed the labels on the X axis remained unchanged.

Could you please advise where I might be going wrong.

Many thanks.

  Re: Date/time format
Posted by Peter Kwan on Aug-23-2024 02:29
Hi Ian Hammond,

For testing, please try:

double testTime[] = {1000, 2000, 3000, 4000};

c->xAxis()->setLabels(DoubleArray(testTime, 4), "{value|dd/mm/yyyy hh:nn:ss}");

It should display some labels that looks like dd/mm/yyyy hh:nn:ss. In any case, the chart should not "remain unchanged".

If the above code displays the numeric values 1000, 2000, 3000, 4000 but not in the date/time format, it is possible there are some other lines in the code that sets the label format. Please search for all the code that uses c->xAxis() to see if there is any other code that can affect the format. Some APIs such as Axis::setLabelFormat, Axis::setLabels, Axis::setDateScale, QChartViewer::syncDateAxisWithViewPort can change the axis labels.


In the simplest case, you can try the followings to verify if it works:


XYChart* c2 = new XYChart(800, 300);
c2->setPlotArea(60, 20, 720, 200);

double testTime[] = { 1000, 2000, 3000, 4000 };
c2->xAxis()->setLabels(DoubleArray(testTime, 4), "{value|dd/mm/yyyy hh:nn:ss}");

// Save to a file
c2->makeChart("c:/aaa/bbb/ccc.png");


If the above still cannot solve the problem, can you provide me with the complete charting part of the code? You can email me at pkwan@advsofteng.net


Best Regards
Peter Kwan