We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Windows Forms Chart Log Scaling

I'm trying to create a bubble chart with a logrithmic scale on the y axis. The data I'm plotting ranges from 0.1 to 1000. When the chart is plotted, the minimum value for the y-axis is always 1 and much of the data plots below the X axis. I've tried setting the PrimaryYAxis.Range.Min = 0.1 but that doesn't do anything.The code is listed below, which first sets up the chart and then loads the data.
 
Thanks in advance.
 

Private Sub SetupChart()

_BubblePlot.ImprovePerformance =

True

_BubblePlot.CalcRegions =

False

ForeColor =

Color.DarkBlue

BackColor =

Color.AliceBlue

Font =

New Font("Trebuchet MS", 8)

_BubblePlot.BackInterior =

New BrushInfo(GradientStyle.None, Color.AliceBlue, Color.AliceBlue)

_BubblePlot.ChartInterior =

New BrushInfo(GradientStyle.ForwardDiagonal, Color.LightSteelBlue, Color.AliceBlue)

_BubblePlot.ChartArea.BackInterior =

New BrushInfo(GradientStyle.None, Color.AliceBlue, Color.AliceBlue)

_BubblePlot.PrimaryXAxis.Title =

"Oerflow Duration (Hours)"

_BubblePlot.PrimaryXAxis.Format =

"F0"

_BubblePlot.PrimaryXAxis.ValueType =

ChartValueType.Double

_BubblePlot.PrimaryYAxis.Title =

"Storm Return Period (Years)"

_BubblePlot.PrimaryYAxis.Format =

"0.#"

_BubblePlot.PrimaryYAxis.ValueType =

ChartValueType.Logarithmic

_BubblePlot.PrimaryYAxis.Origin = 0.1

_BubblePlot.PrimaryXAxis.TitleFont =

New System.Drawing.Font("Verdana", 9.0F, FontStyle.Bold)

_BubblePlot.PrimaryXAxis.TitleColor =

Color.SteelBlue

_BubblePlot.PrimaryYAxis.TitleFont =

New System.Drawing.Font("Verdana", 9.0F, FontStyle.Bold)

_BubblePlot.PrimaryYAxis.TitleColor =

Color.SteelBlue

_BubblePlot.PrimaryXAxis.LabelAlignment =

StringAlignment.Center

_BubblePlot.Titles.Clear()

Dim _Title As Syncfusion.Windows.Forms.Chart.ChartTitle

'>Main Title

_Title =

New Syncfusion.Windows.Forms.Chart.ChartTitle

_Title.Text =

"Bubble Size Reflects Relative Volume of Overflow"

_Title.Font =

New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

_BubblePlot.Titles.Add(_Title)

_Title =

New Syncfusion.Windows.Forms.Chart.ChartTitle

_Title.Text = Globals.Project.CSOBasin

_Title.Font =

New System.Drawing.Font("Verdana", 10.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

_Title.Position =

ChartDock.Bottom

_Title.Alignment =

ChartAlignment.Far

_Title.Margin = 0

_BubblePlot.Titles.Add(_Title)

End Sub

Private Sub LoadChartData()

Dim RarestDuration(Globals.Project.NoCSOs - 1) As Single, RarestStormTr(Globals.Project.NoCSOs - 1) As Single

Dim CSODate(Globals.Project.NoCSOs - 1) As Date, CSODuration(Globals.Project.NoCSOs - 1) As Single, CSOVolume(Globals.Project.NoCSOs - 1) As Single

_BubblePlot.Series.Clear()

Globals.Project.RarestCSOResultsGet(RarestDuration, RarestStormTr)

Globals.Project.CSODataGet(CSODate, CSODuration, CSOVolume)

_series =

New ChartSeries("Bubble", ChartSeriesType.Bubble)

_series.Style.Symbol.Color =

Color.Blue

_BubblePlot.PrimaryYAxis.Range.Min = 0.1

For I As Integer = Globals.Project.NoCSOs - 1 To 0 Step -1

_series.Points.Add(CSODuration(I), RarestStormTr(I), CSOVolume(I))

Next

_BubblePlot.Series.Add(_series)

_BubblePlot.Refresh()

------

End Sub


2 Replies

BB Bruce Barker August 10, 2012 05:26 PM UTC

I solved it. The min and max values for the axis are specified in log space. For a min value of 0.01 and a max of 1000 you specify:
 
PrimaryYAxis.Range.Min=Math.log10(0.01)
PrimaryYAxis.Range.Max=Math.log10(1000.0)
 


VK Vijayabharathi K Syncfusion Team August 15, 2012 01:19 PM UTC

Hi Bruce,

Thanks for using Syncfusion products.

Please let us know if you require any further assistance.

Regards,

Vijayabharathi


Loader.
Live Chat Icon For mobile
Up arrow icon