Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > Location of the label at the center and above the point in Line Chart.

Not answered Location of the label at the center and above the point in Line Chart.

Feed from this thread
  • Yaroslav avatar

    Posted on Jan 26, 2012 (permalink)

    How to place the label of Line chart top and center relative to the point?

    Reply

  • Petar Marchev Petar Marchev admin's avatar

    Posted on Jan 31, 2012 (permalink)

    Hello,

    Presently, there is no way to achieve this with out-of-the-box means.

    However, I can suggest a work-around for this. In a resume you will need to wait for the item labels to get populated into the chart and then you can adjust their margins. I have pasted some code below that should help you.

    public MainPage()
    {
      InitializeComponent();
      this.radChart1.LayoutUpdated += this.radChart1_LayoutUpdated;
    }
     
    void radChart1_LayoutUpdated(object sender, EventArgs e)
    {
      var labelsPanel = Telerik.Windows.Controls.ChildrenOfTypeExtensions.FindChildByType<LabelsPanel>(this.radChart1);
      if (labelsPanel == null || labelsPanel.Children.Count == 0)
        return;
            
      this.radChart1.LayoutUpdated -= this.radChart1_LayoutUpdated;
     
      var first = labelsPanel.Children.First();
      var last = labelsPanel.Children.Last();
     
      foreach (SeriesItemLabel seriesItemLabel in labelsPanel.Children)
      {
        if (seriesItemLabel == first || seriesItemLabel == last)
          continue;
     
        double leftAdjustment = -(seriesItemLabel.ActualWidth / 2 + 5);
        seriesItemLabel.Margin = new Thickness(leftAdjustment, 0, 0, 0);
      }
    }
     

    Regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > Location of the label at the center and above the point in Line Chart.
Related resources for "Location of the label at the center and above the point in Line Chart."

Silverlight Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]