This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
64 lines (49 loc) · 2.64 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
Namespace FormatAxisLabels
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Create an empty chart.
Dim chartControl1 As New ChartControl()
' Create a bar series and add points to it.
Dim series1 As New Series("Series 1", ViewType.Bar)
series1.Points.Add(New SeriesPoint(New Date(2009, 1, 1), New Double() { 26.25 }))
series1.Points.Add(New SeriesPoint(New Date(2009, 2, 1), New Double() { 16.52 }))
series1.Points.Add(New SeriesPoint(New Date(2009, 3, 1), New Double() { 22.21 }))
series1.Points.Add(New SeriesPoint(New Date(2009, 4, 1), New Double() { 15.35 }))
series1.Points.Add(New SeriesPoint(New Date(2009, 5, 1), New Double() { 24.15 }))
' Add the series to the chart.
chartControl1.Series.Add(series1)
' Hide the legend (if necessary).
chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False
' Set the scale type for the series' arguments and values.
series1.ArgumentScaleType = ScaleType.DateTime
series1.ValueScaleType = ScaleType.Numerical
' Cast the chart's diagram to the XYDiagram type, to access its axes.
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
' Define the date-time measurement unit, to which the beginning of
' a diagram's gridlines and labels should be aligned.
diagram.AxisX.DateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Day
' Define the detail level for date-time values.
diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month
' Define the custom date-time format (name of a month) for the axis labels.
diagram.AxisX.Label.TextPattern = "{V:MMMM}"
' Since the ValueScaleType of the chart's series is Numerical,
' it is possible to customize the NumericOptions of Y-axis.
diagram.AxisY.Label.TextPattern = "{V:C1}"
' Add a title to the chart (if necessary).
Dim chartTitle1 As New ChartTitle()
chartTitle1.Text = "Axis Scale Types"
chartControl1.Titles.Add(chartTitle1)
' Add the chart to the form.
chartControl1.Dock = DockStyle.Fill
Me.Controls.Add(chartControl1)
End Sub
End Class
End Namespace