Page 1 of 1

TeeChart for Compact Framework Problem

Posted: Wed Mar 08, 2006 2:05 pm
by 9640546
Current Version of TeeChart - Pocket flicker heavy after adding a point into a serie (fastline!). Is there a solution to avoid this flicker ? In the earlyer versions this problem does't occur!

Here my code:

Code: Select all


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart.Pocket;
using Steema.TeeChart.Tools;


namespace TeeChartV2Test
{
    public class Form1 : Form
    {
        private Steema.TeeChart.Styles.Line m_teechartLine1 = null;
        private DateTime m_dtStart = DateTime.Parse("08.03.2006 13:00");

        /// <summary>
        /// Erforderliche Designervariable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        private System.Windows.Forms.MainMenu mainMenu1;

        /// <summary>
        /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
        protected override void Dispose ( bool disposing )
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose( disposing );
        }

        #region Vom Windows Form-Designer generierter Code

        /// <summary>
        /// Erforderliche Methode für die Designerunterstützung.
        /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        private void InitializeComponent ()
        {
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.m_MyTeeChart = new Steema.TeeChart.Pocket.TChart();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.tmrAddValues = new System.Windows.Forms.Timer();
            this.SuspendLayout();
            // 
            // m_MyTeeChart
            // 
            this.m_MyTeeChart.AutoRepaint = true;
            this.m_MyTeeChart.Location = new System.Drawing.Point( 3, 3 );
            this.m_MyTeeChart.Name = "m_MyTeeChart";
            this.m_MyTeeChart.Size = new System.Drawing.Size( 214, 220 );
            this.m_MyTeeChart.TabIndex = 0;
            this.m_MyTeeChart.Text = "tChart1";
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point( 3, 229 );
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size( 64, 33 );
            this.button1.TabIndex = 1;
            this.button1.Text = "button1";
            this.button1.Click += new System.EventHandler( this.button1_Click );
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point( 119, 233 );
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size( 98, 29 );
            this.button2.TabIndex = 2;
            this.button2.Text = "button2";
            this.button2.Click += new System.EventHandler( this.button2_Click );
            // 
            // tmrAddValues
            // 
            this.tmrAddValues.Interval = 1000;
            this.tmrAddValues.Tick += new System.EventHandler( this.timer1_Tick );
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF( 96F, 96F );
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.ClientSize = new System.Drawing.Size( 234, 275 );
            this.Controls.Add( this.button2 );
            this.Controls.Add( this.button1 );
            this.Controls.Add( this.m_MyTeeChart );
            this.Location = new System.Drawing.Point( 50, 50 );
            this.Menu = this.mainMenu1;
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout( false );

        }
        #endregion

        private Steema.TeeChart.Pocket.TChart m_MyTeeChart;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Timer tmrAddValues;

        public Form1 ()
        {
            InitializeComponent();
        }

        private void button1_Click ( object sender, EventArgs e )
        {
            InitializeTeeChart();
        }

        /// -------------------------------------------------------------------
        /// <summary>
        /// Method name		:	InitializeTeeChart
        /// Author			:	TJo
        ///	Date			:	11.10.2005
        /// </summary>
        /// -------------------------------------------------------------------
        private void InitializeTeeChart()
        {
            m_MyTeeChart.Legend.Visible = true;
            m_MyTeeChart.Aspect.View3D  = false;
            m_MyTeeChart.AutoRepaint    = false;

            // move legend
            m_MyTeeChart.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;
            m_MyTeeChart.Legend.Alignment   = Steema.TeeChart.LegendAlignments.Bottom;
            m_MyTeeChart.Legend.Left        = 0;

            // create axies
            m_MyTeeChart.Axes.Left.Automatic    = false;
            m_MyTeeChart.Axes.Left.Minimum      = 0;
            m_MyTeeChart.Axes.Left.Maximum      = 100;
            m_MyTeeChart.Axes.Left.Grid.Visible = true;

            m_MyTeeChart.Axes.Right.Grid.Visible = false;
            m_MyTeeChart.Axes.Right.Automatic    = false;
            m_MyTeeChart.Axes.Right.Minimum      = 0;
            m_MyTeeChart.Axes.Right.Maximum      = 100;
            m_MyTeeChart.Axes.Right.Visible      = true;

            
            m_MyTeeChart.Axes.Bottom.Grid.Visible = true;
            m_MyTeeChart.Axes.Bottom.Automatic    = false;
            m_MyTeeChart.Axes.Bottom.Minimum      = DateTime.Parse("08.03.2006 13:00").ToOADate();
            m_MyTeeChart.Axes.Bottom.Maximum      = DateTime.Parse( "08.03.2006 13:20" ).ToOADate();


            Steema.TeeChart.Axis axisCustom = new Steema.TeeChart.Axis( m_MyTeeChart.Chart );
            axisCustom.Grid.Visible         = false;
            axisCustom.OtherSide            = true;
            axisCustom.PositionUnits        = Steema.TeeChart.PositionUnits.Pixels;
            axisCustom.RelativePosition     = -50;
            axisCustom.Automatic            = false;
            axisCustom.Minimum              = 0;
            axisCustom.Maximum              = 100;
            axisCustom.Visible              = true;
            m_MyTeeChart.Axes.Custom.Add( axisCustom );

            // resize chart cause of CustomAxis 
            m_MyTeeChart.Panel.MarginRight = 8;

            // add line
            m_teechartLine1 = new Steema.TeeChart.Styles.Line( m_MyTeeChart.Chart );
            // m_teechartLine1.DrawAllPoints = false;
            m_teechartLine1.Visible         = true;
            m_teechartLine1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
            m_teechartLine1.LinePen.Width = 5;

            // set date/time format 
            m_teechartLine1.XValues.DateTime              = true;
            m_MyTeeChart.Axes.Bottom.Labels.DateTimeFormat = "dd.MM.yyyy\nHH:mm";
            m_MyTeeChart.Axes.Bottom.Labels.MultiLine      = true;
            

        }

