Add Series Padding
[GB.CHART2] * NEW: Bar: Style!SeriesPadding allos to define a relative padding between 0 and 2 * NEW: Finish the legend top/bottom display. * BUG: Allow all diferent min values.
This commit is contained in:
parent
6b9af7ca59
commit
044bdc222e
13 changed files with 409 additions and 85 deletions
|
@ -1,5 +1,5 @@
|
|||
# Gambas Project File 3.0
|
||||
Startup=FMain
|
||||
Startup=Form1
|
||||
Version=0.0.3
|
||||
Component=gb.image
|
||||
Component=gb.gui
|
||||
|
|
|
@ -92,7 +92,13 @@ End
|
|||
|
||||
Public Sub SetStyle(sStyle As String)
|
||||
|
||||
|
||||
Select Case (sStyle)
|
||||
Case "Bar"
|
||||
$hStyle = New _ChartStyleBarBasic As "ChartStyleBarBasic"
|
||||
Case "Pie"
|
||||
$hStyle = New _CharStylePie As "ChartStylePie"
|
||||
End Select
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
' Gambas class file
|
||||
|
||||
Private hChart As New Chart
|
||||
Private hChart2 As New Chart
|
||||
Public Sub Form_Open()
|
||||
hChart.Labels = ["Jan", "Fév", "Mar", "Avr", "Mai", "Jui", "Jui", "Aou", "Sep", "Oct", "Nov", "Déc"]
|
||||
|
||||
IniChart2
|
||||
IniChart1
|
||||
End
|
||||
|
||||
|
||||
Private Sub IniChart1()
|
||||
|
||||
hChart.Labels = ["Jan 14", "Fév", "Mar", "Avr", "Mai", "Jui", "Jui", "Aou", "Sep", "Oct", "Nov", "Déc"]
|
||||
hChart.Datas = [ChartDatas("Serie 1", [-16, -12, -6, -1, 5, 14, 29, 22, 13, 3, -6])] ', ChartDatas("Serie 2", [1.0, 2, 3, 4, 5, 3.5]), ChartDatas("Serie 3", [1.0, 2, 3, 4, 5, 3.5])]
|
||||
'hChart.Datas = [ChartDatas("Serie 1", [1.0, 2, 3, 4, 5, 6.5]), ChartDatas("Serie 2", [1.2, 2.3, 3.4, 4.5, 5.6, 3.5]), ChartDatas("Serie 3", [1.3, 2.4, 3.5, 4.6, 5.7, 3.5])]
|
||||
hChart.Border = True
|
||||
|
@ -11,7 +20,7 @@ Public Sub Form_Open()
|
|||
hChart.Legend.Position = Align.Right
|
||||
hChart.Legend.Visible = False
|
||||
hChart.Legend.Title = "Legend"
|
||||
hChart.Title.Text = "This is the Chart Title "
|
||||
hChart.Title.Text = "This is a temperature chart with minus values "
|
||||
hChart.Title.Font.Name = "Times"
|
||||
hChart.Title.Visible = True
|
||||
'AutoScale the fonts via an internal ratio like in a spreadsheet
|
||||
|
@ -24,7 +33,7 @@ Public Sub Form_Open()
|
|||
'But :-)
|
||||
'.Style!Y_AutoScale = True
|
||||
.Style!Y_Step = 10
|
||||
.Style!X_Font = Font["Arial,+2"]
|
||||
.Style!X_Font = Font["Arial"]
|
||||
.Style!Y_Font = Font["Times,+2"]
|
||||
.Style!Padding = 10
|
||||
.Style!ShowValues = True
|
||||
|
@ -36,13 +45,61 @@ Public Sub Form_Open()
|
|||
.Style!BackGround = Color.Lighter(Color.Lighter(Color.Yellow))
|
||||
'.Style!Y_Pattern = "0.0"
|
||||
.Style!InterlinesColor = Color.Lighter(Color.blue)
|
||||
.Style!X_Label = "Activities since jan 2014"
|
||||
.Style!X_Label = "Activities since January 2014"
|
||||
.Style!Y_Label = "Temperature in ° Celcius"
|
||||
End With
|
||||
DrawingArea1.Refresh
|
||||
End
|
||||
Private Sub IniChart2()
|
||||
|
||||
hChart2.Labels = ["Tic", "Tac", "Toe", "Titi", "Toto", "Tata"]
|
||||
'hChart.Datas = [ChartDatas("Serie 1", [-16, -12, -6, -1, 5, 14, 29, 22, 13, 3, -6])] ', ChartDatas("Serie 2", [1.0, 2, 3, 4, 5, 3.5]), ChartDatas("Serie 3", [1.0, 2, 3, 4, 5, 3.5])]
|
||||
hChart2.Datas = [ChartDatas("Serie 1", [1.0, 2, 3, 4, 5, 6.5]), ChartDatas("Serie 2", [1.2, 2.3, 3.4, 4.5, 5.6, 3.5]), ChartDatas("Serie 3", [1.3, 2.4, 3.5, 4.6, 5.7, 3.5])]
|
||||
'hChart.Border = True
|
||||
'hChart.Colors = [Color.Orange]
|
||||
hChart2.SetStyle("Bar")
|
||||
hChart2.Legend.Position = Align.Right
|
||||
hChart2.Legend.Visible = True
|
||||
hChart2.Legend.Title = "Legend"
|
||||
hChart2.Title.Text = "This is a multi series chart "
|
||||
hChart2.Title.Font.Name = "Times"
|
||||
hChart2.Title.Visible = True
|
||||
'AutoScale the fonts via an internal ratio like in a spreadsheet
|
||||
'so the chart always look good even if the device size change
|
||||
hChart2.AutoScale = True
|
||||
'hChart2.Background = Color.Lighter(Color.Yellow)
|
||||
With hChart2
|
||||
'.Style!Y_MaxValue = 8
|
||||
'Style!Y_MinValue = -2
|
||||
'But :-)
|
||||
.Style!Y_AutoScale = True
|
||||
.Style!Y_Step = 1
|
||||
.Style!X_Font = Font["Arial,+2"]
|
||||
.Style!Y_Font = Font["Times,+2"]
|
||||
.Style!Padding = 10
|
||||
'.Style!ShowValues = True
|
||||
.Style!Border = False
|
||||
.Style!ShowArrows = True
|
||||
'.Style!ShowInterlines = True
|
||||
.Style!BarFont = Font["Times, 12"]
|
||||
.Style!BarWidth = 0.9
|
||||
.Style!SeriesPadding = 1
|
||||
'.Style!BackGround = Color.Lighter(Color.Lighter(Color.Yellow))
|
||||
'.Style!Y_Pattern = "0.0"
|
||||
'.Style!InterlinesColor = Color.Lighter(Color.blue)
|
||||
'.Style!X_Label = "Activities since January 2014"
|
||||
'.Style!Y_Label = "Temperature in ° Celcius"
|
||||
End With
|
||||
DrawingArea1.Refresh
|
||||
End
|
||||
|
||||
Public Sub DrawingArea1_Draw()
|
||||
|
||||
hChart.Paint(0, 0, Paint.Width, Paint.Height)
|
||||
hChart2.Paint(0, 0, Paint.Width, Paint.Height)
|
||||
End
|
||||
|
||||
Public Sub DrawingArea2_Draw()
|
||||
|
||||
hChart.Paint(0, 0, Paint.Width, Paint.Height)
|
||||
|
||||
End
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,129,76)
|
||||
Arrangement = Arrange.Vertical
|
||||
MoveScaled(0,0,129,53)
|
||||
Arrangement = Arrange.Horizontal
|
||||
Margin = True
|
||||
{ DrawingArea1 DrawingArea
|
||||
MoveScaled(5,7,112,59)
|
||||
MoveScaled(5,6,54,59)
|
||||
Expand = True
|
||||
}
|
||||
{ DrawingArea2 DrawingArea
|
||||
MoveScaled(69,9,52,56)
|
||||
Expand = True
|
||||
}
|
||||
}
|
||||
|
|
24
comp/src/gb.chart2/.src/FPie.class
Normal file
24
comp/src/gb.chart2/.src/FPie.class
Normal file
|
@ -0,0 +1,24 @@
|
|||
' Gambas class file
|
||||
|
||||
Private hChart As New Chart
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
hChart.Labels = ["Tic", "Tac", "Toe", "Titi", "Toto", "Tata"]
|
||||
|
||||
hChart.Datas = [ChartDatas("Serie 1", [1.0, 2, 3, 4, 5, 6.5])]
|
||||
|
||||
hChart.SetStyle("Pie")
|
||||
|
||||
hChart.Legend.Visible = True
|
||||
With hChart
|
||||
.Style!Border = True
|
||||
.Style!Background = Color.Yellow
|
||||
End With
|
||||
End
|
||||
|
||||
Public Sub DrawingArea1_Draw()
|
||||
|
||||
hChart.Paint(0, 0, Paint.W, Paint.H)
|
||||
|
||||
End
|
11
comp/src/gb.chart2/.src/FPie.form
Normal file
11
comp/src/gb.chart2/.src/FPie.form
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,64,64)
|
||||
Arrangement = Arrange.Horizontal
|
||||
Margin = True
|
||||
{ DrawingArea1 DrawingArea
|
||||
MoveScaled(3,2,57,58)
|
||||
Expand = True
|
||||
}
|
||||
}
|
68
comp/src/gb.chart2/.src/Form1.class
Normal file
68
comp/src/gb.chart2/.src/Form1.class
Normal file
|
@ -0,0 +1,68 @@
|
|||
' Gambas class file
|
||||
|
||||
Private hChart As New Chart
|
||||
Public Sub Form_Open()
|
||||
hChart.Labels = [("January"), ("February"), ("March"), ("April"), ("May"), ("June"), ("July"), ("August"), ("September"), ("October"), ("November"), ("December")]
|
||||
'hChart.Datas = [ChartDatas("Serie 1", [1.0, 2, 3, 4, 5, 6.5]), ChartDatas("Serie 2", [1.0, 2, 3, 4, 5, 3.5]), ChartDatas("Serie 3", [1.0, 2, 3, 4, 5, 3.5])]
|
||||
'hChart.Datas = [ChartDatas("Serie 1", [1.0, 2, 3, 4, 5, 6.5]), ChartDatas("Serie 2", [1.2, 2.3, 3.4, 4.5, 5.6, 3.5]), ChartDatas("Serie 3", [1.3, 2.4, 3.5, 4.6, 5.7, 3.5])]
|
||||
hChart.Datas = [ChartDatas("2009", ReturnTurnover(54000.00, 55999.00)), ChartDatas("2010", ReturnTurnover(55620.00, 57120.00)), ChartDatas("2011", ReturnTurnover(56732.00, 58800.00)), ChartDatas("2012", ReturnTurnover(58434.00, 60000.00)), ChartDatas("2013", ReturnTurnover(59603.00, 61200.00)), ChartDatas("2014", ReturnTurnover(60795.00, 62500.00)), ChartDatas("2015", ReturnTurnover(62618.00, 63600.00)), ChartDatas("2016", ReturnTurnover(63871.00, 64989.00)), ChartDatas("2017", ReturnTurnover(65150.00, 66300.00)), ChartDatas("2018", ReturnTurnover(66450.00, 67700.00))]
|
||||
|
||||
hChart.Border = True
|
||||
hChart.SetStyle("Bar")
|
||||
hChart.Legend.Position = Align.Bottom
|
||||
hChart.Legend.Visible = True
|
||||
hChart.Legend.Title = "Legend"
|
||||
hChart.Title.Text = "Turnover 2009 - 2018"
|
||||
hChart.Title.Font.Name = "Times"
|
||||
hChart.Title.Visible = True
|
||||
'AutoScale the fonts via an internal ratio like in a spreadsheet
|
||||
'so the chart always look good even if the device size change
|
||||
hChart.AutoScale = True
|
||||
With hChart
|
||||
.Style!Y_MaxValue = 69000.00
|
||||
.Style!Y_MinValue = 22000.00
|
||||
'.Style!Y_MaxValue = 7
|
||||
'But :-)
|
||||
'.Style!Y_AutoScale = True
|
||||
.Style!Y_Step = 2000
|
||||
.Style!X_Font = Font["Arial,12"]
|
||||
.Style!Y_Font = Font["arial,8"]
|
||||
.Style!Padding = 10
|
||||
'.Style!ShowValues = True
|
||||
.Style!Border = True
|
||||
'.Style!ShowArrows = True
|
||||
.Style!ShowInterlines = True
|
||||
.Style!BarFont = Font["Times, 12"]
|
||||
.Style!BarWidth = 1
|
||||
.Style!Background = Color.Lighter(Color.Lighter(Color.green))
|
||||
.Style!InterlinesColor = Color.LightGray
|
||||
.Style!SeriesPadding = 1
|
||||
.Style!BarWidth = 0.9
|
||||
'.Style!Y_Pattern = "0.0"
|
||||
End With
|
||||
DrawingArea1.Refresh
|
||||
End
|
||||
|
||||
Private Function ReturnTurnover(fMin As Float, fMax As Float) As Float[]
|
||||
|
||||
Dim aTurnover As New Float[]
|
||||
Dim fRes As Float
|
||||
|
||||
Randomize
|
||||
For i As Integer = 1 To 12
|
||||
fRes = Rnd(fMin, fMax)
|
||||
If i = 2 Then
|
||||
fRes = fRes - ((fRes / 100) * 6)
|
||||
Else If i = 8 Then
|
||||
fRes = fRes - ((fRes / 100) * 50)
|
||||
Endif
|
||||
aTurnover.Add(Round(fRes, -2))
|
||||
Next
|
||||
Return aTurnover
|
||||
|
||||
End
|
||||
|
||||
Public Sub DrawingArea1_Draw()
|
||||
|
||||
hChart.Paint(0, 0, Paint.Width, Paint.Height)
|
||||
End
|
10
comp/src/gb.chart2/.src/Form1.form
Normal file
10
comp/src/gb.chart2/.src/Form1.form
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,64,64)
|
||||
Arrangement = Arrange.Vertical
|
||||
{ DrawingArea1 DrawingArea
|
||||
MoveScaled(2,3,59,59)
|
||||
Expand = True
|
||||
}
|
||||
}
|
79
comp/src/gb.chart2/.src/_CharStylePie.class
Normal file
79
comp/src/gb.chart2/.src/_CharStylePie.class
Normal file
|
@ -0,0 +1,79 @@
|
|||
' Gambas class file
|
||||
|
||||
Inherits _ChartStyle
|
||||
Property Read Symbols As String[] Use $aSymbols
|
||||
|
||||
Private $oLabelsFont As Font
|
||||
|
||||
|
||||
Event Foo
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
$aSymbols = Super.Symbols.Insert(["LabelsFont"])
|
||||
|
||||
'$aSymbols.ReadOnly = True
|
||||
$oLabelsFont = Font["+4"]
|
||||
End
|
||||
|
||||
|
||||
|
||||
Public Sub _get(Symbol As String) As Variant
|
||||
|
||||
Select Case Symbol
|
||||
Case "LabelsFont"
|
||||
Return $oLabelsFont
|
||||
Case Else
|
||||
Return Super[Symbol]
|
||||
|
||||
End Select
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub _put(Value As Variant, Symbol As String)
|
||||
|
||||
|
||||
Select Case Symbol
|
||||
Case "LabelsFont"
|
||||
$oLabelsFont = Value
|
||||
Case Else
|
||||
Super[Symbol] = Value
|
||||
End Select
|
||||
|
||||
End
|
||||
|
||||
Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height As Integer) As Collection
|
||||
|
||||
Dim hChart As Chart = Me._GetParent()
|
||||
Dim hPr As Collection
|
||||
|
||||
|
||||
|
||||
hpr = Super._GetParam(X, Y, Width, Height)
|
||||
|
||||
|
||||
Return hpr
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
||||
Public Sub _PaintBefore(hParam As Collection)
|
||||
|
||||
Super._PaintBefore(hParam)
|
||||
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub _PaintAfter(hParam As Collection)
|
||||
|
||||
Dim hChart As Chart = Me._GetParent()
|
||||
|
||||
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
|
@ -24,51 +24,77 @@ Public Sub _Paint(X As Integer, Y As Integer, Width As Integer, Height As Intege
|
|||
Dim aLabels As String[] = hChart.Labels
|
||||
Dim s As String
|
||||
Dim H As Float
|
||||
Dim f As Float
|
||||
Dim f, j As Float
|
||||
Dim i As Integer
|
||||
|
||||
Paint.font = $oFont
|
||||
Paint.Font.Size *= hChart._fProportionnal
|
||||
For Each s In aLabels
|
||||
|
||||
f = Max(Paint.TextSize(s).W, f)
|
||||
|
||||
Next
|
||||
H = Paint.Font.H
|
||||
|
||||
f = Max(Paint.TextSize($sTitle).W, f)
|
||||
|
||||
Paint.LineWidth = 1 * hChart._fProportionnal
|
||||
Select Case $iPosition
|
||||
Case Align.Top, Align.Bottom
|
||||
hRect.Height = H * 3
|
||||
hRect.W = H * 2 + aLabels.Count * f
|
||||
For Each s In aLabels
|
||||
f += Paint.TextSize(s).W
|
||||
Next
|
||||
|
||||
|
||||
|
||||
hRect.Height = H * 3.5
|
||||
hRect.W = H * 2 + f + aLabels.Max * (H * 1.2 + H / 2) ', Width - H * 2)
|
||||
hRect.X = (Width + -hRect.W) / 2
|
||||
If $iPosition = Align.top Then
|
||||
hRect.Y = Y + H
|
||||
|
||||
Else
|
||||
hRect.Y = Height - hRect.H - H
|
||||
hRect.Y = Y + H
|
||||
|
||||
Else
|
||||
hRect.Y = Height - hRect.H - H
|
||||
Endif
|
||||
Paint.Rectangle(hRect.X, hRect.Y, hRect.W, hRect.H)
|
||||
Paint.Rectangle(hRect.X, hRect.Y, hRect.W, hRect.H)
|
||||
Paint.Stroke
|
||||
hRect.H += H
|
||||
|
||||
If $sTitle Then
|
||||
Paint.Font.Bold = True
|
||||
Paint.DrawText($sTitle, hRect.X, hRect.Y, hRect.W, H, Align.Center)
|
||||
Paint.Font.bold = False
|
||||
|
||||
Endif
|
||||
f = hRect.X + H / 2
|
||||
j = h * 1.5
|
||||
For Each s In aLabels
|
||||
Paint.Rectangle(f, hRect.Y + j, H, H)
|
||||
Paint.Background = hChart.Colors[i Mod hChart.Colors.Count]
|
||||
Paint.Fill(True)
|
||||
Paint.Background = Color.Black
|
||||
Paint.Stroke
|
||||
f += H * 1.2
|
||||
Paint.DrawText(s, f, hRect.Y + j + H / 1.3)
|
||||
f += Paint.TextSize(s).W + H / 2
|
||||
Inc i
|
||||
Next
|
||||
|
||||
Case Else
|
||||
For Each s In aLabels
|
||||
|
||||
f = Max(Paint.TextSize(s).W, f)
|
||||
|
||||
Next
|
||||
f = Max(Paint.TextSize($sTitle).W, f)
|
||||
hRect.H = aLabels.Count * H * 1.2 + H
|
||||
hRect.W = H * 3 + f
|
||||
hRect.Y = (Height - hRect.H) / 2
|
||||
If $sTitle Then hRect.H = hRect.H + H
|
||||
If $sTitle Then hRect.H = hRect.H + H
|
||||
|
||||
If $iPosition = Align.Left Then
|
||||
hRect.X = X + H
|
||||
If $iPosition = Align.Left Then
|
||||
hRect.X = X + H
|
||||
Else
|
||||
hRect.X = Width - hRect.W - H
|
||||
hRect.X = Width - hRect.W - H
|
||||
Endif
|
||||
|
||||
|
||||
Paint.Rectangle(hRect.X, hRect.Y, hRect.W, hRect.H)
|
||||
Paint.Stroke
|
||||
|
||||
|
||||
f = hRect.Y + H * 1.5
|
||||
If $sTitle Then
|
||||
Paint.Font.Bold = True
|
||||
|
@ -76,7 +102,7 @@ Public Sub _Paint(X As Integer, Y As Integer, Width As Integer, Height As Intege
|
|||
Paint.Font.bold = False
|
||||
f = f + H
|
||||
Endif
|
||||
|
||||
|
||||
For Each s In aLabels
|
||||
Paint.Rectangle(hRect.X + H / 2, f - H * 0.8, H, H)
|
||||
Paint.Background = hChart.Colors[i Mod hChart.Colors.Count]
|
||||
|
@ -94,7 +120,7 @@ Public Sub _Paint(X As Integer, Y As Integer, Width As Integer, Height As Intege
|
|||
|
||||
End Select
|
||||
|
||||
Return hRect
|
||||
Return hRect
|
||||
|
||||
|
||||
End
|
||||
|
|
|
@ -24,7 +24,7 @@ Public Sub _get(Symbol As String) As Variant
|
|||
Select Case Symbol
|
||||
Case "Border"
|
||||
Return $bBorder
|
||||
Case "BackGround"
|
||||
Case "Background"
|
||||
Return $iBackGround
|
||||
Case "Padding"
|
||||
Return $fPadding
|
||||
|
@ -40,7 +40,7 @@ Public Sub _put(Value As Variant, Symbol As String)
|
|||
Select Case Symbol
|
||||
Case "Border"
|
||||
$bBorder = Value
|
||||
Case "BackGround"
|
||||
Case "Background"
|
||||
$iBackGround = Value
|
||||
Case "Padding"
|
||||
$fPadding = Value
|
||||
|
@ -53,9 +53,9 @@ End
|
|||
Public Sub _GetParam(X As Integer, Y As Integer, Width As Integer, Height As Integer) As Collection
|
||||
|
||||
Dim hCol As New Collection
|
||||
|
||||
Dim hRect As RectF = RectF(X, Y, Width, Height)
|
||||
hCol!Colors = $aColors
|
||||
|
||||
hCol!Rect = hRect
|
||||
Return hCol
|
||||
End
|
||||
|
||||
|
@ -90,7 +90,11 @@ End
|
|||
|
||||
Public Sub _PaintAfter(hParam As Collection)
|
||||
|
||||
|
||||
If $bBorder Then
|
||||
Paint.LineWidth = 1
|
||||
Paint.Rectangle(hParam!Rect.Left, hParam!Rect.Top, hParam!Rect.W, hParam!Rect.H)
|
||||
Paint.Stroke
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -18,17 +18,18 @@ Private $iInterLinesColor As Integer
|
|||
Private $sYLabel As String
|
||||
Private $sXLabel As String
|
||||
Private $oLabelsFont As Font
|
||||
|
||||
|
||||
Private $fSeriesPadding As Float
|
||||
Private $fAxesWidth As Float = 1.0
|
||||
Event Foo
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
$aSymbols = Super.Symbols.Insert(["X_Font", "X_MaxValue", "X_MinValue", "X_Step"
|
||||
"Y_Font", "Y_MaxValue", "Y_MinValue", "Y_Step", "Y_AutoScale", "ShowArrows", "ShowInterlines", "Y_Label", "X_Label", "LabelsFont"])
|
||||
"Y_Font", "Y_MaxValue", "Y_MinValue", "Y_Step", "Y_AutoScale", "ShowArrows", "ShowInterlines", "Y_Label", "X_Label", "LabelsFont", "SeriesPadding" "AxesWidth"])
|
||||
|
||||
'$aSymbols.ReadOnly = True
|
||||
$oLabelsFont = Font["+4"]
|
||||
$oLabelsFont = Font["+4"]
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
@ -69,6 +70,10 @@ Public Sub _get(Symbol As String) As Variant
|
|||
Return $sXLabel
|
||||
Case "LabelsFont"
|
||||
Return $oLabelsFont
|
||||
Case "SeriesPadding"
|
||||
Return $fSeriesPadding
|
||||
Case "AxesWidth"
|
||||
Return $fAxesWidth
|
||||
Case Else
|
||||
Return Super[Symbol]
|
||||
|
||||
|
@ -105,7 +110,7 @@ Public Sub _put(Value As Variant, Symbol As String)
|
|||
$bShowInterlines = Value
|
||||
Case "Y_Pattern"
|
||||
$sYPattern = Value
|
||||
Case "InterlinesColor"
|
||||
Case "InterlinesColor"
|
||||
$iInterLinesColor = value
|
||||
Case "Y_Label"
|
||||
$sYLabel = Value
|
||||
|
@ -113,6 +118,10 @@ Public Sub _put(Value As Variant, Symbol As String)
|
|||
$sXLabel = Value
|
||||
Case "LabelsFont"
|
||||
$oLabelsFont = Value
|
||||
Case "SeriesPadding"
|
||||
$fSeriesPadding = Value
|
||||
Case "AxesWidth"
|
||||
$fAxesWidth = Value
|
||||
Case Else
|
||||
Super[Symbol] = Value
|
||||
End Select
|
||||
|
@ -128,8 +137,8 @@ Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height A
|
|||
Dim fArrowSize As Float
|
||||
Dim hData As ChartDatas
|
||||
Dim aLabels As String[]
|
||||
|
||||
|
||||
|
||||
|
||||
hpr = Super._GetParam(X, Y, Width, Height)
|
||||
hpr!Padding = Me!Padding * hChart._fProportionnal
|
||||
hpr!Ratio = hChart._fProportionnal
|
||||
|
@ -138,30 +147,30 @@ Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height A
|
|||
|
||||
Paint.Font = Me!X_Font
|
||||
Paint.Font.Size = Paint.Font.Size * hpr!Ratio
|
||||
|
||||
|
||||
|
||||
|
||||
hpr!XTextHeight = Paint.Font.Height
|
||||
hpr!TicLenght = 5 * hpr!Ratio
|
||||
fArrowSize = IIf($bShowArrows, 20, 0) * hpr!Ratio
|
||||
hpr!ArrowSize = fArrowSize
|
||||
|
||||
|
||||
If $sYLabel Then
|
||||
If $sYLabel Then
|
||||
Paint.Font = $oLabelsFont
|
||||
Paint.Font.Size = Paint.Font.Size * hChart._fProportionnal
|
||||
hpr!YLabelWidth = Paint.Font.H + 10
|
||||
Else
|
||||
hpr!YLabelWidth = 0
|
||||
Endif
|
||||
|
||||
|
||||
If $sXLabel Then
|
||||
Paint.Font = $oLabelsFont
|
||||
Paint.Font.Size = Paint.Font.Size * hChart._fProportionnal
|
||||
hpr!XLabelHeight = Paint.Font.H
|
||||
hpr!XLabelHeight = Paint.Font.H
|
||||
Else
|
||||
hpr!XLabelHeight = 0
|
||||
hpr!XLabelHeight = 0
|
||||
Endif
|
||||
|
||||
|
||||
If $fYAutoScale Then
|
||||
For j = 0 To hChart.Datas.Max
|
||||
For i = 0 To hChart.Datas[j].Values.Max
|
||||
|
@ -171,12 +180,12 @@ Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height A
|
|||
Next
|
||||
fmin = Min(fmin, 0)
|
||||
Else
|
||||
fMax = $fYMaxValue
|
||||
fMax = $fYMaxValue
|
||||
fMin = $fYMinValue
|
||||
Endif
|
||||
Paint.Font = $oYFont
|
||||
Paint.Font.Size = Paint.Font.Size * hPr!Ratio
|
||||
hpr!MaxYTextWidth = Paint.TextSize(Format(fMax, $sYPattern)).W
|
||||
Paint.Font = $oYFont
|
||||
Paint.Font.Size = Paint.Font.Size * hPr!Ratio
|
||||
hpr!MaxYTextWidth = Paint.TextSize(Format(fMax, $sYPattern)).W
|
||||
|
||||
hpr!Rect = New RectF
|
||||
With hpr!Rect
|
||||
|
@ -194,19 +203,20 @@ Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height A
|
|||
Next
|
||||
|
||||
hpr!SeriesWidth = hpr!Rect.Width / hChart.Datas.Count
|
||||
hpr!BarWidth = hpr!Rect.Width / j / hChart.Datas.Count
|
||||
hPr!SeriesPadding = (hpr!Rect.Width / j / hChart.Datas.Count) * $fSeriesPadding / 2
|
||||
hpr!BarWidth = ((hpr!SeriesWidth - (hpr!SeriesPadding * 2)) / j)
|
||||
|
||||
|
||||
|
||||
hPr!YMaxValue = fMax
|
||||
hpr!YMinValue = fMin
|
||||
hPr!UnitHeight = hpr!Rect.H / (fMax - fMin)
|
||||
hPr!Center = hpr!Rect.H - Abs(fMin * hpr!UnitHeight)
|
||||
hPr!Center = IIf(fmin < 0, hpr!Rect.H - Abs(fMin * hpr!UnitHeight), hpr!Rect.H)
|
||||
hPr!MaxDatas = j
|
||||
|
||||
|
||||
aLabels = New String[]
|
||||
|
||||
If hChart.Datas.Count = 1 Then
|
||||
|
||||
If hChart.Datas.Count = 1 Then
|
||||
For i = 0 To j
|
||||
If i > hChart.Labels.Max Then
|
||||
aLabels.Add("")
|
||||
|
@ -220,7 +230,7 @@ Public Function _GetParam(X As Integer, Y As Integer, Width As Integer, Height A
|
|||
aLabels.Add(hChart.Datas[i].Text)
|
||||
Next
|
||||
Endif
|
||||
|
||||
|
||||
hpr!Labels = aLabels
|
||||
|
||||
|
||||
|
@ -238,28 +248,40 @@ Public Sub _PaintBefore(hParam As Collection)
|
|||
|
||||
Dim f As Float
|
||||
Dim fBarH, h As Float
|
||||
Dim fCenter As Float = hParam!Rect.Y + hParam!Center
|
||||
|
||||
Super._PaintBefore(hParam)
|
||||
|
||||
|
||||
Paint.AntiAlias = False
|
||||
If $bShowInterlines Then
|
||||
Paint.LineWidth = 1 * hParam!Ratio
|
||||
Paint.LineWidth = 1 '* hParam!Ratio
|
||||
Paint.Background = $iInterLinesColor
|
||||
For f = 0 To $fYMaxValue Step $fYStep
|
||||
|
||||
fBarH = f * hParam!UnitHeight
|
||||
h = hParam!Rect.Bottom - fBarH - Paint.Font.Height / 2
|
||||
h = fCenter - fBarH - Paint.Font.Height / 2
|
||||
If h < hParam!Rect.top Then Break
|
||||
Paint.MoveTo(hParam!Rect.Left, hParam!Rect.Bottom - fBarH)
|
||||
Paint.MoveTo(hParam!Rect.Left, fCenter - fBarH)
|
||||
Paint.RelLineTo(hParam!Rect.W, 0)
|
||||
Paint.Stroke
|
||||
|
||||
|
||||
Next
|
||||
For f = $fYStep DownTo $fYMinValue Step $fYStep
|
||||
|
||||
fBarH = f * hParam!UnitHeight
|
||||
h = fCenter - fBarH - Paint.Font.Height / 2
|
||||
If h < hParam!Rect.top Then Break
|
||||
Paint.MoveTo(hParam!Rect.Left, fCenter - fBarH)
|
||||
Paint.RelLineTo(hParam!Rect.W, 0)
|
||||
Paint.Stroke
|
||||
|
||||
Next
|
||||
|
||||
Endif
|
||||
|
||||
'Draw InterLines Behind
|
||||
|
||||
Paint.AntiAlias = True
|
||||
|
||||
|
||||
|
||||
|
@ -280,22 +302,22 @@ Public Sub _PaintAfter(hParam As Collection)
|
|||
Dim fTextPadding As Float
|
||||
Dim hRect As RectF
|
||||
Dim fCenter As Float = hParam!Rect.Y + hParam!Center
|
||||
|
||||
Dim fStart As Float
|
||||
|
||||
'Draw bars
|
||||
Paint.Font = $oXFont
|
||||
Paint.Font.Size = Paint.Font.Size * hChart._fProportionnal
|
||||
Paint.Background = Color.Black
|
||||
Paint.LineWidth = 2 * hParam!Ratio
|
||||
Paint.LineWidth = $fAxesWidth * hParam!Ratio
|
||||
Paint.MoveTo(hParam!Rect.Left, hParam!Rect.Bottom)
|
||||
Paint.RelLineTo(hParam!Rect.W, 0)
|
||||
|
||||
|
||||
|
||||
f = hParam!Rect.Width / hParam!Labels.Count
|
||||
aLabels = hParam!Labels
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
For i = 0 To aLabels.mAx
|
||||
'Paint.DrawRect(hParam!Rect.Left + hParam!BarWidth * i, hParam!Rect.Bottom + hParam!TicLenght, hParam!BarWidth, hParam!XTextHeight, color.black)
|
||||
Paint.MoveTo(hParam!Rect.Left + f * (i + 1), hParam!Rect.Bottom)
|
||||
|
@ -314,21 +336,23 @@ Public Sub _PaintAfter(hParam As Collection)
|
|||
|
||||
sPattern = $sYPattern
|
||||
fTextPadding = hParam!Ratio * 10
|
||||
For f = 0 To hParam!YMaxValue Step $fYStep
|
||||
fBarH = f * hParam!UnitHeight
|
||||
fStart = IIf(hParam!YMinValue > 0, hParam!YMinValue, 0)
|
||||
For f = fStart To hParam!YMaxValue Step $fYStep
|
||||
|
||||
fBarH = f * hParam!UnitHeight - fStart * hParam!UnitHeight
|
||||
h = fCenter - fBarH - Paint.Font.Height / 2
|
||||
If h < hParam!Rect.top Then Break
|
||||
'If h < hParam!Rect.top Then Break
|
||||
Paint.MoveTo(hParam!Rect.Left, fCenter - fBarH)
|
||||
Paint.RelLineTo(-hParam!TicLenght, 0)
|
||||
Paint.Stroke
|
||||
Paint.DrawText(Format(f, sPattern), hParam!Rect.Left - hParam!TicLenght - hParam!MaxYTextWidth - fTextPadding, fCenter - fBarH - Paint.Font.Height / 2, hParam!MaxYTextWidth,, Align.Right)
|
||||
|
||||
Next
|
||||
|
||||
|
||||
For f = $fYStep DownTo hParam!YMinValue Step $fYStep
|
||||
fBarH = f * hParam!UnitHeight
|
||||
h = fCenter - fBarH - Paint.Font.Height / 2
|
||||
If h < hParam!Rect.top Then Break
|
||||
'If h < hParam!Rect.top Then Break
|
||||
Paint.MoveTo(hParam!Rect.Left, fCenter - fBarH)
|
||||
Paint.RelLineTo(-hParam!TicLenght, 0)
|
||||
Paint.Stroke
|
||||
|
@ -341,9 +365,9 @@ Public Sub _PaintAfter(hParam As Collection)
|
|||
If $sYLabel Then
|
||||
Paint.Save
|
||||
Paint.Font = $oLabelsFont
|
||||
Paint.Font.Size = Paint.Font.Size * hParam!Ratio
|
||||
Paint.Font.Size = Paint.Font.Size * hParam!Ratio
|
||||
hRect = Paint.TextSize($sYLabel)
|
||||
hRect.X = (hParam!Rect.X - hParam!TicLenght - hParam!MaxYTextWidth - fTextPadding) - hRect.W / 2 - hRect.H
|
||||
hRect.X = (hParam!Rect.X - hParam!TicLenght - hParam!MaxYTextWidth - fTextPadding) - hRect.W / 2 - hRect.H
|
||||
hRect.Y = hParam!Rect.Top + (hParam!Rect.H - hRect.H) / 2
|
||||
Paint.Translate(hRect.X + hRect.W / 2, hRect.Y + hRect.H / 2)
|
||||
Paint.Rotate(Rad(90))
|
||||
|
@ -353,9 +377,9 @@ Public Sub _PaintAfter(hParam As Collection)
|
|||
Paint.Restore
|
||||
Endif
|
||||
|
||||
If $sXLabel Then
|
||||
If $sXLabel Then
|
||||
Paint.Font = $oLabelsFont
|
||||
Paint.Font.Size = Paint.Font.Size * hParam!Ratio
|
||||
Paint.Font.Size = Paint.Font.Size * hParam!Ratio
|
||||
H = Paint.TextSize($sXLabel).H
|
||||
|
||||
Paint.DrawText($sXLabel, hParam!Rect.X, hParam!Rect.Bottom + hParam!TicLenght + hParam!XTextHeight + H / 2, hParam!Rect.W, H, Align.Center)
|
||||
|
@ -388,6 +412,7 @@ If $sXLabel Then
|
|||
Paint.Fill
|
||||
Endif
|
||||
|
||||
Super._PaintAfter(hParam)
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ Private $bYShowInterLines As Boolean
|
|||
Private $bShowValues As Boolean
|
||||
Private $fBarWidth As Float = 1.0
|
||||
Private $oBarFont As Font
|
||||
Private $fSeriesPadding As Float
|
||||
Public Sub _new()
|
||||
|
||||
$aSymbols = Super.Symbols.Insert(["Y_ShowInterLines", "ShowValues", "BarWidth", "BarFont"])
|
||||
|
@ -25,6 +26,7 @@ Public Sub _get(Symbol As String) As Variant
|
|||
Return $fBarWidth
|
||||
Case "BarFont"
|
||||
Return $oBarFont
|
||||
|
||||
Case Else
|
||||
Return Super[Symbol]
|
||||
|
||||
|
@ -45,6 +47,7 @@ Public Sub _put(Value As Variant, Symbol As String)
|
|||
$fBarWidth = Min(Max(Value, 0.1), 1.0)
|
||||
Case "BarFont"
|
||||
$oBarFont = Value
|
||||
|
||||
Case Else
|
||||
Super[Symbol] = Value
|
||||
End Select
|
||||
|
@ -62,19 +65,27 @@ Public Sub _PaintContent(hParam As Collection)
|
|||
Dim fBarW As Float = hParam!BarWidth * $fBarWidth
|
||||
Dim fCenter As Float = hParam!Rect.Top + hParam!Center
|
||||
Dim H As Integer
|
||||
Dim fStart As Float
|
||||
Dim f As Float
|
||||
|
||||
Paint.Background = Color.Black
|
||||
fStart = IIf(hParam!YMinValue > 0, hParam!YMinValue, 0)
|
||||
For j = 0 To hChart.Datas.Max
|
||||
fX = hParam!SeriesWidth * J
|
||||
fX = hParam!SeriesWidth * J + hParam!SeriesPadding
|
||||
|
||||
For i = 0 To hChart.Datas[j].Values.Max
|
||||
fBarH = hParam!UnitHeight * hChart.Datas[j].Values[i]
|
||||
f = hChart.Datas[j].Values[i]
|
||||
If f > 0 Then
|
||||
fBarH = Max(hParam!UnitHeight * f - fStart * hParam!UnitHeight, 0)
|
||||
Else
|
||||
fBarH = Min(hParam!UnitHeight * f - fStart * hParam!UnitHeight, 0)
|
||||
Endif
|
||||
|
||||
Paint.FillRect(fX + hParam!Rect.Left + hParam!BarWidth * i + (hParam!BarWidth - fBarW) / 2, fCenter - fBarH, fBarW, fBarH, hChart.Colors[i Mod hChart.Colors.count])
|
||||
|
||||
|
||||
If $bShowValues Then
|
||||
Paint.Font = $oBarFont
|
||||
'Paint.Font.Grade = 1
|
||||
Paint.font.Size = Paint.Font.Size * hParam!Ratio
|
||||
|
||||
If fBarH < 0 Then
|
||||
|
@ -83,10 +94,9 @@ Public Sub _PaintContent(hParam As Collection)
|
|||
H = 0
|
||||
Endif
|
||||
|
||||
Paint.DrawText(hChart.Datas[j].Values[i], fX + hParam!Rect.Left + hParam!BarWidth * i, fCenter - fBarH - Paint.Font.H + H, hParam!BarWidth, Paint.Font.H, Align.center)
|
||||
Paint.DrawText(f, fX + hParam!Rect.Left + hParam!BarWidth * i, fCenter - fBarH - Paint.Font.H + H, hParam!BarWidth, Paint.Font.H, Align.center)
|
||||
|
||||
Endif
|
||||
|
||||
Next
|
||||
Next
|
||||
|
||||
|
|
Loading…
Reference in a new issue