cancel
Showing results for 
Search instead for 
Did you mean: 

X-Axis Labelling

Former Member
0 Kudos

Hi All,

I want to write a javascript for an iChart Applet where i can define the gap after which x-axis label should appear.

For example, if i am plotting a chart of population in a country for all year. I want to show all the bars for 12 months, however, i want to display labels for 1st, 4th, 7th, 10th, 12th bar only. So, that the chart looks neat.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

jcgood25
Active Contributor
0 Kudos

Claude,

By default, the iChart will always display a label for the first and last item, so in your example the 1st and 12th bars should have one, and bar mode will typically show a label for each bar. If you change your XAxisTicksPerLabel setting to 3 shouldn't the remaining items get the labels you desire? If this doesn't work with the standard Bar or GroupBar mode, then switch to Custom mode and make your pen types Bar on the pen details tab and the ticks per label should work. Using the ticks per label will allow the dataset to drive the display items, whereas CustomLabels are just hard-coded custom strings.

Regards,

Jeremy

Former Member
0 Kudos

Thanks for your inputs Jeremy.

However, I am not been able to do that. XAxisTicksPerLabel is not having any effect on the output.

@Jeremy/Vijaya

Talking about Custum Labels, I guess for that the data will be hard-coded, however, my data is coming from the data source for x-axis labelling.

@Pradeep

The Label Depth is an alternative way for making labels look less clustured but consider the case when we are plotting three values against one x-axis column. In such cases, the same label gets repeated and which is just a shear waste of space.

Please correct me if i have misunderstood your comments.

jcgood25
Active Contributor
0 Kudos

Have you tried Custom chart mode like I suggested earlier? You will need to specify Bar mode for each of your pens on the pen details tab, but this chart type should honor the corresponding XAxisTicksPerLabel setting.

Former Member
0 Kudos

Hi Jeremy,

No, I havent tried that as yet. I will get back to you once I attempt that.

Thanks a lot for the support.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Claude,

The suggestion given above will work, but for that we have to hard code custom strings.If the objective is just to give a clean representation,then instead of giving alternate lables we can use the depth label feature of the graph.In this the labels will be displayed in a manner which gives a clear and neat picture.

It can be handled from javascript.

var objChart = document.appPopulation.getChartObject(); // appPopulation is the name of the applet

now chart object is assigned to variable objChart. then do

objChart.setXAxisLabelDepth(2); // depth can be set to 2,3,4 ... that defines the depth level

document.appPopulation.refresh();

then clear the java console and refersh the applet.

This will set the depth for the labels.So there will not be any overlapping of labels.

Regards

Pradeep

Former Member
0 Kudos

Hi,

<b>CustomLabels</b> parameter provides a list of user-provided labels that will be displayed below the X Axis of the chart. The label positions will be evenly spaced based on the number of items provided in the list.

Try using Custom labels with AxisWidth.