        private void button2_Click ( object sender, EventArgs e )
        {
            tmrAddValues.Enabled = !tmrAddValues.Enabled;
        }

        private void timer1_Tick ( object sender, EventArgs e )
        {
            m_dtStart =  m_dtStart.AddMinutes( 1 );
            m_MyTeeChart.AutoRepaint = false;
            Random rnd = new Random();
            m_teechartLine1.Add( m_dtStart, rnd.Next( 0, 100 ) );
            m_MyTeeChart.AutoRepaint = true;
            m_MyTeeChart.Refresh();
        }
    }
}

Posted: Wed Mar 08, 2006 2:47 pm
by 9640546
I have found a smal workaroud for this problem! Perhaps it may be useful for others :wink:

Code: Select all

/*****************************************************************************	 
                      (C) Copyright by VESCON GmbH 
																				                      
 Module   : TeeChartEx.cs
 SCCS     : $Archive: $ $Revision:  $
 Author   : TJo
 Date     : 08.03.2006
 Last Change : $Date: $ $Author: $  
 Description : 

 Known problems :

 Modification history :
     Date   | Usr.| Comment
   ---------+-----+----------------------------------------------------------	 
            |     |
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using Steema.TeeChart.Pocket;

namespace FIChart.Controls
{
    /****************************************************************************
    Class name     :  TeeChartEx
    Author         :  
    Date           :  
    Description    :  

    Known problems :

    Modification history : 

      Date   | Usr.| Comment 
    ---------+-----+----------------------------------------------------------
             |     | 
    ****************************************************************************/
    /// <summary>
    /// Class TeeChartEx
    /// </summary>
    public class TeeChartEx : Steema.TeeChart.Pocket.TChart
    {
        //---------------------------------------------------------------------
        // -- local members
        #region local members
        private Bitmap m_bmpBitmap = null;
        #endregion
        //---------------------------------------------------------------------

        /// -------------------------------------------------------------------
        /// <summary>
        /// Method name		:	OnPaintBackground
        /// Author			:	TJo
        ///	Date			:	08.03.2006
        /// </summary>
        /// -------------------------------------------------------------------
        protected override void OnPaintBackground ( PaintEventArgs e )
        {
        }

        /// -------------------------------------------------------------------
        /// <summary>
        /// Method name		:	OnPaint
        /// Author			:	TJo
        ///	Date			:	08.03.2006
        /// </summary>
        /// -------------------------------------------------------------------
        protected override void OnPaint ( PaintEventArgs e )
        {
            // check if bitmap is valid
            if (m_bmpBitmap == null)
            {// create first bitmap
                m_bmpBitmap = new Bitmap( this.ClientSize.Width, this.ClientSize.Height );
            }
            else
            {// check resize
                if ((m_bmpBitmap.Width != this.ClientSize.Width) || 
                    (m_bmpBitmap.Height != this.ClientSize.Height))
                {// create new bitmap
                    m_bmpBitmap = new Bitmap( this.ClientSize.Width, this.ClientSize.Height );
                }
            }

            // create new graphic for backbuffer
            Graphics g = Graphics.FromImage( m_bmpBitmap );

            // create eventargs for teechart
            PaintEventArgs evtPaintArgs = new PaintEventArgs( g, new Rectangle( 0, 0, m_bmpBitmap.Width, m_bmpBitmap.Height ) );

            // call base class
            base.OnPaint( evtPaintArgs );

            // draw image
            e.Graphics.DrawImage( m_bmpBitmap, 0, 0 );
        }
    }

}


Posted: Mon Mar 13, 2006 2:30 pm
by narcis
Hi VESCON,

Thanks for reporting. We have been able to reproduce the problem here and fixed it for the next maintenance release.