How to arrange bar Series in asp.net???

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

How to arrange bar Series in asp.net???

Post by Glenn F. Henriksen » Thu Feb 26, 2004 9:54 am

I am using asp.net and Steema TeeChart for .NET v1 to make some reports and display them in IE browser.

But when I am trying to add five groups data into one teechart control, a problem appeared! The every group data bars width are not same and the position is very difficault to control!!!!!

It almost makes me mad,I don't know how to resolve this problem!
Pls help me! Thanks!

My source code is following:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
With tchart1.Chart
.Aspect.View3D = False
.Header.Lines = New String() {"tChart1"}
.Header.Visible = False
.Legend.Visible = False
End With

Dim barSeriesva1 As New Steema.TeeChart.Styles.Bar()
Dim barSeriesva2 As New Steema.TeeChart.Styles.Bar()
Dim barSeriesva3 As New Steema.TeeChart.Styles.Bar()
Dim barSeriesva4 As New Steema.TeeChart.Styles.Bar()
Dim barSeriesva5 As New Steema.TeeChart.Styles.Bar()
Dim barAxis1 As New Steema.TeeChart.Axis(True, False, tchart1.Chart)
Dim barAxis2 As New Steema.TeeChart.Axis(True, False, tchart1.Chart)
Dim barAxis3 As New Steema.TeeChart.Axis(True, False, tchart1.Chart)
Dim barAxis4 As New Steema.TeeChart.Axis(True, False, tchart1.Chart)

With tchart1.Chart.Axes
.Custom.Add(barAxis1)
.Custom.Add(barAxis2)
.Custom.Add(barAxis3)
.Custom.Add(barAxis4)
.Bottom.Title.Text = "Title 1"
.Bottom.Increment = 10
End With

With barAxis1
.Increment = 10
.Title.Text = "Title 2"
End With

With barAxis2
.Title.Text = "Title 3"
End With

With barAxis3
.Title.Text = "Title 4"
End With

With barAxis4
.Title.Text = "Title 5"
End With

With barSeriesva1
.CustomHorizAxis = tchart1.Chart.Axes.Bottom
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA1"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Red
End With

With barSeriesva2
.CustomHorizAxis = barAxis1
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA2"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Green
End With

With barSeriesva3
.CustomHorizAxis = barAxis2
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA3"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.White
End With

With barSeriesva4
.CustomHorizAxis = barAxis3
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA4"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Blue
End With

With barSeriesva5
.CustomHorizAxis = barAxis4
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA5"
.Brush.Color = System.Drawing.Color.Yellow
End With

With tchart1.Chart
.Series.Add(barSeriesva1)
.Series.Add(barSeriesva2)
.Series.Add(barSeriesva3)
.Series.Add(barSeriesva4)
.Series.Add(barSeriesva5)
End With

End Sub

With barAxis1
.Increment = 10
.Title.Text = "Title 2"
End With

With barAxis2
.Title.Text = "Title 3"
End With

With barAxis3
.Title.Text = "Title 4"
End With

With barAxis4
.Title.Text = "Title 5"
End With

With barSeriesva1
.CustomHorizAxis = tchart1.Chart.Axes.Bottom
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA1"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Red
End With

With barSeriesva2
.CustomHorizAxis = barAxis1
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA2"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Green
End With

With barSeriesva3
.CustomHorizAxis = barAxis2
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA3"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.White
End With

With barSeriesva4
.CustomHorizAxis = barAxis3
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA4"
.BarWidthPercent = 90
.Brush.Color = System.Drawing.Color.Blue
End With

With barSeriesva5
.CustomHorizAxis = barAxis4
.FillSampleValues()
.MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
.Title = "VA5"
.Brush.Color = System.Drawing.Color.Yellow
End With

With tchart1.Chart
.Series.Add(barSeriesva1)
.Series.Add(barSeriesva2)
.Series.Add(barSeriesva3)
.Series.Add(barSeriesva4)
.Series.Add(barSeriesva5)
End With
[/quote]

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Fri Feb 27, 2004 1:10 pm

Hello,

There's a few things I see in the code that may be of interest to note.

There are 2 copies of the code in the mail. I've based this answer on the 1st part (up to end sub)

- The width of Bars vary in your code, some at 90%. That may be intentional?
- Each Series is using a different Axis, the axes are all at the same position (0) and that is causing them to overwrite their Labels. Custom axes should, ideally, be at different positions for them to add value to a Chart. Alternatively put all Bars to the same axis
- 2nd effect of different axes for each Series is that the increment scale is different for each one, creating a a non-linear relationship between the overlapping data ....

An option would be to use the same Horizontal Axis:

Code: Select all

    With TChart1.Chart
      .Aspect.View3D = False
      .Header.Lines = New String() {"tChart1"}
      .Header.Visible = False
      .Legend.Visible = False
    End With

    Dim barSeriesva1 As New Steema.TeeChart.Styles.Bar
    Dim barSeriesva2 As New Steema.TeeChart.Styles.Bar
    Dim barSeriesva3 As New Steema.TeeChart.Styles.Bar
    Dim barSeriesva4 As New Steema.TeeChart.Styles.Bar
    Dim barSeriesva5 As New Steema.TeeChart.Styles.Bar

    With barSeriesva1
      .FillSampleValues()
      .MultiBar = Steema.TeeChart.Styles.MultiBars.SideAll
      .Title = "VA1"
      .BarWidthPercent = 90
      .Brush.Color = System.Drawing.Color.Red
    End With

    With barSeriesva2
      .FillSampleValues()
      .Title = "VA2"
      .BarWidthPercent = 90
      .Brush.Color = System.Drawing.Color.Green
    End With

    With barSeriesva3
      .FillSampleValues()
      .Title = "VA3"
      .BarWidthPercent = 90
      .Brush.Color = System.Drawing.Color.White
    End With

    With barSeriesva4
      .FillSampleValues()
      .Title = "VA4"
      .BarWidthPercent = 90
      .Brush.Color = System.Drawing.Color.Blue
    End With

    With barSeriesva5
      .FillSampleValues()
      .BarWidthPercent = 90
      .Title = "VA5"
      .Brush.Color = System.Drawing.Color.Yellow
    End With

    With TChart1.Chart
      .Series.Add(barSeriesva1)
      .Series.Add(barSeriesva2)
      .Series.Add(barSeriesva3)
      .Series.Add(barSeriesva4)
      .Series.Add(barSeriesva5)
    End With
If you prefer to use several Axes I suggest you position them at different locations (in that way Labels and Titles don't overwrite each other)

eg. Putting Axis position to 30%

Code: Select all

    axis = TChart1.Chart.Axes.Custom.Add(barAxis1)
    axis.RelativePosition = 30
But I think the one Axis solution might be nearer to what you need.

Regards,
Marc Meumann
Steema Support

Post Reply