FastlineSeries equivalent of Bar Series?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

FastlineSeries equivalent of Bar Series?

Post by asupriya » Tue Jul 21, 2009 6:02 am

I need to plot bit values (0 or 1) of a very large set of shorts, with bit 0 as empty space and bit 1 value as a filled bar. Is there any FastlineSeries equivalent for Bar series to handle such a large amount of data?

If no such series is available, can you please suggest an efficient series that simply plots different colors for the '0' value and '1' values? Its essentially similar to Welcome !\Chart styles\Statistical\Color Grid, but should be able to be used with the Fastlineseries on the same tchart object. It should be able to handle large amount of data.

Thanks,

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: FastlineSeries equivalent of Bar Series?

Post by Yeray » Tue Jul 21, 2009 9:30 am

Hi asupriya,

If i understand well what you are trying to do, isn't the bar series the best looking series for this?

With null values for the "zeros":

Code: Select all

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


        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;

            Bar bar1 = new Bar(tChart1.Chart);
            bar1.BarWidthPercent = 0;
            bar1.Marks.Visible = false;

            for (int i = 0; i < 500; i++)
			{
                if ((i % 20 == 0) || (i % 21 == 0) || (i % 22 == 0))
                {
                    bar1.Add();  //the zeros
                }
                else
                {
                    bar1.Add(1, Color.Blue);  //the ones
                }
			}
        }
Or with points also for the "zeros" as 0,5 to show them and giving a label to show them as a zero instead of 0,5:

Code: Select all

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


        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;

            Bar bar1 = new Bar(tChart1.Chart);
            bar1.BarWidthPercent = 0;
            bar1.Marks.Visible = false;

            for (int i = 0; i < 500; i++)
			{
                if ((i % 20 == 0) || (i % 21 == 0) || (i % 22 == 0))
                {
                    bar1.Add(0.5, "0", Color.Red);  //the zeros
                }
                else
                {
                    bar1.Add(1, "1", Color.Blue);  //the ones
                }
			}

            tChart1.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
        }
Or maybe easier with the volume series:

Code: Select all

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

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;

            Volume volume1 = new Volume(tChart1.Chart);
            volume1.Marks.Visible = false;

            for (int i = 0; i < 500; i++)
            {
                if ((i % 20 == 0) || (i % 21 == 0) || (i % 22 == 0))
                {
                    volume1.Add(0.5, "0", Color.Red);  //the zeros
                }
                else
                {
                    volume1.Add(1, "1", Color.Blue);  //the ones
                }
            }

            tChart1.Axes.Left.SetMinMax(0, 1.5); 
            tChart1.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: FastlineSeries equivalent of Bar Series?

Post by asupriya » Wed Jul 22, 2009 6:04 am

Thanks for the hints. Out of all, volume series has acceptable performance with our data and thus is being used.

One related question is, how can i let the user change the color assignment for 0s and 1s? Users will be using this series in combination with fastlineseries. Legend.click event handles the line color, thickness, etc. editing stuff for fastlineseries. Similarly, when the series type is of volume series type, How can I have something similar editor interface for the volume series so that users can set what color bits with '0' take and what color '1's take.

Thanks for the help.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: FastlineSeries equivalent of Bar Series?

Post by Yeray » Wed Jul 22, 2009 8:36 am

Hi asupriya,

You could have two Color variables and a form with two buttons, one for each color, show the color palette when any of them are pressed, and loop your into your series and changing the ValueColor of all the items with the YValue that matches the pressed button.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: FastlineSeries equivalent of Bar Series?

Post by asupriya » Thu Jul 23, 2009 4:44 am

changing the ValueColor of all the items with the YValue that matches the pressed button
1. That will be extremely slow process as I have more than 18000 values in a series. Is there a better alternate to looping through the YValues?

2. Is there a way to get equivalent result of fastlineseries1.drawAllPoints=False for the volume series?

3. If the volume series is drawn over already existing FastLineSeries on a graph display, How can I make sure that fastlineseries ALWAYS drawn over the volume series so that the line draws are visible over the volume series. There can be more than one fast line series on a graph display. I can use tChart1.Series.Exchange, but it works with only two series at a time. How to make sure that volume series is always at the bottom layer of all other series on a given graph display?

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

Re: FastlineSeries equivalent of Bar Series?

Post by Narcís » Thu Jul 23, 2009 1:22 pm

Hi asupriya,
1. That will be extremely slow process as I have more than 18000 values in a series. Is there a better alternate to looping through the YValues?
Yes, you can do someting like this:

Code: Select all

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

		private Steema.TeeChart.Styles.Volume volume1;

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;
			volume1 = new Steema.TeeChart.Styles.Volume(tChart1.Chart);
			volume1.FillSampleValues();

			tChart1.ClickLegend += new MouseEventHandler(tChart1_ClickLegend);
		}

		void tChart1_ClickLegend(object sender, MouseEventArgs e)
		{	
			int index = tChart1.Legend.Clicked(e.X, e.Y);
			if (index != -1)
			{
				volume1.Colors[index] = Color.Red;
				volume1.Repaint();
			}			
		}
If you are using a FastLine series and a Volume series with same values you can use the same index for both series.
2. Is there a way to get equivalent result of fastlineseries1.drawAllPoints=False for the volume series?
Yes, something similar can be achieved with the DownSampling function demoed at All Features\Welcome !\Functions\Extended\Reducing number of points
3. If the volume series is drawn over already existing FastLineSeries on a graph display, How can I make sure that fastlineseries ALWAYS drawn over the volume series so that the line draws are visible over the volume series. There can be more than one fast line series on a graph display. I can use tChart1.Series.Exchange, but it works with only two series at a time. How to make sure that volume series is always at the bottom layer of all other series on a given graph display?
You can do something as in the code snippet below so that the FastLine series will always be the top-most series in the chart.

Code: Select all

			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			fastLine1.FillSampleValues();
			
			Steema.TeeChart.Styles.Volume volume1 = new Steema.TeeChart.Styles.Volume(tChart1.Chart);
			volume1.FillSampleValues();

			tChart1.Series.Exchange(0, tChart1.Series.Count-1);
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