Regarding Bar chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Regarding Bar chart

Post by amol » Mon Sep 04, 2017 2:07 pm

Hi steema support,

I have a bar chart based on data
.
x axis- 0.0 , 0.4 , 0.9, 0.13 ,0.17 ,0.22, 0.26, 0.30, 0.35, 0.39
Y-Axis- 0.01, 0.78, 0.15, 0.04, 0.01, 0,0,0,0,0
Untitled.png
Untitled.png (22.54 KiB) Viewed 13226 times
In this i have facing overlap and gap issue. Please look this.

code-

SeriesPlotBar = new Bar(tChartGraph.Chart);
SeriesPlotBar.Color = BarAreaLightRed;
SeriesPlotBar.Marks.Visible = false;
SeriesPlotBar.StackGroup = 0;
SeriesPlotBar.BarWidthPercent = 100;

After setting barwidth percentage issue not resolved.
Rest we have soon provide data for our previous posts.

Thanks

Plano research

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: Regarding Bar chart

Post by amol » Mon Sep 04, 2017 2:09 pm

Untitled.png
Untitled.png (11.02 KiB) Viewed 13228 times
More Images

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Regarding Bar chart

Post by Christopher » Tue Sep 05, 2017 9:14 am

Hello,

Using the latest version of TeeChart.dll and the following code:

Code: Select all

    Bar series;
    private void InitializeChart()
    {
      double[] xvalues = new double[] { 0.0, 0.4, 0.9, 0.13, 0.17, 0.22, 0.26, 0.30, 0.35, 0.39 };
      double[] yvalues = new double[] { 0.01, 0.78, 0.15, 0.04, 0.01, 0, 0, 0, 0, 0 };

      series = new Bar(tChart1.Chart);
      series.Add(xvalues, yvalues);
      series.Marks.Visible = false;

      tChart1.Axes.Bottom.SetMinMax(0, 0.5);
      tChart1.Axes.Left.SetMinMax(0, 0.2);
    }

    private void button2_Click(object sender, EventArgs e)
    {
      series.CustomBarWidth = 30;
      //series.BarWidthPercent = 20;
    }
I obtain the following before the button click:
WindowsFormsApplication1_2017-09-05_11-06-24.png
WindowsFormsApplication1_2017-09-05_11-06-24.png (13.71 KiB) Viewed 13215 times
and after the click I obtain:
WindowsFormsApplication1_2017-09-05_11-06-37.png
WindowsFormsApplication1_2017-09-05_11-06-37.png (13.69 KiB) Viewed 13212 times
in this test both CustomBarWidth and BarWidthPercent work as expected. Which version of TeeChart.dll are you using?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: Regarding Bar chart

Post by amol » Thu Sep 07, 2017 1:03 pm

I would like to share that we can not fix the width of bars and my expectation is to combine the bars without gap and without overlap.

I am giving 2 more dataset.

Ist Dataset

X- 0.06,0.18,0.13,0.41,0.53,0.64,0.76,0.87,0.9,1.11
Y- 0.01,0.04,0.09,0.16,0.20,0.19,0.16,0.09,.0.05,.0.0

And the chart image is as below, in this case overlapping is coming. I am using silverlight.
1.png
1.png (14.03 KiB) Viewed 13201 times
IINd Dataset-

X- 0.0, 0.04 ,0.09 ,0.13 ,0.17 ,0.22 ,0.26 ,0.30 ,0.35 ,0.39
Y- 0.01, 0.78, 0.15 , 0.04, 0.01, 0, 0, 0, 0, 0

In This gap is coming-
2.png
2.png (13.73 KiB) Viewed 13203 times
Please provide dome fruitful solution. In Excel we are able to plot expected. And i am using percentage 100%.

Thanks

Plano
Attachments
2.png
2.png (10.41 KiB) Viewed 13203 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Regarding Bar chart

Post by Christopher » Thu Sep 07, 2017 3:25 pm

Hello,

TeeChart has no facility for allowing the Bar series to draw bars of different widths. If you want bars of different widths you can use the Histogram series, e.g.

Code: Select all

    Histogram series;
    private void InitializeChart()
    {
      double[] xvalues = new double[] { 0.0, 0.4, 0.9, 0.13, 0.17, 0.22, 0.26, 0.30, 0.35, 0.39 };
      double[] yvalues = new double[] { 0.01, 0.78, 0.15, 0.04, 0.01, 0, 0, 0, 0, 0 };

      series = new Histogram(tChart1.Chart);
      series.XValues.Order = ValueListOrder.Ascending;

      series.Add(xvalues, yvalues);
      series.Marks.Visible = false;
      series.XValues.Sort();

      tChart1.Axes.Bottom.SetMinMax(0, 0.9);
      tChart1.Axes.Left.SetMinMax(-1, 0.8);
    }
which gives me:
TChart636403942242529566.png
TChart636403942242529566.png (12.64 KiB) Viewed 13200 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply