how to do display x-Axis Label
Posted: Thu Jun 07, 2007 6:16 am
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
Steema Software - Customer Support Forums
http://216.92.243.79/support/
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();
}
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(); }
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");
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();
}