Example 49: Adding custom text or drawings to chart
Super 2d/3d Graph Library
exposes 3 events that you can use to add
custom content, text or drawings to the
chart canvas:
-
BeginPaint:
occurs just after clearing the canvas
and before any other drawing is done.
-
AfterPaint:
occurs when chart is completed, before
screen refreshing occurs..
-
ValueClick:
occurs when any value item (bar, line,
point, ...) is clicked by user.
In this sample, a simple
text is added to the chart in the left side
("Custom text added by user").
Steps:
1. Create a new Windows
application project (VB.NET).
2. Add Super 2d/3d Graph
Library to the toolbox pallete and drag it
to Form1.
3. Copy and paste de
following code:
Form Code
Imports Super2d3dGraphLibrary
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Super2d3dGraph1
.SampleChart()
.Style = STYLE2D3D.STYLE2D_PIE
.RefreshChart()
End With
End Sub
Private Sub Super2d3dGraph1_AfterPaint(ByVal g As CustomGraphics) Handles Super2d3dGraph1.AfterPaint
g.RotateTransform(90)
g.TranslateTransform(30, -50)
' Draw text in white first, displaced 2 pixels, to simulate a glow effect
g.DrawString("Custom
Text Added By User", New Font("Arial",
30), New SolidBrush(Color.White), 0, 0)
g.DrawString("Custom
Text Added By User", New Font("Arial",
30), New SolidBrush(Color.Purple), 2, 2)
g.ResetTransform()
End Sub
End Class
Result:

|