Example 10: Customizing values positioning and appearance
OK, let's start with the
first of the tutorials about values.
In this example, I will
demonstrate the three different ways of
showing your data over the chart. Note, that
you also may show the data on a table, the
datatable which is shown below the chart if
ShowDataTable is set to True.
These are the properties
that control the appearance of the values:
- ShowValues -- if true, values will appear
over each graphic item (bar, pie, etc.)
- ShowDataTable -- if true, a table with
all data will appear in the lower area of
the chart control
- ValuesAlignment -- controls the
alignment of the numbers on the datatable
- ValuesBackColor -- background color of
labels
- ValuesColor -- text color
- ValuesFont -- font for labels
- ValuesFormat -- string format, like
"0", "N", "p", ... (see Visual Studio help
for string format codes)
- ValuesStyle -- transparent or solid
rounded background
- ValuesLocationStyle -- default, inside
(for bar charts) or smart (avoid label
overlap)
This sample project uses
2 chart objects. One bar chart showing
values inside each bar and a pie
chart using smart ValuesLocationStyle.
Steps:
1. Create a new Windows
application project (VB.NET)
2. Add Super 2d/3d Graph
Library to the toolbox pallete and drag two
charts
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
Dim v As New Super2d3dGraphLibrary.SeriesFactory
Dim x As Single
' Precalculate some random values
For k As Integer = 0 To 8
x = x + Int(Rnd() *
10) + 15
v.AddValue(x)
Next
' Populate the BAR chart
With Super2D3dGraph1
.AutoRefresh = False
.Title = "ValuesLocationStyle = INSIDE"
.Style = STYLE2D3D.STYLE2D_BAR
.ShowDataTable = False
.ShowLegend = False
.ValuesLocationStyle
=
STYLECAPTIONLOCATION.STYLECAPTIONLOCATION_INSIDE
.ValuesBackColor =
Color.Yellow
.ValuesColor =
Color.Blue
End With
' Assign the previous calculated values to
the chart
v.ApplyTo(Super2D3dGraph1)
Super2D3dGraph1.RefreshChart()
' Populate the PIE chart
With Super2D3dGraph2
.AutoRefresh = False
.LicenseeIdentifier = "STAND" ' This is the
demo license
.Title = "ValuesLocationStyle = SMART"
.Style = STYLE2D3D.STYLE2D_PIE
.ShowDataTable = False
.ShowLegend = False
.ValuesLocationStyle
=
STYLECAPTIONLOCATION.STYLECAPTIONLOCATION_INSIDE
.ValuesBackColor =
Color.YellowGreen
.ValuesColor =
Color.Brown
End With
' Assign the previous calculated values to
the chart
v.ApplyTo(Super2D3dGraph2)
Super2D3dGraph2.RefreshChart()
End Sub
End Class
Result:

|