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

Message ListMessage List     Post MessagePost Message

  colorAxis label Formatting
Posted by Judy on Jan-04-2023 13:45
Hi Peter,

I want to make colorAxis label has Formatting like this 2.3K,

I had tried like this colorAxis.addLabel(levelDetail[1], "2.3k");,

but it's not work,

string[] colorDetail

I also had tried like this colorAxis.setLabels(colorDetail);,

but the color also been change.

please tell me how can I do

Thanks!

Judy

  Re: colorAxis label Formatting
Posted by Peter Kwan on Jan-05-2023 03:29
Hi Judy,

By default, ChartDirector will automatically determine the color axis scale based on your data, and determine the labels on the color axis. For example, it may set the axis scale for certain data to 0 - 25, and set the labels to 0, 5, 10, 15, 20, 25.

I am not sure exactly what you want. If you think the axis scale and axis labels are OK, but want to add a character "K" after the label (that is, display the labels as 0K, 5K, 10K, 15K, 20K, 25K), you can use Axis.setLabelFormat. It is like:

colorAxis.setLabelFormat("{value}K");

If you want to divide the label by 1000, then append a "K" to the label, the format is:

c.yAxis().setLabelFormat("{={value}/1000}K");

See:

https://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1669883401#N1669883401

If you want to set the axis scale and labels yourself (for example, you want to use the scale 0 - 50 with a label every 10 units, instead of the scale automatically determine by ChartDirector), you can use Axis.setLinearScale.

The code colorAxis.addLabel(levelDetail[1], "2.3k"); will put the label "2.3K" at the levelDetail[1] position on the axis. Note that the label will only be visible if it is within the axis scale. For example, if the axis scale is 0 - 50, and your code adds a label at z = 10000, the label will be ignored, as the axis it is outside the axis. Also, the label must be added after ChartDirector has determined the axis scale (eg. after calling BaseChart.layout). If you use it too early, when ChartDirector determines the axis scale automatically, it will overwrite the label configuration.

The Axis.setLabels will configure the axis to use an enumerated scale. It is because the labels are text strings and have no meaning to the computer. They are just names for human reading. For example, you can use "High", "Medium", "Low" as the labels. ChartDirector will then simply use the array index 0, 1, 2, 3, ... as the axis scale.

If you want to specify an axis scale and set the labels for that scale, you can use Axis.setLinearScale2. See:

https://www.advsofteng.com/doc/cdnet.htm#Axis.setLinearScale2.htm

Best Regards
Peter Kwan