BorderColor on LinearAxis Shows on Label

8 posts, 0 answers
  1. Laura
    Laura avatar
    11 posts
    Member since:
    Jan 2014

    Posted 27 May 2015 Link to this post

    Hi,

     

    I would like to change the color of the Axis line, but when I set the BorderColor, I get a border around the label that matches the color I am setting for the Axis line.  I don't want a border around the label, I just want to change the color of the line.  How do I do that?  

    This is the code: linearAxis1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(143)))), ((int)(((byte)(142)))));

    Laura

  2. Dimitar
    Admin
    Dimitar avatar
    1822 posts

    Posted 28 May 2015 Link to this post

    Hello Laura,

    Thank you for writing.

    The axis children are inheriting the border color and in this case you must set their border color as well:
    foreach (var item in verticalAxis.Children)
    {
        item.BorderColor = Color.Transparent;
    }

    Please let me know if there is something else I can help you with. 

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Laura
    Laura avatar
    11 posts
    Member since:
    Jan 2014

    Posted 28 May 2015 in reply to Dimitar Link to this post

    Thank you Dimitar!  This worked perfectly, though I did have to change it just slightly to also change the backcolor of the item, then all worked well.

    foreach (var item in verticalAxis.Children)

    {    

    item.BorderColor = Color.Transparent;
    item.BackColor = Color.Transparent;

    }

  4. Dimitar
    Admin
    Dimitar avatar
    1822 posts

    Posted 29 May 2015 Link to this post

    Hello Laura,

    I am glad I could be of help. Let us know if you have any other questions.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. RBarnes
    RBarnes avatar
    49 posts
    Member since:
    Oct 2012

    Posted 12 Sep in reply to Laura Link to this post

    Cycling the Axis.Children works if your axis are static, if you however are sending live data to you chart and your axis change, it puts all the borders back around the labels again.  I tried cycling the children after changing the min and max values, but no luck in keeping the borders around the labels hidden.

  6. Dimitar
    Admin
    Dimitar avatar
    1822 posts

    Posted 13 Sep Link to this post

    Hello Roger,

    You can use custom renderer for this case. Here is a sample implementation:
    public class CustomCartesianRenderer : CartesianRenderer
    {
        public CustomCartesianRenderer(CartesianArea area)
            : base(area)
        { }
        protected override void Initialize()
        {
            base.Initialize();
            for (int i = 0; i < this.DrawParts.Count; i++)
            {
                AxisLabelDrawPart part = this.DrawParts[i] as AxisLabelDrawPart;
                if (part != null && part.Element is CategoricalAxis)
                {
                    this.DrawParts[i] = new MyAxisLabelDrawPart((CategoricalAxis)part.Element, this);
                }
            }
        }
    }
    class MyAxisLabelDrawPart : AxisLabelDrawPart
    {
        public MyAxisLabelDrawPart(Axis axis, IChartRenderer renderer) : base(axis, renderer)
        { }
        protected override void DrawNoneAndMultiLineLabelElements()
        {
     
            foreach (var item in this.Element.Children)
            {
               
                item.BorderWidth = 0;
            }
            base.DrawNoneAndMultiLineLabelElements();
        }
    }

    The default renderer can be changed in the CreateRenderer event handler:
    void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
    {
        e.Renderer = new CustomCartesianRenderer(e.Area as CartesianArea);
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. RBarnes
    RBarnes avatar
    49 posts
    Member since:
    Oct 2012

    Posted 13 Sep in reply to Dimitar Link to this post

    Not to sound negative by any means, but this seems excessive to be able to remove the borders on labels. Based on my understanding, are inherited from the axis border.

    Suggested upgrade idea, would resolve my issue here.

    HorizontalAxis.LabelBorder.Visible = False

    VerticalAxis.LabelBorder.Visible = False

  8. Dimitar
    Admin
    Dimitar avatar
    1822 posts

    Posted 5 days and 18 hours ago Link to this post

    Hi Roger,

    This is a good suggestion and this is why I have logged a feature request for this in our Feedback Portal. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top