Page 1 of 1
Custom Y-Axis Position
Posted: Mon Jul 15, 2019 6:48 am
by 15686059
Hello Steema Support,
I've got an problem that I don't know how to solve.
Every Line in my Chart got an own Custom Y-Axis, but the first one uses the main Y-Axis.
I implemented a Function that hide or fade in the selected Axis.
But when a Custom Y-Axis is faded in, it doesn't get the same position like the main Axis.
So is there an option to set the same Axis-Position for the Custom Axis as for the main Axis?
Thank you for your help!!
Best regards,
Florian
Re: Custom Y-Axis Position
Posted: Mon Jul 15, 2019 7:32 am
by Christopher
Hello Florian,
You will need to specify a value for the LeftMargin of the Panel class to shift the Custom Axis across, e.g.
Code: Select all
private void InitializeChart()
{
var line = new Line(tChart1.Chart);
line.FillSampleValues();
}
bool _flag = false;
Axis _custom = null;
void SetCustom()
{
_flag = !_flag;
if (_flag)
{
tChart1[0].CustomVertAxis = _custom;
tChart1.Panel.MarginLeft = 7;
}
else
{
tChart1[0].CustomVertAxis = null;
tChart1.Panel.MarginLeft = 3;
}
}
private void button2_Click(object sender, EventArgs e)
{
_custom = new Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(_custom);
SetCustom();
}
Re: Custom Y-Axis Position
Posted: Mon Jul 15, 2019 7:34 am
by 15686059
Hello Christopher,
Thanks for your fast help!
But is it possible to post the code in VB.NET?
Thank you very much!
Best regards,
Florian
Re: Custom Y-Axis Position
Posted: Mon Jul 15, 2019 7:52 am
by Christopher
Hello Florian,
I hope you find this more helpful:
Code: Select all
Private Sub InitializeChart()
Dim line = New Line(tChart1.Chart)
line.FillSampleValues()
End Sub
Private _flag As Boolean = False
Private _custom As Axis = Nothing
Private Sub SetCustom()
_flag = Not _flag
If _flag Then
tChart1(0).CustomVertAxis = _custom
tChart1.Panel.MarginLeft = 7
Else
tChart1(0).CustomVertAxis = Nothing
tChart1.Panel.MarginLeft = 3
End If
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
_custom = New Axis(tChart1.Chart)
tChart1.Axes.Custom.Add(_custom)
SetCustom()
End Sub
Re: Custom Y-Axis Position
Posted: Mon Jul 15, 2019 8:23 am
by 15686059
Hello Christopher,
thanks, that works great!
But I've got another question:
How can I change the color of the numbers in the y-axis?
Thanks in advance!
Best regards,
Florian
Re: Custom Y-Axis Position
Posted: Mon Jul 15, 2019 8:56 am
by 15686059
I've got it already!
It is:
TChart1.Axes.Left.Labels.Font.Color = Color.Red
Thanks for helping!
Best regards,
Florian