[GB.CHART]

* NEW: some change on pie type (labels around the pie)



git-svn-id: svn://localhost/gambas/trunk@1940 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2009-05-01 21:16:14 +00:00
parent fdabd0c98c
commit 46f31908c6
10 changed files with 124 additions and 14 deletions

View File

@ -73,6 +73,14 @@ Style
p
i
Labels
r
_CLabels
ShowLabels
p
b
_New
m

View File

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0
Title=gb.chart
Startup=FTest2
Startup=FTest
Version=0.0.5
Component=gb.qt
Component=gb.form

View File

@ -28,7 +28,7 @@ Private $iHeight As Integer
Private $oHeaders As _CHeaders
Private $iBackground As Integer = Color.White
Private $iBorder As Boolean = True
Private $bShowLabels As Boolean = False
Property Border As Boolean
Property Background As Integer
@ -51,13 +51,15 @@ Property Count As Integer
Property Proportionnal As Boolean
Property Read Headers As _CHeaders
Property Style As Integer
Property Read Labels As _CLabels
Property ShowLabels As Boolean
Public Sub _New()
id = Now()
Me.CountDataSets = 1
Me.Type = ChartType.Columns
Me.Type = ChartType.Pie
_$ColChart.Add(Me, id)
$oHeaders = New _CHeaders(id)
$oLegend = New _CLegend(id)
@ -356,3 +358,21 @@ Public Sub _Free()
End
Private Function Labels_Read() As _CLabels
End
Private Function ShowLabels_Read() As Boolean
Return $bShowLabels
End
Private Sub ShowLabels_Write(Value As Boolean)
$bShowLabels = Value
End

View File

@ -501,3 +501,10 @@ Public Sub spStep_Change()
DrawingArea1.Refresh
End
Public Sub CheckBox11_Click()
Chart.ShowLabels = Last.Value
DrawingArea1.Refresh
End

View File

