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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Windows Forms Chart Plotting Minor Grid Lines with a Log Scale

Thread ID:

Created:

Updated:

Platform:

Replies:

104711 Aug 10,2012 10:27 PM UTC Aug 15,2012 08:37 AM UTC WinForms 1
loading
Tags: Chart
Bruce Barker
Asked On August 10, 2012 10:27 PM UTC

It appears that there are no methods to plot minor grid lines. It can be accomplished using the ChartAreaPaint event. The code below shows an example.
 

Private

Sub _BubblePlot_ChartAreaPaint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles _BubblePlot.ChartAreaPaint

Dim YMin As Double, YMax As Double, XMin As Double, XMax As Double, MaxStop As Double

Dim GridLoc As Double, _Increment As Double

Dim _Pen As Pen = New Pen(System.Drawing.Color.FromArgb(175, 129, 115, 27))

 

If (_BubblePlot.PrimaryYAxis.ValueType = ChartValueType.Logarithmic) Then 'Include Minor Gridlines for Y Axis (Horizontal)

Dim ptLeft As Point, ptRight As Point

YMin = _BubblePlot.PrimaryYAxis.Range.Min

'Min, Max Values in Log Space

YMax = _BubblePlot.PrimaryYAxis.Range.Max

MaxStop = 10 ^ YMax

Dim LogIncrement As Integer = CInt(YMin)

_Increment = 10 ^ YMin

GridLoc = _Increment

'> Draw horizonal lines incrementing by _Increment for each log cycle

Do While GridLoc < MaxStop

For I As Integer = 1 To 9

GridLoc += _Increment

ptLeft = _BubblePlot.ChartArea.GetPointByValue(

New ChartPoint(_BubblePlot.PrimaryXAxis.Range.Min, GridLoc))

ptRight = _BubblePlot.ChartArea.GetPointByValue(

New ChartPoint(_BubblePlot.PrimaryXAxis.Range.Max, GridLoc))

e.Graphics.DrawLine(_Pen, ptLeft.X, ptLeft.Y, ptRight.X, ptRight.Y)

Next

_Increment *= 10

GridLoc = _Increment

Loop

End If

If (_BubblePlot.PrimaryXAxis.ValueType = ChartValueType.Logarithmic) Then 'Include Minor Gridlines for X Axis (Vertical)

Dim ptBottom As Point, ptTop As Point

XMin = _BubblePlot.PrimaryXAxis.Range.Min

'Min, Max Values in Log Space

XMax = _BubblePlot.PrimaryXAxis.Range.Max

MaxStop = 10 ^ YMax

Dim LogIncrement As Integer = CInt(XMin)

_Increment = 10 ^ XMin

GridLoc = _Increment

'> Draw horizonal lines incrementing by _Icrement for each log cycle

Do While GridLoc < MaxStop

For I As Integer = 1 To 9

GridLoc += _Increment

ptBottom = _BubblePlot.ChartArea.GetPointByValue(

New ChartPoint(GridLoc, _BubblePlot.PrimaryYAxis.Range.Min))

ptTop = _BubblePlot.ChartArea.GetPointByValue(

New ChartPoint(GridLoc, _BubblePlot.PrimaryXAxis.Range.Max))

e.Graphics.DrawLine(_Pen, ptBottom.X, ptBottom.Y, ptTop.X, ptTop.Y)

Next

_Increment *= 10

GridLoc = _Increment

Loop

End If

End Sub


Vijayabharathi K [Syncfusion]
Replied On August 15, 2012 08:37 AM UTC

Hi Bruce,

 Thanks for using Syncfusion products.

 We are having properties to plot the minor grid lines in logarithmic type chart. Please refer the below code snippet to achieve this,

 [C#]

this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Logarithmic;

            this.chartControl1.PrimaryXAxis.DrawMinorGrid = true;

            this.chartControl1.PrimaryXAxis.SmallTicksPerInterval = 3;

 Note: Please find the attachment screenshot for minor grid lines.

 Please let us know if any concerns.

 Regards,

Vijayabharathi

 



Screenshot_e83d19d5.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;