-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
62 lines (51 loc) · 2.28 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
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Namespace MarkerAndCheckbox
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
chart.DataSource = CreateChartData()
chart.SeriesDataMember = "Month"
chart.SeriesTemplate.ArgumentDataMember = "Section"
chart.SeriesTemplate.ValueDataMembers.AddRange(New String() { "Value" })
chart.SeriesTemplate.View = New StackedBarSeriesView()
End Sub
Private Function CreateChartData() As DataTable
Dim table As New DataTable("Table1")
table.Columns.Add("Month", GetType(String))
table.Columns.Add("Section", GetType(String))
table.Columns.Add("Value", GetType(Int32))
table.Rows.Add(New Object() { "Jan", "Section1", 10 })
table.Rows.Add(New Object() { "Jan", "Section2", 20 })
table.Rows.Add(New Object() { "Feb", "Section1", 20 })
table.Rows.Add(New Object() { "Feb", "Section2", 30 })
table.Rows.Add(New Object() { "March", "Section1", 15 })
table.Rows.Add(New Object() { "March", "Section2", 25 })
Return table
End Function
Private Sub chart_CustomDrawSeries(ByVal sender As Object, ByVal e As CustomDrawSeriesEventArgs) Handles chart.CustomDrawSeries
Dim lmi As New Bitmap(33, 15)
Dim g As Graphics = Graphics.FromImage(lmi)
g.FillRectangle(New SolidBrush(e.SeriesDrawOptions.Color), New Rectangle(0, 0, 17, 15))
g.DrawRectangle(New Pen(e.SeriesDrawOptions.Color), New Rectangle(18, 0, 14, 14))
If e.Series.CheckedInLegend Then
g.DrawLines(New Pen(e.SeriesDrawOptions.Color, 2), New Point() { _
New Point(21, 6), _
New Point(25, 10), _
New Point(29, 3) _
})
End If
e.LegendMarkerImage = lmi
End Sub
End Class
End Namespace