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

Show first and last Itemlabel

3 Answers 119 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dipika
Top achievements
Rank 1
Dipika asked on 14 May 2013, 05:57 PM
Hi,
I have Lineseries chart in which I want to show only first and last item label. By setting ShowItemLabel=true it shows item label on each and every point and because of that original graph line is not visible.
So is there any way we can show only first and last item label ?
Also when graph line is stick to the x-axis i.e. at 0th position that time though I increase StrockThickness, it doesnt looks that much visible as it shown  in other range. Can you please suggest some way to show/ highlight graph line placed at x-axis i.e. at 0th position ?

Thanks,
Dipika

3 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 18 May 2013, 08:21 AM
Hi Dipika,

In order to achieve this, you can bind the visibility of the series item labels and use a converter to filter the labels in between the first and the last one. I have attached a sample project to demonstrate that.

I hope this helps.
 
Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dipika
Top achievements
Rank 1
answered on 12 Jul 2013, 06:08 PM
Hi,
Thanks for the reply :)
However have query regarding to show first and last label while zoomin/zoomout.
I am using Auto mode to set range, however while zooming, sometimes it doesn't show last label, however while debugging converter I found that data series takes last data which doesn't get seen while zooming and that's why not able to show last label. Can you please help me to set last label while zooming as zooming doesn't take dataseries properly to show last label. Please revert if not get.


Thank you,
Dipika
0
Petar Kirov
Telerik team
answered on 17 Jul 2013, 11:27 PM
Hi Dipika,

Instead of using a SeriesItemLabelStyle with converter, you can attach to RadChart's LayoutUpdated event and change the visibility of all of the labels, except for the first and the last, by finding them in the visual tree:
public MainPage()
{
    InitializeComponent();
 
    this.chart.LayoutUpdated += Chart_LayoutUpdated;
}
 
void Chart_LayoutUpdated(object sender, EventArgs e)
{
    var labelsPanel = this.chart.ChildrenOfType<LabelsPanel>().FirstOrDefault();
 
    if (labelsPanel == null)
        return;
 
    SetLabelsVisibility(labelsPanel.Children);
}
 
private static void SetLabelsVisibility(UIElementCollection labels)
{
    if (labels.Count < 1)
        return;
 
    for (int i = 1; i < labels.Count - 1; i++)
    {
        labels[i].Visibility = Visibility.Collapsed;
    }
}


Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
Dipika
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Dipika
Top achievements
Rank 1
Share this question
or