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

Message ListMessage List     Post MessagePost Message

  Changing the date format on the chart legend when tracking values
Posted by Steph on Jun-07-2016 10:55
Attachments:
Hi Peter,

Just a very quick one: how do you change the date format in the legend ?
Also, is there a compatibility with the new Java 8 Date/Time library ?

Thanks
Best Regards
FinanceChart.JPG

  Re: Changing the date format on the chart legend when tracking values
Posted by Peter Kwan on Jun-07-2016 22:46
Hi Steph,

Since you mentioned about the Java 8 Date/Time library, I assume the screen shot is a desktop application (as opposed to a web application), and it is using the programmable track cursor feature to create the legend. In this case, the date should be formatted by your own code. If you code is based on the "Finance Chart Track Line (Windows)" sample code, it should have code like the followings which formats the legend date:

    ... c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy") ...

You can change the mmm dd, yyyy above to use alternative formats. You can also use Java code for formatting. In this case, you can convert the xValue to java.util.Date and use Java to format it:

java.util.Date d = Chart.NTime(xValue);
.... format d using your own method ....



As a programming library, our code needs to work in all commonly used Java versions. That is why we often cannot directly use the "Java 8 Date/Time library" as it only works in the latest Java version. If your code is using the "Java 8 Date/Time library", you may convert "Java 8 LocalDateTime or LocalDate" to either ChartDirector "Chart.chartTime" values or "java.util.Date" objects before passing them to ChartDirector. In particular, the ChartDirector chartTime is usually similar concept as LocalDateTime and LocalDate and it should be easy to convert from one to the other.

Regards
Peter Kwan

  Re: Changing the date format on the chart legend when tracking values
Posted by Steph on Jun-08-2016 14:29
Thanks a lot Peter, I'm going to have a look at this. As usual, fantastic support here.

  Re: Changing the date format on the chart legend when tracking values
Posted by Steph on Jun-09-2016 16:23
Attachments:
Just one more question, when displaying the data as a number, I'm ending up with some weird letter at at the end like "e", "x", "o"... Would you have any idea of where it is coming from ?

Thanks Peter
Number Formatting.JPG

  Re: Changing the date format on the chart legend when tracking values
Posted by Steph on Jun-09-2016 16:37
Ok, sorry, I found out, it is a parameter called "unitChar" that is aggregated to the formatted string

Cheers