-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStyleActions.vb
More file actions
114 lines (93 loc) · 4.52 KB
/
StyleActions.vb
File metadata and controls
114 lines (93 loc) · 4.52 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Imports System
Imports System.Drawing
Imports System.Globalization
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Charts
Imports DevExpress.Spreadsheet.Drawings
Imports DevExpress.Utils
Namespace SpreadsheetChartAPISamples
Public NotInheritable Class StyleActions
Private Sub New()
End Sub
Public Shared SetChartStyleAction As Action(Of Workbook) = AddressOf SetChartStyle
Public Shared SetChartFontAction As Action(Of Workbook) = AddressOf SetChartFont
Public Shared CustomSeriesColorAction As Action(Of Workbook) = AddressOf CustomSeriesColor
Public Shared TransparencyAction As Action(Of Workbook) = AddressOf Transparency
Private Shared Sub SetChartStyle(ByVal workbook As Workbook)
#Region "#SetChartStyle"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:D4"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Set the chart style.
chart.Style = ChartStyle.Accent1Dark
#End Region ' #SetChartStyle
End Sub
Private Shared Sub SetChartFont(ByVal workbook As Workbook)
#Region "#SetChartFont"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:D4"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Set the chart font.
chart.Font.Name = "Segoe Script"
chart.Font.Bold = True
chart.Font.Color = Color.Navy
#End Region ' #SetChartFont
End Sub
Private Shared Sub CustomSeriesColor(ByVal workbook As Workbook)
#Region "#CustomSeriesColor"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:D4"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Change the series colors.
chart.Series(0).Fill.SetSolidFill(Color.FromArgb(&H66, &HFF, &H66))
chart.Series(1).Fill.SetSolidFill(Color.FromArgb(&HFF, &HFF, &H33))
#End Region ' #CustomSeriesColor
End Sub
Private Shared Sub Transparency(ByVal workbook As Workbook)
#Region "#Transparency"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask4")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Line, worksheet("B3:D8"))
chart.TopLeftCell = worksheet.Cells("F3")
chart.BottomRightCell = worksheet.Cells("L14")
' Customize the chart area and the plot area appearance.
chart.Fill.SetNoFill()
chart.Outline.SetSolidFill(Color.FromArgb(&H99, &H99, &H99))
chart.PlotArea.Fill.SetSolidFill(Color.FromArgb(&H22, &H99, &H99, &H99))
' Specify the position of the legend.
chart.Legend.Position = LegendPosition.Top
' Use a secondary axis.
chart.Series(1).AxisGroup = AxisGroup.Secondary
' Customize the axis scale and appearance.
Dim axis As Axis = chart.PrimaryAxes(0)
axis.Outline.SetNoFill()
axis.MajorTickMarks = AxisTickMarks.None
axis = chart.PrimaryAxes(1)
axis.Outline.SetNoFill()
axis.MajorTickMarks = AxisTickMarks.None
axis.MajorGridlines.Visible = False
axis.Scaling.AutoMax = False
axis.Scaling.AutoMin = False
axis.Scaling.Max = 1400
axis.Scaling.Min = 0
axis = chart.SecondaryAxes(1)
axis.Outline.SetNoFill()
axis.MajorTickMarks = AxisTickMarks.None
axis.Scaling.AutoMax = False
axis.Scaling.AutoMin = False
axis.Scaling.Max = 390
axis.Scaling.Min = 270
#End Region ' #Transparency
End Sub
End Class
End Namespace