Поскольку VBScript не поддерживает наследование, можно получить / установить значения для подклассифицированных параметров:
<%
Set ChartDict = CreateObject("Scripting.Dictionary")
Dim ChartData: Set ChartData = new ChartDataClass
With ChartData
.Essential = 10
.Lifestyle = 40
.Spending = 30
' .Average is calcualted
.ColorScheme("Default") ' sets chart colors
End With
ChartDict.Add "Chart1", ChartData ' add chartData object to dictionary
'''''''''''''''''''''''''''''''''''''
'from using ChartData.ColorScheme("Default"), I want to use ChartData.ChartColors.{OuterLeft, OuterFill, OuterRight, etc...}
'*****************************************************************************
'
' Description:
' An ASP class to
' - create a charts class that contains all required parameters
' - for use with essential, lifestyle and spending gauge data sets
'
'*****************************************************************************
Class ChartDataClass
Public Essential
Public Lifestyle
Public Spending
Dim ChartColors
' automatically calculates the average of the three main values
Public Property Get Average
Average = Round((Essential + Lifestyle + Spending) / 3, 2)
End Property
' setting colors
Public Sub ColorScheme(ByVal SchemeName)
Set ChartColors = New ChartColorsClass
Select Case SchemeName
Case LCase("default")
With ChartColors
.OuterLeft = ""
.OuterFill = ""
.OuterRight = ""
.OuterRight = ""
.InnerLeft = "#3180B8"
.InnerFill = "#DADADA"
End With
End Select
Response.Write("<br>SchemeName: " + SchemeName)
Response.Write("<br>ChartColors.InnerLeft: " + ChartColors.InnerLeft)
End Sub
End Class
'*****************************************************************************
'
' Description:
' An ASP class to
' - contain color parameters
' - for use with essential, lifestyle and spending gauge data sets
'
'*****************************************************************************
Class ChartColorsClass
Public OuterLeft
Public OuterFill
Public OuterRight
Public InnerLeft
Public InnerFill
End Class
%>
Я хотел бы установить цветовую схему с помощью ChartData.ColorScheme("Default")
, я хочу использовать наборзначения ChartData.ChartColors.{OuterLeft, OuterFill, OuterRight, etc...}
Я мог бы просто установить более длинные свойства имени:
Public ColorOuterLeft, ColorOuterFill, ColorOuterRight, ColorInnerLeft, ColorInnerFill
.
Другие опции?