Show first and last Itemlabel

4 posts, 0 answers
  1. Dipika
    Dipika avatar
    11 posts
    Member since:
    Sep 2012

    Posted 14 May 2013 Link to this post

    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
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 18 May 2013 Link to this post

    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.

  3. DevCraft banner
  4. Dipika
    Dipika avatar
    11 posts
    Member since:
    Sep 2012

    Posted 12 Jul 2013 Link to this post

    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
  5. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 17 Jul 2013 Link to this post

    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 >>
Back to Top