-
Notifications
You must be signed in to change notification settings - Fork 7
/
ChartingDemo.bbj
128 lines (104 loc) · 4.45 KB
/
ChartingDemo.bbj
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
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <eu@basis.com>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientAddRangeChartModel
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientAddRangeSelectionModel
use ::BBjGridExWidget/BBjGridExWidgetContextMenu.bbj::BBjGridContextMenuItem
use ::BBjGridExWidget/Demo/assets/Utilities.bbj::BBjGridExWidgetDemoUtilities
use com.basiscomponents.db.ResultSet
use com.basiscomponents.bc.SqlQueryBC
use java.util.ArrayList
use java.util.Collections
use java.util.Random
? 'HIDE'
BBjGridExWidgetDemoUtilities.nagAboutLicense()
declare auto BBjTopLevelWindow wnd!
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"BBj Grid Range Selection Demo")
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize")
onRandomChart! = wnd!.addButton(99,10,10,150,25,"Build Random Chart")
onRandomChart!.setCallback(BBjAPI.ON_BUTTON_PUSH,"onRandomChart")
gosub main
process_events
rem /**
rem * Retrive the data from the database and configure the grid
rem */
main:
declare BBjGridExWidget grid!
declare SqlQueryBC sbc!
declare ResultSet rs!
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT ARTIST , MUSICTYPE , COST , RETAIL , PLAYINGTIME FROM CDINVENTORY")
grid! = new BBjGridExWidget(wnd!,101, 0 , 50 , 800 , 550)
REM we start by enabling the charts feature
grid!.getOptions().setEnableCharts(1)
REM Set to true to enable Range Selection
grid!.getOptions().setEnableRangeSelection(1)
REM Allow users to move between cells using arrow keys instead of rows
grid!.getOptions().setNavigationBehavior(grid!.GRID_NAVIGATION_BEHAVIOUR_NEXT_CELL())
REM Disable row selection on row click
grid!.getOptions().setSuppressRowClickSelection(1)
REM Enable User Charts (allow uses to create charts by selecting a range)
grid!.getContextMenu().addItem(BBjGridContextMenuItem.CHART_RANGE())
REM Here we add a range selection to the grid by defining the columns which are included
REM in the range and the start and end row's index/id
declare BBjGridExWidgetClientAddRangeChartModel chart!
rem /**
rem * In Order to create a chart , we need to setup an addRangeChartModel.
rem * The models requires the chart type to create and a range selection model
rem *
rem * Note how we are using a bounded range selection in this demo. Ranges are normally bounded by a start and end row.
rem * However it is also possible to define a range unbounded by rows (ie to contain all rows).
rem * For an unbounded range, do not provided start or end row positions.
rem */
chart! = new BBjGridExWidgetClientAddRangeChartModel()
chart!.setRangeSelection(grid!.addRangeSelection("MUSICTYPE,COST" , 0 , 8))
chart!.setType(BBjGridExWidgetClientAddRangeChartModel.TYPE_GROUPEDCOLUMN())
chart!.setAggregate(1)
grid!.addRangeChart(chart!)
rem /**
rem * You can add / remove items to the chart toolbar
rem *
rem * @see BBjGridExWidget.CAHRT_TOOLBAR_SETTINGS()
rem * @see BBjGridExWidget.CAHRT_TOOLBAR_DATA()
rem * @see BBjGridExWidget.CAHRT_TOOLBAR_FORMAT()
rem * @see BBjGridExWidget.CAHRT_TOOLBAR_DOWNLOAD()
rem */
grid!.addChartToolbarItem(BBjGridExWidget.CAHRT_TOOLBAR_DOWNLOAD())
grid!.setFitToGrid()
grid!.getSidebar().setHiddenByDefault(1)
grid!.setData(rs!)
REM align columns of type number to the right to get better presentation
grid!.getColumn("COST").setAlignment(BBjGridExWidget.GRID_ALIGN_RIGHT() , 1)
grid!.getColumn("RETAIL").setAlignment(BBjGridExWidget.GRID_ALIGN_RIGHT() , 1)
grid!.getColumn("PLAYINGTIME").setAlignment(BBjGridExWidget.GRID_ALIGN_RIGHT() , 1)
return
rem /**
rem * Add a random chart model
rem */
onRandomChart:
REM clear all charts
grid!.clearChart()
chart!.setRangeSelection(grid!.addRangeSelection("MUSICTYPE,COST" , rnd(20) , rnd(20)))
grid!.addRangeChart(chart!)
return
rem /**
rem * Listen to the BBjTopLevelWindow resize events and
rem * resize the grid to fill the available space.
rem */
resize:
ev! = BBjAPI().getLastEvent()
w=ev!.getWidth()
h=ev!.getHeight()
grid!.setSize(w,h - 50)
return
rem /**
rem * Close the demo
rem */
byebye:
bye