how to do display x-Axis Label
how to do display x-Axis Label
how to do display x-Axis Label like 0 1 2 3 0 1 2 3 0 1 2 3
one axes not multi axis
one axes not multi axis
Hi Grace
You can use the "GetAxisLabel" event of the chart to change x-Axis label, your code can be something similar as below code:
You can use the "GetAxisLabel" event of the chart to change x-Axis label, your code can be something similar as below code:
Code: Select all
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender == tChart1.Axes.Bottom) //Only x-Axis
e.LabelText = (Convert.ToInt16(e.LabelText) % 4).ToString();
}
please look this code
Code: Select all
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
TestLine();
}
public void TestLine()
{
Line line1 = new Line();
Line line2 = new Line();
line1.Add(1.5, 1.7);
line1.Add(2.4, 2.9);
line1.Add(3.6, 4.9);
line1.Add(4.9, 5.6);
line2.Add(5.7, 2.6);
line2.Add(6.3, 3.5);
line2.Add(7.9, 4.2);
line2.Add(9.7, 4.3);
this.tChart1.Chart.Series.Add(line1);
this.tChart1.Chart.Series.Add(line2);
line1.Pointer.Style = PointerStyles.Circle;
line1.Pointer.Visible = true;
line2.Pointer.Style = PointerStyles.Circle;
line2.Pointer.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Mark;
}
private void tChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
{
if (((Steema.TeeChart.Axis)sender).Equals(tChart1.Axes.Bottom)) e.LabelText = "Period " + Convert.ToString(e.ValueIndex);
}
}
create two line , but only display one line x-Axis Label,9348258 wrote:Hi Grace
You can use the "GetAxisLabel" event of the chart to change x-Axis label, your code can be something similar as below code:
Code: Select all
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e) { if (sender == tChart1.Axes.Bottom) //Only x-Axis e.LabelText = (Convert.ToInt16(e.LabelText) % 4).ToString(); }
line2 x-Axis Label is gone
Hi Grace
The parameter e.ValueIndex of the "GetAxisLabel" event returns -1 if the serie hasn't a label. So if you want to use this parameter you should put label as below code:
If you want that also the second line Axis label is displayed, you have two possibilities, the first is put also in the first line the same points to the second line as below code:
The other one is to use a custom labels, you can put this as below line:
You can see more about custom labels in the "What's New?\Welcome !\Axes\Labels\Custom labels" example at the features demo. You'll find the demo at TeeChart's program group.
The parameter e.ValueIndex of the "GetAxisLabel" event returns -1 if the serie hasn't a label. So if you want to use this parameter you should put label as below code:
Code: Select all
line1.Add(1.5, 1.7, "1.5");
Code: Select all
line1.Add(5.7, 0, Color.Transparent);
line1.Add(6.3, 0, Color.Transparent);
line1.Add(7.9, 0, Color.Transparent);
line1.Add(9.7, 0, Color.Transparent);
line2.Add(5.7, 2.6,"5.7");
line2.Add(6.3, 3.5, "6.3");
line2.Add(7.9, 4.2, "7.9");
line2.Add(9.7, 4.3, "9.7");
Code: Select all
tChart1.Axes.Bottom.Labels.Items.Add(1.5, "1.5");
You can see more about custom labels in the "What's New?\Welcome !\Axes\Labels\Custom labels" example at the features demo. You'll find the demo at TeeChart's program group.
but use this method:
The other one is to use a custom labels, you can put this as below line:
Code:
tChart1.Axes.Bottom.Labels.Items.Add(1.5, "1.5");
it is a problem that the items won't show friendly when there are so much points i added.and also it must can be zoom in or out.so if zoom out ,the items can't see what they are.how to do about it.can it change when the axie change?
The other one is to use a custom labels, you can put this as below line:
Code:
tChart1.Axes.Bottom.Labels.Items.Add(1.5, "1.5");
it is a problem that the items won't show friendly when there are so much points i added.and also it must can be zoom in or out.so if zoom out ,the items can't see what they are.how to do about it.can it change when the axie change?
Hi Grace
I think that it's better to put the labels directly, without event and without custom labels. The bottom axis paints the labels of the first serie. So, you should put all the labels in the first serie, in this case you shouldn't have problems with zoom and scroll. You can do something similar as below code:
I think that it's better to put the labels directly, without event and without custom labels. The bottom axis paints the labels of the first serie. So, you should put all the labels in the first serie, in this case you shouldn't have problems with zoom and scroll. You can do something similar as below code:
Code: Select all
public void TestLine()
{
Line line1 = new Line();
Line line2 = new Line();
line1.Add(1.5, 1.7, GetPointLabel(line1));
line1.Add(2.4, 2.9, GetPointLabel(line1));
line1.Add(3.6, 4.9, GetPointLabel(line1));
line1.Add(4.9, 5.6, GetPointLabel(line1));
//The below lines puts the labels of second serie in a (nulls/transparents) points, of the first serie
line2.Add(5.7, 2.6); line1.Add(5.7, 0, GetPointLabel(line1), Color.Transparent);
line2.Add(6.3, 3.5); line1.Add(6.3, 0, GetPointLabel(line1), Color.Transparent);
line2.Add(7.9, 4.2); line1.Add(7.9, 0, GetPointLabel(line1), Color.Transparent);
line2.Add(9.7, 4.3); line1.Add(9.7, 0, GetPointLabel(line1), Color.Transparent);
this.tChart1.Chart.Series.Add(line1);
this.tChart1.Chart.Series.Add(line2);
line1.Pointer.Style = PointerStyles.Circle;
line1.Pointer.Visible = true;
line2.Pointer.Style = PointerStyles.Circle;
line2.Pointer.Visible = true;
}
private static string GetPointLabel(Line line1)
{
return "Period" + line1.Count.ToString();
}