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
| ' Gambas class file
'Uploaded to the Gambas Farm 17/05/2017 '18/05/2017 Added Chart Types and resizable Chart 'Bugs or comments to bugs@cogier.com 'Code altered from this site 'https://novatocodegambas.blogspot.com/2015/09/ejemplo-de-componente-gbchart-graficas.html' 'Updated for QT5 08/12/22
bSkip AS BOOLEAN 'To skip the AllSliders routine while setting up the values bPlusMinus AS BOOLEAN
PUBLIC SUB Form_Open()
Chart.CountDataSets = 2 'How many data sets do you require = 2 Chart.Headers.Values = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] 'Header values Chart.Title.Text = "Percent" 'Chart heading Chart[0].Values = [20, 50, 10, 60, 30] 'Chart initial values Chart[1].Values = [15, 85, 25, 35, 55] 'Chart initial values 'Chart.Legend.Visible = True 'Makes the Legend visible Chart.Legend.Title = "Days" 'Title of chart Chart.Type = ChartType.Lines 'Type of chart Chart.BackGround = Color.Yellow 'Sets the background colour SliderBackGround.value = 16776960 LabelColour.text = Str(16776960) Chart.Border = FALSE 'Gets rid of the border DrawingArea1.Refresh 'Refresh the Drawing area
Slider1.value = Chart[0].Values[0] 'Slider value matches Chart[0].Values Slider2.value = Chart[0].Values[1] 'Slider value matches Chart[0].Values Slider3.value = Chart[0].Values[2] 'Slider value matches Chart[0].Values Slider4.value = Chart[0].Values[3] 'Slider value matches Chart[0].Values Slider5.value = Chart[0].Values[4] 'Slider value matches Chart[0].Values Slider6.value = Chart[1].Values[0] 'Slider value matches Chart[0].Values Slider7.value = Chart[1].Values[1] 'Slider value matches Chart[0].Values Slider8.value = Chart[1].Values[2] 'Slider value matches Chart[0].Values Slider9.value = Chart[1].Values[3] 'Slider value matches Chart[0].Values Slider10.value = Chart[1].Values[4] 'Slider value matches Chart[0].Values bSkip = TRUE 'Now the AllSliders routing can go to work AllSliders_Change 'Run the AllSliders_Change routine
END
PUBLIC SUB AllRadio_Click() 'When a RadiButton is clicked
DIM oObj AS OBJECT 'Object needed
FOR EACH oObj IN HBoxType.Children 'For each of the Children (RadioButtons in this case) in the HBoxType IF oObj.Value = TRUE THEN Chart.Type = Val(oObj.tag) 'If the Value is true (it's been clicked) then set the chart type to the value of the RadioButton's Tag NEXT
DrawingArea1.Refresh 'Refresh the DrawingArea
END
PUBLIC SUB DrawingArea1_Draw() 'Required to draw the chart
DIM siHeight, siWidth AS SHORT 'For Height and Width of the Chart
siHeight = DrawingArea1.Height - 10 'Set the value to 10 less than the DrawingArea Height siWidth = DrawingArea1.Width - 10 'Set the value to 10 less than the DrawingArea Width IF siHeight < 10 THEN siHeight = 10 'Make sure the value is not too small IF siWidth < 10 THEN siWidth = 10 'Make sure the value is not too small
Chart.Height = siHeight 'Set the Chart Height Chart.Width = siWidth 'Set the Chart Width Chart.Draw 'Draw the chart
END
PUBLIC SUB AllSliders_Change() 'If a slider is moved..
IF NOT bSkip THEN RETURN 'Get out of here during inital setup Chart[0].Values = [Slider1.Value, Slider2.Value, Slider3.Value, Slider4.Value, Slider5.Value] 'Set the chart values up based on the slider values Chart[1].values = [Slider6.Value, Slider7.Value, Slider8.Value, Slider9.Value, Slider10.Value] 'Set the chart values up based on the slider values DrawingArea1.Refresh 'Redraw the chart
ValueBox1.value = Slider1.Value 'Set the ValueBox to show slide value ValueBox2.value = Slider2.Value 'Set the ValueBox to show slide value ValueBox3.value = Slider3.Value 'Set the ValueBox to show slide value ValueBox4.value = Slider4.Value 'Set the ValueBox to show slide value ValueBox5.value = Slider5.Value 'Set the ValueBox to show slide value ValueBox6.value = Slider6.Value 'Set the ValueBox to show slide value ValueBox7.value = Slider7.Value 'Set the ValueBox to show slide value ValueBox8.value = Slider8.Value 'Set the ValueBox to show slide value ValueBox9.value = Slider9.Value 'Set the ValueBox to show slide value ValueBox10.value = Slider10.Value 'Set the ValueBox to show slide value
END
PUBLIC SUB SliderBackGround_Change() 'Background slider
Chart.BackGround = SliderBackGround.Value 'Set the Chart background colour to the value of the slider LabelColour.Text = Str(SliderBackGround.Value) 'Put the value in the Label DrawingArea1.Refresh 'Refresh the drawing
END
PUBLIC SUB Overs_Enter() 'If the mouse Enters the 'Overs' panels then..
IF LAST.name = "PanelPlus" THEN bPlusMinus = TRUE 'If the mouse is over the 'Plus' panel then bPlusMinus = True IF LAST.name = "PanelMinus" THEN bPlusMinus = FALSE 'If the mouse is over the 'Minus' panel then bPlusMinus = False Timer1.Start 'Start the timer
END
PUBLIC SUB Overs_Leave() 'If the mouse Leaves the 'Overs' panels then..
Timer1.Stop 'Stop the timer
END
PUBLIC SUB Timer1_Timer() 'Timer
DIM iSlider AS INTEGER = SliderBackGround.Value 'iSlider = the Sliders Value
IF NOT bPlusMinus THEN 'If bPlusMinus is False then.. DEC iSlider 'iSlider = iSlider - 1 IF iSlider < 0 THEN iSlider = 0 'Make sure iSlider stays above -1 Chart.BackGround = iSlider 'Set the Chart Background to iSlider ELSE 'Else (If bPlusMinus is True then..) INC iSlider 'iSlider = iSlider + 1 IF iSlider > 16777215 THEN iSlider = 16777215 'Make sure iSlider stays Below 16777216 Chart.BackGround = iSlider 'Set the Chart Background to iSlider END IF
LabelColour.Text = Str(iSlider) 'Add the colour Value to the Label SliderBackGround.value = iSlider 'Change the Slider Value DrawingArea1.Refresh 'Refresh the Chart
END
|