Just a little Demo, how to work with the new RC6.cChart-Class (requiring an RC6-version >= 6.0.3).
This Class follows a somewhat different pattern, compared to other Chart-Controls -
because it supports a "virtual concept" which:
- doesn't define the Chart-behaviour (or Type) as much via Properties
- but via OwnerDraw-Events instead
To "catch" these Events (to draw your own "ChartType"):
- you have to define your own Class (per ChartType)
- and in this Class, you will receive the OwnerDraw-Events
Example for such a UserDefined CharType-Class
(taken from the zipped example below, responsible for rendering the chart at the right-hand-side of the following ScreenShot):
Here a ScreenShot:
![]()
Here is the zipped Demo-Code, which produced the above output:
ChartPlot.zip
Have fun,
Olaf
This Class follows a somewhat different pattern, compared to other Chart-Controls -
because it supports a "virtual concept" which:
- doesn't define the Chart-behaviour (or Type) as much via Properties
- but via OwnerDraw-Events instead
To "catch" these Events (to draw your own "ChartType"):
- you have to define your own Class (per ChartType)
- and in this Class, you will receive the OwnerDraw-Events
Example for such a UserDefined CharType-Class
(taken from the zipped example below, responsible for rendering the chart at the right-hand-side of the following ScreenShot):
Code:
Option Explicit
Public WithEvents Chart As cChart
Private Sub Class_Initialize()
Set Chart = New_c.Chart
End Sub
'**** Class-specific Implementation of the Chart-Events *****
Private Sub Chart_DrawChartBackGroundAndTitle(CC As cCairoContext, ByVal Title As String)
CC.Paint 1, Cairo.CreateSolidPatternLng(vbWhite)
CC.SelectFont "Times New Roman", 13, &H222222, True, True
CC.DrawText 0, 0, CC.Surface.Width, 50, Title, True, vbCenter, 3, True
End Sub
Private Sub Chart_OverrideAxisProps(Axis As cChartAxis, ByVal CurrentMin As Double, ByVal CurrentMax As Double, ByVal CurrentTickIntervals As Long)
If Axis.Name = "X" Then Axis.TickIntervals = 10
End Sub
Private Sub Chart_DrawSingleTickForAxis(Axis As cChartAxis, CC As cCairoContext, ByVal TickValue, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long)
Select Case UCase$(Axis.Name)
Case "X"
CC.DrawLine x, y, x, y + dy + 4, True, 1, vbRed, 0.5
Axis.DrawTickText CC, x, y + 6, Format$(TickValue, "0.00")
Case "Y"
CC.DrawLine x - 4, y, x + dx, y, True, 1, vbBlue, 0.5
Axis.DrawTickText CC, x - 4, y, Format$(TickValue, "0.00")
End Select
End Sub
Private Sub Chart_DrawData(CC As cCairoContext, DataArr() As Variant, ByVal dx As Long, ByVal dy As Long)
Dim PolyArr As cArrayList
Set PolyArr = Chart.GetAxisScaledPolyArrXY(DataArr, Chart.AxisCol("X"), Chart.AxisCol("Y"))
CC.SetLineWidth 2
CC.PolygonPtr PolyArr.DataPtr, PolyArr.Count \ 2, False, splNormal, True, True
CC.Stroke , Cairo.CreateSolidPatternLng(vbGreen)
End Sub

Here is the zipped Demo-Code, which produced the above output:
ChartPlot.zip
Have fun,
Olaf