Page 1 of 1

Stacked100 - Bar

Posted: Fri Dec 05, 2008 2:47 pm
by 10549438
Hello,

at the moment I work with the webcharts stacked100-Bars.
I have different Bars created, that are all Stacked100-Bars.
Sometimes I add values to every Bar-Series (Index 0 .. 6) per Timestamp, which I have created (i.e. EndDate, see below) and sometimes I only add values to a few of my 7 BarSeries (i.e. StartDate, see below).

Code: Select all

        DateTime StartDate = new DateTime(2008, 01, 02, 10, 00, 00);
        DateTime EndDate = new DateTime(2008, 01, 02, 12, 00, 00);

        Chart_Stack = WebChart_Stack.Chart;
        Chart_Stack.Axes.Bottom.Automatic = true;

        bar_stacked[0].Add(StartDate, 4);
        bar_stacked[1].Add(StartDate, 20);
        bar_stacked[5].Add(StartDate, 10);
        bar_stacked[6].Add(StartDate, 2);
        
        bar_stacked[0].Add(EndDate, 40);
        bar_stacked[1].Add(EndDate, 30);
        bar_stacked[2].Add(EndDate, 20);
        bar_stacked[3].Add(EndDate, 20);
        bar_stacked[4].Add(EndDate, 20);
        bar_stacked[5].Add(EndDate, 20);
        bar_stacked[6].Add(EndDate, 20);
The Problem here is that I get Gaps in the WebChart between the Stacked100-Bars and the Values are not drawn correctly.
What can I do to get this working correctly?

Best regards
Michael

Posted: Fri Dec 05, 2008 3:02 pm
by narcis
Hi Michael,

That's because for stacked charts you need to have same number of values in all series. For series where no values exist you can add null points, for example:

Code: Select all

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

		void InitializeChart()
		{
			for (int i = 0; i < 7; i++)
			{
				tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
				((Steema.TeeChart.Styles.Bar)tChart1[i]).MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked100;
			}

			DateTime StartDate = new DateTime(2008, 01, 02, 10, 00, 00);
			DateTime EndDate = new DateTime(2008, 01, 02, 12, 00, 00);

			tChart1[0].Add(StartDate, 4);
			tChart1[1].Add(StartDate, 20);
			tChart1[2].Add(StartDate, 0, Color.Transparent);
			tChart1[3].Add(StartDate, 0, Color.Transparent);
			tChart1[4].Add(StartDate, 0, Color.Transparent);
			tChart1[5].Add(StartDate, 10);
			tChart1[6].Add(StartDate, 2);

			tChart1[0].Add(EndDate, 40);
			tChart1[1].Add(EndDate, 30);
			tChart1[2].Add(EndDate, 20);
			tChart1[3].Add(EndDate, 20);
			tChart1[4].Add(EndDate, 20);
			tChart1[5].Add(EndDate, 20);
			tChart1[6].Add(EndDate, 20); 
		}