@ -4,12 +4,12 @@
MoveScaled(0,0,111,90)
Text = ("")
Arrangement = Arrange.Vertical
Spacing = 5
Spacing = True
Padding = 5
{ HBox1 HBox
MoveScaled(2,2,105,81)
Expand = True
Spacing = 5
Spacing = True
{ DrawingArea1 DrawingArea
MoveScaled(1,4,61,61)
Background = &HFFFFFF&
@ -18,7 +18,7 @@
{ TabStrip1 TabStrip
MoveScaled(63,2,44,79)
Arrangement = Arrange.Vertical
Spacing = 5
Spacing = True
Padding = 5
Count = 4
Index = 0
@ -83,7 +83,7 @@
{ ScrollView1 ScrollView
MoveScaled(1,5,63,18)
Arrangement = Arrange.Row
Spacing = 10
Spacing = True
Padding = 5
ScrollBar = Scroll.Horizontal
}
@ -94,7 +94,7 @@
{ ScrollView2 ScrollView
MoveScaled(1,28,63,18)
Arrangement = Arrange.Row
Spacing = 5
Spacing = True
Padding = 5
}
Index = 2
@ -167,7 +167,7 @@
}
}
{ Frame2 Frame
MoveScaled(3,46,37,23)
MoveScaled(3,46,37,26)
Text = ("Axes")
{ CheckBox3 CheckBox
MoveScaled(2,3,30,3)
@ -198,6 +198,11 @@
MoveScaled(2,8,24,2)
Text = ("X Steps Arrange")
}
{ CheckBox11 CheckBox
MoveScaled(2,22,30,3)
Text = ("Show Data labels")
Value = CheckBox.True
}
}
Index = 3
Text = ("Colors")

View File

@ -0,0 +1,41 @@
' Gambas class file
Property {Font} As Font
Property ForeColor As Integer
Property BackGround As Integer
Private Function Font_Read() As Font
End
Private Sub Font_Write(Value As Font)
End
Private Function ForeColor_Read() As Integer
End
Private Sub ForeColor_Write(Value As Integer)
End
Private Function BackGround_Read() As Integer
End
Private Sub BackGround_Write(Value As Integer)
End

View File

@ -0,0 +1,3 @@
' Gambas class file

View File

@ -101,13 +101,15 @@ Public Sub Draw(bSeries As Boolean)
w = Chart._$ColChart[$sidChart].Width
h = Chart._$ColChart[$sidChart].Height
'draw.Font = Chart.Font
'Get the max text length
'Get the max text length
draw.Font = $oFont
draw.Font.Size = $oFont.Size * Chart._$ColChart[$sidChart]._fProportionnal
For Each s In arsInt
i = draw.TextWidth(s)
If i > cnt Then cnt = i
Next
draw.Font = $oFont
draw.Font.Size = $oFont.Size * Chart._$ColChart[$sidChart]._fProportionnal
Print cnt
SQUARESIZE = draw.TextHeight("T")
Select Case $iPosition

View File

@ -45,7 +45,7 @@ Public Sub Draw(CX As Integer, CY As Integer, CW As Integer, CH As Integer)
fMinVal = Chart._$ColChart[$sidChart].YAxe.MinValue
Endif
Case ChartType.ColumnsStacked
fMaxVal = MTools.GetChartMaxCumulate(Chart._$ColChart[$sidChart])
fMaxVal = MTools.GetChartMaxCumulate($sidChart)
Case ChartType.ColumnsPercent
fMaxVal = 100
End Select

View File

@ -22,6 +22,7 @@ Public Sub Draw(CX As Integer, CY As Integer, CW As Integer, CH As Integer)
Dim fRayon As Float
Dim fMaxRayon As Float
Dim fRayonUnit As Float
Dim tmpX, tmpY As Integer
'Obtenir la valeur cumulée:
For Each s In Chart._$ColChart[$sidChart].Headers
If draw.TextWidth(s) > iMaxTextWidth Then iMaxTextWidth = draw.TextWidth(s)
@ -63,8 +64,31 @@ Public Sub Draw(CX As Integer, CY As Integer, CW As Integer, CH As Integer)
Else
draw.Circle(CX + CW / 2, CY + Ch / 2, fRayon, fCumul, fNewPos)
Endif
tmpX = CX + CW / 2 + Cos(fTextPos) * (fRayon + draw.TextWidth(Chart._$ColChart[$sidChart].Headers[i]) + (30 * Chart._$ColChart[$sidChart]._fProportionnal)) - draw.TextWidth(Chart._$ColChart[$sidChart].Headers[i]) / 2
tmpY = CY + Ch / 2 + Sin(fTextPos - Rad(180)) * (fRayon + draw.TextWidth(Chart._$ColChart[$sidChart].Headers[i]) + 30 * Chart._$ColChart[$sidChart]._fProportionnal)
'<--Text
If Chart._$ColChart[$sidChart].ShowLabels Then
draw.Text(Chart._$ColChart[$sidChart].Headers[i], tmpX, tmpY)
'If tmpY < CY + CH / 2 Then
tmpY += draw.TextHeight(Chart._$ColChart[$sidChart].Headers[i]) / 2
If tmpX < CX + CW / 2 Then
tmpX += draw.TextWidth(Chart._$ColChart[$sidChart].Headers[i]) + 5 * Chart._$ColChart[$sidChart]._fProportionnal
draw.Line(tmpX + 10 * Chart._$ColChart[$sidChart]._fProportionnal, tmpY, tmpX, tmpY)
tmpX += 10 * Chart._$ColChart[$sidChart]._fProportionnal
Else
draw.Line(tmpX - 10 * Chart._$ColChart[$sidChart]._fProportionnal, tmpY, tmpX, tmpY)
tmpX -= 10 * Chart._$ColChart[$sidChart]._fProportionnal
Endif
draw.Line(CX + CW / 2 + Cos(fTextPos) * (fRayon - 10 * Chart._$ColChart[$sidChart]._fProportionnal), CY + Ch / 2 + Sin(fTextPos - Rad(180)) * (fRayon - 10 * Chart._$ColChart[$sidChart]._fProportionnal), tmpX, tmpY)
Endif
'-->
'draw.Text(Chart[i].Label, Cos(fTextPos) * (fRayon) + CX + CW / 2, Sin((fTextPos) - Rad(180)) * (fRayon) + CY + fRayon - draw.Font.Height())
fCumul += Rad(f * frapport)
Next