-
Notifications
You must be signed in to change notification settings - Fork 4
/
Combo.jsx
328 lines (323 loc) · 9.81 KB
/
Combo.jsx
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
import React from "react";
import PropTypes from "prop-types";
import XYChart from "../XYChart";
function Combo({ cols, ...rest }) {
return (
<XYChart // width={750} height={400} events={true}
type="combo"
cols={cols}
{...rest}
/>
);
}
const BORDER_SHAPE = PropTypes.shape({
color: PropTypes.oneOfType([PropTypes.string]),
side: PropTypes.oneOf([
"top",
"left",
"bottom",
"right",
"start",
"end",
"horizontal",
"vertical",
"all",
"between",
]),
size: PropTypes.oneOfType([PropTypes.string]),
style: PropTypes.oneOf([
"solid",
"dashed",
"dotted",
"double",
"groove",
"ridge",
"inset",
"outset",
"hidden",
]),
});
Combo.propTypes = {
/** cols from Qlik Data Model to render in the Combo */
cols: PropTypes.array.isRequired,
/** Calc condition for the chart */
calcCondition: PropTypes.shape({
qCond: PropTypes.string,
qMsg: PropTypes.string,
}),
/** Supress zero values in the the chart */
suppressZero: PropTypes.bool,
/** Supress missing values in the the chart */
suppressMissing: PropTypes.bool,
/** Combo Sort Order */
sortOrder: PropTypes.array,
/** Sort Ascending or descending */
sortDirection: PropTypes.string,
/** Combo width */
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/** The height of the Combo */
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/** The amount of margin around the component */
margin: PropTypes.string,
/** The amount of margin around the chart */
chartMargin: PropTypes.object,
/** Size of the Combo */
size: PropTypes.oneOf(["tiny", "small", "medium", "large", "xlarge"]),
// showLabels: PropTypes.oneOf(["top", "none", "inside"]),
showLabels: PropTypes.bool,
// /** Show text on Axis */
showAxisLabels: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(["both", "yAxis", "xAxis", "none"]),
]),
// /** Spacing of Ticks on Y Axis */
// tickSpacing: PropTypes.oneOf(["wide", "normal", "narrow"]),
/** Display Axis and ticks */
hideAxisLine: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(["both", "yAxis", "xAxis", "none"]),
]),
/** Show gridline rows on Axis */
showGridRows: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), // RENAME
/** Show gridline columns on Axis */
showGridColumns: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), // RENAME
/** Show shadow around Combo Chart */
showBoxShadow: PropTypes.bool,
/** Border of the Pie Chart, need desc */
border: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf([
"top",
"left",
"bottom",
"right",
"start",
"end",
"horizontal",
"vertical",
"all",
"between",
"none",
]),
PropTypes.shape({
color: PropTypes.oneOfType([PropTypes.string]),
side: PropTypes.oneOf([
"top",
"left",
"bottom",
"right",
"start",
"end",
"horizontal",
"vertical",
"all",
"between",
]),
size: PropTypes.oneOfType([PropTypes.string]),
style: PropTypes.oneOf([
"solid",
"dashed",
"dotted",
"double",
"groove",
"ridge",
"inset",
"outset",
"hidden",
]),
}),
PropTypes.arrayOf(BORDER_SHAPE),
]),
// /** Border radius of the chart */
borderRadius: PropTypes.string,
// /** Background Color of the chart */
backgroundColor: PropTypes.string,
// /** color scheme of the chart */
colorTheme: PropTypes.oneOfType([
PropTypes.oneOf([
"motor",
"divergent9",
"divergent13",
"eco",
"bio",
"red",
"blue",
"gray",
"pink",
"grape",
"violet",
"indigo",
"blue",
"cyan",
"teal",
"green",
"lime",
"yellow",
"orange",
"base",
"light",
"dark",
]),
PropTypes.array,
]),
// /** Stacked Chart */
// stacked: PropTypes.bool,
/** Stacked Chart */
showAsPercent: PropTypes.bool,
/** RoundNum of the Combo */
roundNum: PropTypes.bool,
/** Decimai precision for RoundNum of the Combo */
precision: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
/** Title of the Combo */
title: PropTypes.string,
/** Sub Title of the Combo */
subTitle: PropTypes.string,
/** Legend of the chart */
showLegend: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(["right", "bottom"]),
]),
/** Show tooltip */
showTooltip: PropTypes.bool,
/** SelectionMethod */
selectionMethod: PropTypes.oneOf(["click", "brush", "none"]),
// /** Maximum Width of the Combo */
// maxWidth: PropTypes.number,
// /** Force supression of Scroll / Overview chart */
// suppressScroll: PropTypes.bool,
// // /** Allow for bushes to be resized on chart */
// // allowZoom: PropTypes.bool, // Descoped to later version
// // /** Ratio of the size 0f the scroll bar (Range 0 - 1) */
// // scrollRatio: PropTypes.number, // Descoped to later version
/** Pddding for each bar */
padding: PropTypes.number,
/** Shape of the symbol to be used on the line. This will apply to all series on the chart */
showPoints: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string, // { symbol : "circle","cross","diamond","square","star","triangle","wye","none", size}
]),
/** Show values as Other */
otherTotalSpec: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.shape({
qOtherLabel: PropTypes.string,
qOtherCount: PropTypes.string,
}),
]),
/** Name of the parent grid area to place the box */
gridArea: PropTypes.string,
useAnimatedAxes: PropTypes.bool,
useAnimatedGrid: PropTypes.bool, // NEW
animationTrajectory: PropTypes.oneOf(["center", "outside", "min", "max"]), // NEW
// autoWidth: PropTypes.bool, // REMOVED
renderHorizontally: PropTypes.bool,
includeZero: PropTypes.bool,
xAxisOrientation: PropTypes.oneOf(["top", "bottom"]),
yAxisOrientation: PropTypes.oneOf(["left", "right"]),
legendLeftRight: PropTypes.oneOf(["left", "right"]),
legendTopBottom: PropTypes.oneOf(["top", "bottom"]),
legendDirection: PropTypes.oneOf(["row", "column"]),
legendShape: PropTypes.string,
backgroundPattern: PropTypes.oneOf(["Lines", "Circles", "Hexagon", "Waves"]),
/** BackgroundSTyle */
/** either : style of one of below or bckgroundFrom and bckgroundTo */
/** Linear */
/** Radial */
/** DarkGreen */
/** LightGreen */
/** OrangeRed */
/** PinkBlue */
/** PinkRed */
/** PurpleOrangle */
/** PurpleRed */
/** PurpleTeal */
/** SteelPurple */
/** TealBlue */
backgroundStyle: PropTypes.object,
multiColor: PropTypes.bool,
events: PropTypes.bool,
/** Use dual Y axis on the the chart */
dualAxis: PropTypes.bool,
// /** Show CrossHair on the chart */
// showCrossHair: PropTypes.bool, // REMOVED
/** Show Horizontal CrossHair on the chart */
showHorizontalCrosshair: PropTypes.bool, // ADDED
/** Show Vertical CrossHair on the chart */
showVerticalCrosshair: PropTypes.bool, // ADDED
/** Horizontal styling of the CrossHair. */
horizontalCrosshairStyle: PropTypes.object,
/** Vertical styling of the CrossHair. */
verticalCrosshairStyle: PropTypes.object,
/** Styling of the Legend labels. */
legendLabelStyle: PropTypes.object,
/** Styling of the Value labels. */
valueLabelStyle: PropTypes.object,
/** Used for tooltip. If true only show the item that hovered over. If fasle show all items for that stack / group */
showClosestItem: PropTypes.bool,
/** Only use one color for the toolyip instead of multi color per item. */
useSingleColor: PropTypes.bool,
/** Snap to X Axis (normally true for bar or combo) */
snapTooltipToDatumX: PropTypes.bool,
/** Snap to Y Axis (normally true for bar or combo) */
snapTooltipToDatumY: PropTypes.bool,
/** Show value only for Tooltip */
valueOnly: PropTypes.bool,
/** Show single line fo text and value for tooltip */
valueWithText: PropTypes.bool,
/** Input format of date supplied from engine (in qText) */
parseDateFormat: PropTypes.string,
/** Reposition the tooltip. */
shiftTooltipTop: PropTypes.number,
/** Reposition the tooltip. */
shiftTooltipLeft: PropTypes.number,
/** Number of ticks for the Grid Rows. Leave blank to auto calculate */
numGridRows: PropTypes.number, // NEW
/** Number of ticks for the Grid Columns. Leave blank to auto calculate */
numGridColumns: PropTypes.number, // NEW
/** Number of ticks for the X Axis. Leave blank to auto calculate */
numDimensionTicks: PropTypes.number,
/** Number of ticks for the Y Axis. Leave blank to auto calculate */
numMeasureTicks: PropTypes.number,
/** Number of ticks for the dual Y Axis. Leave blank to auto calculate */
numMeasureDualTicks: PropTypes.number,
/** Format of dates to be displayed on XAxis. */
formatAxisDate: PropTypes.string,
/** Combo stroke width */
strokeWidth: PropTypes.number,
/** Styles for the X Axis */
xAxisStyles: PropTypes.object,
/** Styles for the Y Axis */
yAxisStyles: PropTypes.object,
/** Styling for the tooltip */
tooltipStyles: PropTypes.object,
};
Combo.defaultProps = {
calcCondition: undefined,
width: "100%",
height: "400px", // 100%
size: "medium",
border: true,
/** Use dual Y axis on the the chart */
dualAxis: false,
colorTheme: null,
sortOrder: [],
sortDirection: "",
showAsPercent: false,
gridArea: null,
xAxisOrientation: "bottom",
yAxisOrientation: "left",
legendLeftRight: "right",
legendTopBottom: "top",
legendDirection: "row",
legendShape: "auto",
parseDateFormat: null,
formatAxisDate: null,
strokeWidth: null,
numDimensionTicks: null,
numMeasureTicks: null,
numMeasureDualTicks: null,
showHorizontalCrosshair: false,
showVerticalCrosshair: false,
showTooltip: true,
};
export default Combo;