This is a migrated thread and some comments may be shown as answers.

Adding axis label items

4 Answers 166 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
skysailor
Top achievements
Rank 1
skysailor asked on 25 Jun 2008, 02:49 AM
Hi,
I would like to add some axis labels at different points along the axis scale. I have turned AutoScale off and set the MinValue and MaxValue to define the extent of the scale. I would then like to add some labels along the scale at various points. These may not be evenly spaced. If my scale goes from 1.0 up to 5.0 how do I get a label on the scale at a value of 2.5 say?

I'm adding ChartAxisItem objects to the Items in the axis. This seems to put them evenly spaced and seems to define the values of the axis value than place them on the axis at that point. What is the meaning of the ChartAxisItem Value property? Is this the scale value for that item label? Why is it of type Decimal and not of type Double?

Clayton.

4 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 27 Jun 2008, 06:39 AM
Hi skysailor,

Unfortunately using AddRange will not work for your case. You can still do what you want though using the following code:
RadChart1.PlotArea.YAxis.AutoScale = false
for (int i = 0; i < 10; i++) 
    ChartAxisItem item = new ChartAxisItem(); 
    item.Value = i * 10; 
    RadChart1.PlotArea.YAxis.Items.Add(item); 
 
    if (i == 6) 
    { 
        ChartAxisItem item2 = new ChartAxisItem(); 
        item2.Value = 65
        item2.TextBlock.Text = "Custom"
        RadChart1.PlotArea.YAxis.Items.Add(item2); 
    } 
As far as your question about the Value property - yes it indicates the position on the axis. It should be of type double, but is kept decimal for backwards compatibility reasons.

All the best,
Vladimir Milev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
skysailor
Top achievements
Rank 1
answered on 30 Jun 2008, 12:09 AM
Hi,
I still cannot get this to work. When I add axis items it changes the scales of may chart. I don't want this. I have a point cjhart with X/Y points scattered over it. I want to set the max/min of the X/Y scales and then not to have that change. I just want to add labels at certain points along the axis that I choose.

But when I add axis items it moves the data points. It seems as though you must have at least two axis items for the start and end of the axis scale. And then the Y scale will let you place other points at different positions on the scale but the X axis will not. The X axis labels are always evenly spaced. I'm using a ChartAxisLayoutMode.Normal on the XAxis so it should be treated the same as the YAxis.

Is there any way to put labels at random positions along the scale without messing up the chart?

Clayton.
0
Vladimir Milev
Telerik team
answered on 03 Jul 2008, 04:31 PM
Hi skysailor,

Thanks for the additional explanation. Now I understand what you need. Unfortunately what you describe requires some kind of annotation functionality for RadChart which is currently not implemented. I also cannot think of a work-around or a hack that could work in this situation. We sincerely apologize for this inconvenience.

Best wishes,
Vladimir Milev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
skysailor
Top achievements
Rank 1
answered on 03 Jul 2008, 11:12 PM
Hi,
What I ended up doing was adding 20 items to the axis and making them all invisible. Then choosing the item that was closest to the position I wanted and making it visible and setting the text label.
It works but an "annotation" feature would be nicer.
Clayton.
Tags
Chart (Obsolete)
Asked by
skysailor
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
skysailor
Top achievements
Rank 1
Share this question
or