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

BorderColor on LinearAxis Shows on Label

7 Answers 162 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 27 May 2015, 03:07 PM

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

7 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 28 May 2015, 03:11 PM
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
0
Laura
Top achievements
Rank 1
answered on 28 May 2015, 04:36 PM

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;

}

0
Dimitar
Telerik team
answered on 29 May 2015, 07:45 AM
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
0
RBarnes
Top achievements
Rank 1
answered on 12 Sep 2017, 08:06 PM

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.

0
Dimitar
Telerik team
answered on 13 Sep 2017, 06:13 AM
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.
0
RBarnes
Top achievements
Rank 1
answered on 13 Sep 2017, 05:46 PM

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

0
Dimitar
Telerik team
answered on 14 Sep 2017, 08:19 AM
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.
Tags
ChartView
Asked by
Laura
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Laura
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Share this question
or