Page 1 of 1

Create New Y Axis

Posted: Wed Oct 28, 2015 5:16 pm
by srinin2k
I want to add a secondary Y axis on right side. I want to inherit all the properties of first Y Axis i.e YAxes[0]. (Font, Color). How do I do that?

I wish you have a simple function like "Clone()"

I have one problem with manually settings attributes. The axis has some violet color at the top and the bottom edge of the axis. Need to know which property to set to make it like the other Y axis.
I use code like

var yaxis = Chart.ViewXY.YAxes[0];
AxisY axis2 = new AxisY(Chart.ViewXY, true);

axis2.Title.HorizontalAlign = YAxisTitleAlignmentHorizontal.Right;
axis2.Units.HorizontalAlign = YAxisTitleAlignmentHorizontal.Right;
axis2.Units.DistanceToAxis = 20;

axis2.MinorDivTickStyle.Visible = false;
axis2.Alignment = AlignmentHorizontal.Right;
axis2.MajorDivTickStyle.Alignment = Alignment.Far;
axis2.MinorDivTickStyle.Alignment = Alignment.Far;
axis2.AxisColor = yaxis.AxisColor;
axis2.MajorDivTickStyle.Color = yaxis.MajorDivTickStyle.Color;
axis2.LabelsColor = yaxis.LabelsColor;
axis2.Title.Color = yaxis.Title.Color;
axis2.GridStripColor = yaxis.GridStripColor;
axis2.MajorGrid.Color = yaxis.MajorGrid.Color;

axis2.Title.Font = yaxis.Title.Font;
axis2.Title.Shadow = yaxis.Title.Shadow;
axis2.LabelsFont = yaxis.LabelsFont;

axis2.AllowAutoYFit = true;

Chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;

Re: Create New Y Axis

Posted: Thu Oct 29, 2015 8:31 am
by ahe
Do you mean the "ScaleNibs"? The small handles at the ends of the axis?

Code: Select all

axis2.ScaleNibs.Color = yaxis.ScaleNibs.Color;
But I agree, for your use case a Clone() function or a copy constructor would be useful. I solved this by manually creating all axes (axisses?) to make sure they look the same.