-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathViewOptionsActions.vb
More file actions
259 lines (215 loc) · 11.5 KB
/
ViewOptionsActions.vb
File metadata and controls
259 lines (215 loc) · 11.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Charts
Imports DevExpress.Spreadsheet.Drawings
Imports System.Drawing
Namespace SpreadsheetChartAPISamples
Public NotInheritable Class ViewOptionsActions
Private Sub New()
End Sub
Public Shared ShowAutomaticMarkersAction As Action(Of Workbook) = AddressOf ShowAutomaticMarkers
Public Shared ShowCustomMarkersAction As Action(Of Workbook) = AddressOf ShowCustomMarkers
Public Shared SetMarkerSizeAction As Action(Of Workbook) = AddressOf SetMarkerSize
Public Shared SmoothLinesAction As Action(Of Workbook) = AddressOf SmoothLines
Public Shared GapWidthAction As Action(Of Workbook) = AddressOf GapWidth
Public Shared VaryColorsByPointAction As Action(Of Workbook) = AddressOf VaryColorsByPoint
Public Shared ChangeChartAppearanceAction As Action(Of Workbook) = AddressOf ChangeChartAppearance
Public Shared ApplyGradientToChartBackgroundAction As Action(Of Workbook) = AddressOf ApplyGradientToChartBackground
Public Shared CustomWallsAndFloorAction As Action(Of Workbook) = AddressOf CustomWallsAndFloor
Private Shared Sub ShowAutomaticMarkers(ByVal workbook As Workbook)
#Region "#ShowAutomaticMarkers"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Line, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Display markers using automatic style.
chart.Series(0).Marker.Symbol = MarkerStyle.Auto
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #ShowAutomaticMarkers
End Sub
Private Shared Sub ShowCustomMarkers(ByVal workbook As Workbook)
#Region "#ShowCustomMarkers"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Line, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Display markers and specify the marker style.
chart.Series(0).Marker.Symbol = MarkerStyle.Circle
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #ShowCustomMarkers
End Sub
Private Shared Sub SetMarkerSize(ByVal workbook As Workbook)
#Region "#SetMarkerSize"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Line, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Display markers and specify the marker style and size.
chart.Series(0).Marker.Symbol = MarkerStyle.Circle
chart.Series(0).Marker.Size = 15
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #SetMarkerSize
End Sub
Private Shared Sub SmoothLines(ByVal workbook As Workbook)
#Region "#SmoothLines"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Turn on curve smoothing.
chart.Series(0).Smooth = True
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #SmoothLines
End Sub
Private Shared Sub GapWidth(ByVal workbook As Workbook)
#Region "#GapWidth"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Set the gap width between data series.
chart.Views(0).GapWidth = 33
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #GapWidth
End Sub
Private Shared Sub VaryColorsByPoint(ByVal workbook As Workbook)
#Region "#VaryColorsByPoint"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #VaryColorsByPoint
End Sub
Private Shared Sub ChangeChartAppearance(ByVal workbook As Workbook)
#Region "#ChangeChartAppearance"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask7")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("N17")
' Add and format the chart title.
chart.Title.SetValue("Сountries with the largest forest area")
chart.Title.Font.Color = Color.FromArgb(&H34, &H5E, &H25)
' Set no fill for the plot area.
chart.PlotArea.Fill.SetNoFill()
' Apply the gradient fill to the chart area.
chart.Fill.SetGradientFill(ShapeGradientType.Linear, Color.FromArgb(&HFD, &HEA, &HDA), Color.FromArgb(&H77, &H93, &H3C))
Dim gradientFill As ShapeGradientFill = chart.Fill.GradientFill
gradientFill.Stops.Add(0.78F, Color.FromArgb(&HB7, &HDE, &HE8))
gradientFill.Angle = 90
' Set the picture fill for the data series.
chart.Series(0).Fill.SetPictureFill("Pictures\PictureFill.png")
' Customize the axis appearance.
Dim axisCollection As AxisCollection = chart.PrimaryAxes
For Each axis As Axis In axisCollection
axis.MajorTickMarks = AxisTickMarks.None
axis.Outline.SetSolidFill(Color.FromArgb(&H34, &H5E, &H25))
axis.Outline.Width = 1.25
Next axis
' Change the scale of the value axis.
Dim valueAxis As Axis = axisCollection(1)
valueAxis.Scaling.AutoMax = False
valueAxis.Scaling.Max = 8000000
valueAxis.Scaling.AutoMin = False
valueAxis.Scaling.Min = 0
' Specify display units for the value axis.
valueAxis.DisplayUnits.UnitType = DisplayUnitType.Thousands
valueAxis.DisplayUnits.ShowLabel = True
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #ChangeChartAppearance
End Sub
Private Shared Sub ApplyGradientToChartBackground(ByVal workbook As Workbook)
#Region "#ApplyGradientToChartBackground"
Dim worksheet As Worksheet = workbook.Worksheets("chartScatter")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ScatterLineMarkers, worksheet("C2:D52"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L17")
' Set the series line color.
chart.Series(0).Outline.SetSolidFill(Color.FromArgb(&HBC, &HCF, &H2))
' Specify the data markers.
Dim markerOptions As Marker = chart.Series(0).Marker
markerOptions.Symbol = MarkerStyle.Diamond
markerOptions.Size = 10
markerOptions.Fill.SetSolidFill(Color.FromArgb(&HBC, &HCF, &H2))
markerOptions.Outline.SetNoFill()
' Set no fill for the plot area.
chart.PlotArea.Fill.SetNoFill()
' Apply the gradient fill to the chart area.
chart.Fill.SetGradientFill(ShapeGradientType.Circle, Color.FromArgb(&HE3, &H48, &H3), Color.FromArgb(&H0, &H32, &H86))
Dim gradientFill As ShapeGradientFill = chart.Fill.GradientFill
gradientFill.FillRect.Left = 0.5
gradientFill.FillRect.Right = 0.5
gradientFill.FillRect.Bottom = 0.5
gradientFill.FillRect.Top = 0.5
' Set the X-axis scale.
Dim axisX As Axis = chart.PrimaryAxes(0)
axisX.Scaling.AutoMax = False
axisX.Scaling.AutoMin = False
axisX.Scaling.Max = 60.0
axisX.Scaling.Min = -60.0
axisX.MajorGridlines.Visible = True
axisX.Visible = False
' Set the Y-axis scale.
Dim axisY As Axis = chart.PrimaryAxes(1)
axisY.Scaling.AutoMax = False
axisY.Scaling.AutoMin = False
axisY.Scaling.Max = 50.0
axisY.Scaling.Min = -50.0
axisY.MajorUnit = 10.0
axisY.Visible = False
' Hide the chart legend.
chart.Legend.Visible = False
#End Region ' #ApplyGradientToChartBackground
End Sub
Private Shared Sub CustomWallsAndFloor(ByVal workbook As Workbook)
#Region "#CustomWallsAndFloor"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Column3DClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
' Specify the series outline.
chart.Series(0).Outline.SetSolidFill(Color.AntiqueWhite)
' Hide the legend.
chart.Legend.Visible = False
' Specify the side wall color.
chart.View3D.SideWall.Fill.SetSolidFill(Color.FromArgb(&HDC, &HFA, &HDD))
' Specify the pattern fill for the back wall.
chart.View3D.BackWall.Fill.SetPatternFill(Color.FromArgb(&H9C, &HFB, &H9F), Color.WhiteSmoke, DevExpress.Spreadsheet.Drawings.ShapeFillPatternType.DiagonalBrick)
Dim floorOptions As SurfaceOptions = chart.View3D.Floor
' Specify the floor color.
floorOptions.Fill.SetSolidFill(Color.FromArgb(&HFA, &HDC, &HF9))
' Specify the floor border.
floorOptions.Outline.SetSolidFill(Color.FromArgb(&HB4, &H95, &HDE))
floorOptions.Outline.Width = 1.25
#End Region ' #CustomWallsAndFloor
End Sub
End Class
End Namespace