Page 1 of 1

FastlineSeries equivalent of Bar Series?

Posted: Tue Jul 21, 2009 6:02 am
by 13051032
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,

Re: FastlineSeries equivalent of Bar Series?

Posted: Tue Jul 21, 2009 9:30 am
by yeray
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;
        }

Re: FastlineSeries equivalent of Bar Series?

Posted: Wed Jul 22, 2009 6:04 am
by 13051032
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.

Re: FastlineSeries equivalent of Bar Series?

Posted: Wed Jul 22, 2009 8:36 am
by yeray
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.

Re: FastlineSeries equivalent of Bar Series?

Posted: Thu Jul 23, 2009 4:44 am
by 13051032
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?

Re: FastlineSeries equivalent of Bar Series?

Posted: Thu Jul 23, 2009 1:22 pm
by narcis
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);