Page 1 of 1

Stacked Bar chart issues

Posted: Wed Jun 24, 2009 3:08 pm
by 13045482
Hi
i am uploading an application 'teechart_test." The application basically let user enter no of bars to display in the textbox given and then the user can see respective no of bars in chart. Please see "BAR_ORIGINAL_MAXPOINT.vb" and run it.
-TChart1.Page.MaxPointsPerPage
Following issues-
1. if user puts 1 in textbox and then click no of bars ,then the bar display is not correct.
2. if user puts 2 in textbox and then click no of bar, then it displays 2 bars and bar display is correct- so this ok
3. But if user puts 5 in textbox and then click no of bar, then it displays 6 bars and Thats not OK.
4. But if user puts 7 in textbox and then click no of bar, then it displays 8 bars and that too there is NO SPACE BETWEEN THEM and Thats not OK.
5.But if user puts 8 in textbox and then click no of bar, then it displays 8 bars(which is OK) and BUT there is NO SPACE BETWEEN THEM and Thats not OK.

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 8:35 am
by 10050769
Hello shikha,

I couldn't reproduce your issues in the last update of version 3 of TeeChartFor .Net. Please see this thread and check that with last version works fine your application.

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 9:31 am
by 13045482
great, but the first issue is still there.. that is "if user puts 1 in textbox and then click no of bars ,then the bar display is not correct.That is bar is 1 but it has many levels stacked on it ( that is more than 3 levels/colors stacked on it)"

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 10:44 am
by 10050769
Hi asupriya,


I could reproduce your problem and I have added to the list of Bug Report with number [TF02014262] we will try to fix it for next versions of TeeChart .NET.

Thanks,

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 10:51 am
by 13045482
THANX.. BUT PLEASE LET ME KNOW SOME WORK AROUND FOR THIS FOR NOW AS ITS VERY IMPORTANT.. THANX IN ADVANCE

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 12:08 pm
by narcis
Hi shikha,

You could set bottom axis minimum and maximum values instead, for example:

Code: Select all

TChart1.Axes.Bottom.SetMinMax(0.5, 1.5)
Hope this helps!

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 12:24 pm
by 13045482
thanks, but how would i know what min and max values i need to set in TChart1.Axes.Bottom.SetMinMax function. if i set it the values u have given it doews not behave correctly(ie i dont see expected output for example if enter 1 for no of bars and then press button then now i can see 3 bars instead of 1!).
i have used this code-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TChart1.Axes.Bottom.SetMinMax(0.5, 1.5)
TChart1.Page.MaxPointsPerPage = Val(Me.TextBox1.Text)
End Sub

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 1:03 pm
by narcis
Hi shikha,

You can do something like this:

Code: Select all

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NumBars as Integer = Val(Me.TextBox1.Text)

If (NumBars=1) then
TChart1.Axes.Bottom.SetMinMax(0.5, 1.5)
TChart1.Page.MaxPointsPerPage = 0
Else
TChart1.Axes.Bottom.Automatic=True
TChart1.Page.MaxPointsPerPage = NumBars
End IF
End Sub

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 2:21 pm
by 13045482
great.. but one thing.. in this case the bar width becomes less when entered 1 in textbox.. any resolution for that?

Re: Stacked Bar chart issues

Posted: Thu Jun 25, 2009 2:32 pm
by yeray
Hi shikha,

Try playing with the SetMinMax entered values. Having less distance (for example 0.6, 1.4) I think that the bar should look wider.

Re: Stacked Bar chart issues

Posted: Fri Jun 26, 2009 1:34 pm
by 13045482
Thanks.

But there is more issue-
I want taht the Y axis values should be scaled for each chart based on max Y axis values in taht specific chart.
So for example-
1. when we display just one bar and its value is say 50 than Y axis should be scaled upto 50 + .5
2.when we display just two bars and their value is say 50 and 80 than Y axis should be scaled upto 80 + .5(as 80 is higher)

Please help with this.. many thanks for ur help

Re: Stacked Bar chart issues

Posted: Fri Jun 26, 2009 3:04 pm
by yeray
Hi shikha,

Then you should calculate chart's left axis maximum manually looking into the shown bars and which is the highest. Here is the complete example in csharp:

Code: Select all

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

        private Steema.TeeChart.Styles.Bar bar1, bar2, bar3, bar4;

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;
            tChart1.Aspect.View3D = false;

            bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar3 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar4 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);

            bar1.Marks.Visible = false;
            bar2.Marks.Visible = false;
            bar3.Marks.Visible = false;
            bar4.Marks.Visible = false;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    tChart1[i].Add((j+1)*100);
                }
            }

            bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
            tChart1.Page.MaxPointsPerPage = 2;

            numericUpDown1.Minimum = 1;
            numericUpDown1.Maximum = tChart1[0].Count;
        }
        
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            tChart1.Page.MaxPointsPerPage = (int)numericUpDown1.Value;
            if (tChart1.Page.MaxPointsPerPage == 1)
            {
                tChart1.Axes.Bottom.SetMinMax(-0.25, 0.25);
            }
            else
            {
                tChart1.Axes.Bottom.Automatic = true;
            }

            tChart1.Refresh();

            double tmpMax;
            double MaxVisible = 0;

            for (int ValueIndex = 0; ValueIndex < tChart1[0].Count; ValueIndex++)
            {
                tmpMax = 0;
                if ((ValueIndex <= tChart1[0].LastVisibleIndex) && (ValueIndex >= tChart1[0].FirstVisibleIndex))
                {
                    for (int SeriesIndex = 0; SeriesIndex < tChart1.Series.Count; SeriesIndex++)
                    {
                        tmpMax = tmpMax + tChart1[SeriesIndex].YValues[ValueIndex];
                    }
                    if (tmpMax > MaxVisible)
                    {
                        MaxVisible = tmpMax;
                    }
                }
            }
            tChart1.Axes.Left.AutomaticMaximum = false;
            tChart1.Axes.Left.Maximum = MaxVisible + tChart1.Axes.Left.MaximumOffset;
            tChart1.Header.Text = MaxVisible.ToString();
        }
    }