lable axsis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 20, 2008 4:03 pm

Hello Alex,

We did receive your e-mail and example and replied to it yesterday and today. Didn't you receive our e-mails?

Anyway, this was a bug (TF02012833) which has been fixed for the next maintenance release. In the meantime, I also suggested you a workaround that consisted on using the GetAxisLabel event. Here is the code:

Code: Select all

  public partial class Form1 : Form
  {
    private DataTable sourceTable;
    private DataColumn colXData;
    private DataColumn colYData;
    private DataColumn colColor;
    private DataColumn newC;
    private Steema.TeeChart.Styles.FastLine f;
		private Annotation anno1;
    private Steema.TeeChart.Axis axis1;
		private string[] XLabels;

    public Form1()
    {
        InitializeComponent();
        LoadDB();
				ShowGraph();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void LoadDB()
    {
      //System.DateTime
      sourceTable = new DataTable("sourceTable");
      colXData = new DataColumn("XData", Type.GetType("System.DateTime"));
      colYData = new DataColumn("YData", Type.GetType("System.String"));
      colColor = new DataColumn("Color", Type.GetType("System.Object"));
      newC = new DataColumn("newC", Type.GetType("System.Object"));

      // add colls
      sourceTable.Columns.Add(colXData);
      sourceTable.Columns.Add(colYData);
      sourceTable.Columns.Add(colColor);
      sourceTable.Columns.Add(newC);

      // fill data

      DataRow NewRow;
      int time = 100;
			int start = 100;
			int end = 130;

			long now = DateTime.Now.Ticks;

      for (int i = start; i < end; i++)
      {
        NewRow = sourceTable.NewRow();

        // NewRow["Desc"] = "Label" + i.ToString();

        NewRow["YData"] = i * i;//Math.Sin(i*2*Math.PI/360);
        NewRow["newC"] = i * 5.5f;
        if ((i % 5) == 0)
        {
            time = time + 1;
            NewRow["Color"] = Color.Red;
        }
        else
        {
            time = time + 2;
            NewRow["Color"] = Color.Blue;
        }

				DateTime next = new DateTime(now);
				next = next.AddMilliseconds(time);
				NewRow["XData"] = next;

				//string tmpDate = "11:11:11." + time;
				//XLabels[i - start] = tmpDate;
				//NewRow["XData"] = DateTime.Parse(tmpDate);
        sourceTable.Rows.Add(NewRow);
      }
    }

    private void ShowGraph()
    {
			tChart1.Panel.MarginLeft = 8;

      this.axis1 = new Steema.TeeChart.Axis(this.tChart1.Chart);

			//axis1.Increment = (double)Steema.TeeChart.DateTimeSteps.OneMillisecond; 
			axis1.StartPosition = 0;
			axis1.EndPosition = 50;
			axis1.AxisPen.Style = System.Drawing.Drawing2D.DashStyle.Solid;
			axis1.AxisPen.Color = Color.Red;
			axis1.AutomaticMaximum = true;
			axis1.AutomaticMinimum = true;
			tChart1.Axes.Custom.Add(axis1);

			//tChart1.Axes.Bottom.Labels.ValueFormat = "0.#";
			////tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Value;						
			//tChart1.Axes.Bottom.Labels.Separation = 0;
			//tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss:FFF";
			////tChart1.Axes.Bottom.Labels.Angle = 90;
			//tChart1.Axes.Bottom.Grid.Visible = false;
			////tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMillisecond);

      tChart1.Tools.Add(anno1 = new Annotation());

			anno1.Shape.CustomPosition = true;
			anno1.Shape.Left = axis1.Position + 50;
			anno1.Shape.Top = axis1.IStartPos + 50;
			anno1.Shape.Font.Color = Color.Blue;
			anno1.Text = "ok";
			anno1.AutoSize = true;
			anno1.Shape.Transparent = true;

      f = new Steema.TeeChart.Styles.FastLine();

			f.DrawAllPoints = false;
      tChart1.Series.Add(f);          
      f.CustomVertAxis = axis1;
      f.LinePen.Width = 4;
			f.ValueFormat = "";
			//f.XValues.DateTime = true;
			f.XValues.DataMember = "XData";
			f.YValues.DataMember = "Ydata";
			// f.ColorMember = "Color";
			//f.LabelMember = "newC";
			f.DataSource = sourceTable;

			tChart1.Axes.Bottom.Labels.ValueFormat = "";
			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
    }

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Bottom)
			{
				DateTime dt = DateTime.FromOADate(Convert.ToDouble(e.LabelText));
				dt.Millisecond.ToString();
				e.LabelText = dt.ToLongTimeString() + ":" + dt.Millisecond.ToString();
			}
		}

  }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marian
Newbie
Newbie
Posts: 8
Joined: Tue Jan 29, 2008 12:00 am

performance

Post by Marian » Fri Mar 07, 2008 2:28 pm

Hi Alex,
I use Teechart Java version. My experience with it is that if you plot a bigger number of points, changing chart's background grid from dashed to solid or removing it helps speed of panning and zooming a lot.
Hope it will be of some use for you as well.
Marian

Alain Bolduc
Newbie
Newbie
Posts: 30
Joined: Mon Feb 18, 2008 12:00 am

Question on label axis...

Post by Alain Bolduc » Tue Mar 25, 2008 2:30 pm

Hi Narcís!

Is there a way to display text (like units) on axis label but using value for the graphic?

Here an exemple of what I would like to do :

Code: Select all

 dB -|
     |
  4 -|
     |
  2 -|
      ----------------------
      0   1    2   3   4   km
Thanks, bye!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 25, 2008 2:43 pm

Hi Qwerty,

I'm not 100% sure of what you are trying to achieve. I can think of several options here:

1. Use axis titles for that, for example:

Code: Select all

			tChart1.Axes.Left.Title.Text = "dB";
2. Populate series with the labels you'd like to be plotted, eg.:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			int i;

			for (i = 0; i < 10; i++)
			{
				line1.Add(i, i, i.ToString());
			}

			line1.Add(i, i, "dB");

			tChart1.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
			tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;

			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if ((sender == tChart1.Axes.Bottom) && (e.ValueIndex == tChart1[0].Count - 1))
			{
				e.LabelText = "km";
			}
		}
3. Use custom axis labels as shown in the All Features\Welcome !\Axes\Labels\Custom labels example at the features demo available at TeeChart's program group.

If this doesn't help don't hesitate to let us know.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 31, 2008 3:31 pm

Hello Alex,

We have been investigating TF02012833 and found that it is not a bug. Using code below works fine, commented out line was the one causing the problem.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = true;
			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

			DateTime now = new DateTime(DateTime.Now.Ticks);

			for (int i = 0; i < 45; i++)
			{
				fastLine1.Add(now.AddMilliseconds(i).ToOADate(), i);
			}

			fastLine1.XValues.DateTime = true;
			tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMillisecond);
			//tChart1.Axes.Bottom.Increment = (double)(Steema.TeeChart.DateTimeSteps.OneMillisecond);
			tChart1.Axes.Bottom.Labels.Angle = 90;
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply