@graphenedata/cli 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +8591 -1214
- package/dist/docs/base.md +98 -0
- package/dist/docs/cli.md +22 -0
- package/dist/docs/graphene.md +10 -10
- package/dist/ui/component-utilities/echarts.js +2 -3
- package/dist/ui/component-utilities/formatting.js +3 -11
- package/dist/ui/component-utilities/getSeriesConfig.js +2 -1
- package/dist/ui/components/Area.svelte +188 -151
- package/dist/ui/components/AreaChart.svelte +43 -79
- package/dist/ui/components/Bar.svelte +273 -255
- package/dist/ui/components/BarChart.svelte +58 -112
- package/dist/ui/components/BigValue.svelte +13 -7
- package/dist/ui/components/Chart.svelte +280 -317
- package/dist/ui/components/Column.svelte +102 -113
- package/dist/ui/components/DateRange.svelte +37 -27
- package/dist/ui/components/Dropdown.svelte +77 -57
- package/dist/ui/components/DropdownOption.svelte +10 -7
- package/dist/ui/components/ECharts.svelte +23 -16
- package/dist/ui/components/ErrorChart.svelte +85 -21
- package/dist/ui/components/GrapheneQuery.svelte +7 -3
- package/dist/ui/components/InlineDelta.svelte +53 -34
- package/dist/ui/components/Line.svelte +192 -178
- package/dist/ui/components/LineChart.svelte +53 -96
- package/dist/ui/components/PieChart.svelte +26 -15
- package/dist/ui/components/QueryLoad.svelte +15 -10
- package/dist/ui/components/SortIcon.svelte +5 -1
- package/dist/ui/components/Table.svelte +15 -9
- package/dist/ui/components/TableCell.svelte +30 -17
- package/dist/ui/components/TableGroupRow.svelte +26 -19
- package/dist/ui/components/TableGroupToggle.svelte +9 -6
- package/dist/ui/components/TableHeader.svelte +37 -27
- package/dist/ui/components/TableRow.svelte +30 -20
- package/dist/ui/components/TableSubtotalRow.svelte +16 -9
- package/dist/ui/components/TableTotalRow.svelte +18 -11
- package/dist/ui/components/TextInput.svelte +23 -20
- package/dist/ui/components/_Table.svelte +303 -260
- package/dist/ui/internal/LocalApp.svelte +40 -0
- package/dist/ui/internal/NavSidebar.svelte +27 -30
- package/dist/ui/internal/PageError.svelte +23 -0
- package/dist/ui/internal/checkSocket.ts +48 -0
- package/dist/ui/internal/queryEngine.ts +9 -2
- package/dist/ui/internal/telemetry.ts +1 -0
- package/dist/ui/web.js +5 -55
- package/package.json +9 -10
- package/cli.ts +0 -156
- package/dist/ui/internal/NavSidebarHMR.svelte +0 -8
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {setContext, type Snippet} from 'svelte'
|
|
3
|
+
import {type Writable, writable, get} from 'svelte/store'
|
|
4
4
|
import {propKey, configKey} from '../component-utilities/chartContext.js'
|
|
5
|
-
let props = writable({})
|
|
6
|
-
/** @type {import("svelte/store").Writable<import("echarts").Options>} */
|
|
7
|
-
let config = writable({})
|
|
8
|
-
|
|
9
|
-
setContext(propKey, props)
|
|
10
|
-
setContext(configKey, config)
|
|
11
|
-
|
|
12
5
|
import ECharts from './ECharts.svelte'
|
|
13
6
|
import getColumnSummary from '../component-utilities/getColumnSummary.js'
|
|
14
7
|
import getDistinctValues from '../component-utilities/getDistinctValues.js'
|
|
@@ -26,23 +19,48 @@
|
|
|
26
19
|
import {parseCommaList} from '../component-utilities/inputUtils.ts'
|
|
27
20
|
import {logError} from '../internal/telemetry.ts'
|
|
28
21
|
|
|
22
|
+
interface Props {
|
|
23
|
+
data?: any, chartContext?: any, queryID?: any, x?: any, y?: any, y2?: any, series?: any, size?: any
|
|
24
|
+
tooltipTitle?: any, showAllXAxisLabels?: any, swapXY?: boolean | string, title?: string, subtitle?: string
|
|
25
|
+
chartType?: string, bubble?: boolean, hist?: boolean, boxplot?: boolean, xType?: string
|
|
26
|
+
xAxisTitle?: string, xBaseline?: boolean | string, xTickMarks?: boolean | string
|
|
27
|
+
xGridlines?: boolean | string, xAxisLabels?: boolean | string, sort?: boolean | string, xFmt?: any
|
|
28
|
+
xMin?: any, xMax?: any, yLog?: boolean | string, yType?: string, yLogBase?: number, yAxisTitle?: string
|
|
29
|
+
yBaseline?: boolean | string, yTickMarks?: boolean | string, yGridlines?: boolean | string
|
|
30
|
+
yAxisLabels?: boolean | string, yMin?: any, yMax?: any, yScale?: boolean | string, yFmt?: any
|
|
31
|
+
yAxisColor?: string, y2AxisTitle?: string, y2Baseline?: boolean | string, y2TickMarks?: boolean | string
|
|
32
|
+
y2Gridlines?: boolean | string, y2AxisLabels?: boolean | string, y2Min?: any, y2Max?: any
|
|
33
|
+
y2Scale?: boolean | string, y2Fmt?: any, y2AxisColor?: string, sizeFmt?: any, colorPalette?: string
|
|
34
|
+
legend?: any, echartsOptions?: any, seriesOptions?: any, seriesColors?: any, stackType?: string
|
|
35
|
+
stacked100?: boolean, chartAreaHeight?: any, connectGroup?: string, leftPadding?: any, rightPadding?: any
|
|
36
|
+
xLabelWrap?: boolean | string, children?: Snippet
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Note: renamed from 'props' to 'chartProps' to avoid conflict with $props() rune
|
|
40
|
+
let chartProps = writable({})
|
|
41
|
+
let config: Writable<any> = writable({})
|
|
42
|
+
|
|
43
|
+
setContext(propKey, chartProps)
|
|
44
|
+
setContext(configKey, config)
|
|
45
|
+
|
|
29
46
|
const {theme, resolveColor, resolveColorsObject, resolveColorPalette} = getThemeStores()
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
let {
|
|
49
|
+
data = undefined, chartContext = undefined, queryID = undefined, x = undefined, y = undefined,
|
|
50
|
+
y2 = undefined, series = undefined, size = undefined, tooltipTitle = undefined,
|
|
51
|
+
showAllXAxisLabels = undefined, swapXY = false, title = undefined, subtitle = undefined,
|
|
52
|
+
chartType = 'Chart', bubble = false, hist = false, boxplot = false, xType = undefined,
|
|
53
|
+
xAxisTitle = 'false', xBaseline = true, xTickMarks = false, xGridlines = false, xAxisLabels = true,
|
|
54
|
+
sort = true, xFmt = undefined, xMin = undefined, xMax = undefined, yLog = false, yType = undefined,
|
|
55
|
+
yLogBase = 10, yAxisTitle = 'false', yBaseline = false, yTickMarks = false, yGridlines = true,
|
|
56
|
+
yAxisLabels = true, yMin = undefined, yMax = undefined, yScale = false, yFmt = undefined,
|
|
57
|
+
yAxisColor = 'true', y2AxisTitle = 'false', y2Baseline = false, y2TickMarks = false,
|
|
58
|
+
y2Gridlines = true, y2AxisLabels = true, y2Min = undefined, y2Max = undefined, y2Scale = false,
|
|
59
|
+
y2Fmt = undefined, y2AxisColor = 'true', sizeFmt = undefined, colorPalette = 'default',
|
|
60
|
+
legend = undefined, echartsOptions = undefined, seriesOptions = undefined, seriesColors = undefined,
|
|
61
|
+
stackType = undefined, stacked100 = false, chartAreaHeight = undefined, connectGroup = undefined,
|
|
62
|
+
leftPadding = undefined, rightPadding = undefined, xLabelWrap = false, children,
|
|
63
|
+
}: Props = $props()
|
|
46
64
|
|
|
47
65
|
// This should be reworked to fit better with svelte's reactivity.
|
|
48
66
|
|
|
@@ -54,117 +72,41 @@
|
|
|
54
72
|
// then we throw if the fallback column is now missing.
|
|
55
73
|
|
|
56
74
|
// This is a hack to get around the above
|
|
57
|
-
//
|
|
58
|
-
|
|
75
|
+
// Track whether x/y were initially set (not using fallbacks)
|
|
76
|
+
// These capture the initial values intentionally - they're set once on mount
|
|
77
|
+
// and updated in the effect. Using closure pattern to silence state_referenced_locally warning.
|
|
78
|
+
let ySet = $state((() => y ? true : false)())
|
|
59
79
|
// const y2Set = y2 ? true : false;
|
|
60
|
-
let xSet = x ? true : false
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
let xSet = $state((() => x ? true : false)())
|
|
81
|
+
|
|
82
|
+
// Convert boolean string props to actual booleans
|
|
83
|
+
let swapXY_bool = $derived(toBoolean(swapXY))
|
|
84
|
+
let xBaseline_bool = $derived(toBoolean(xBaseline))
|
|
85
|
+
let xTickMarks_bool = $derived(toBoolean(xTickMarks))
|
|
86
|
+
let xGridlines_bool = $derived(toBoolean(xGridlines))
|
|
87
|
+
let xAxisLabels_bool = $derived(toBoolean(xAxisLabels))
|
|
88
|
+
let sort_bool = $derived(toBoolean(sort))
|
|
89
|
+
let yLog_bool = $derived(toBoolean(yLog))
|
|
90
|
+
let yBaseline_bool = $derived(toBoolean(yBaseline))
|
|
91
|
+
let yTickMarks_bool = $derived(toBoolean(yTickMarks))
|
|
92
|
+
let yGridlines_bool = $derived(toBoolean(yGridlines))
|
|
93
|
+
let yAxisLabels_bool = $derived(toBoolean(yAxisLabels))
|
|
94
|
+
let yScale_bool = $derived(toBoolean(yScale))
|
|
95
|
+
let y2Baseline_bool = $derived(toBoolean(y2Baseline))
|
|
96
|
+
let y2TickMarks_bool = $derived(toBoolean(y2TickMarks))
|
|
97
|
+
let y2Gridlines_bool = $derived(toBoolean(y2Gridlines))
|
|
98
|
+
let y2AxisLabels_bool = $derived(toBoolean(y2AxisLabels))
|
|
99
|
+
let y2Scale_bool = $derived(toBoolean(y2Scale))
|
|
100
|
+
let xLabelWrap_bool = $derived(toBoolean(xLabelWrap))
|
|
101
|
+
|
|
102
|
+
let yAxisColorStore = $derived(resolveColor(yAxisColor))
|
|
103
|
+
let y2AxisColorStore = $derived(resolveColor(y2AxisColor))
|
|
104
|
+
let colorPaletteResolved = $derived(resolveColorPalette(colorPalette))
|
|
105
|
+
let seriesColorsResolved = $derived(resolveColorsObject(seriesColors))
|
|
64
106
|
|
|
65
|
-
// Chart titles:
|
|
66
|
-
export let title = undefined
|
|
67
|
-
export let subtitle = undefined
|
|
68
|
-
|
|
69
|
-
// Chart type:
|
|
70
|
-
export let chartType = 'Chart' // Used to label chart error messages
|
|
71
|
-
export let bubble = false
|
|
72
|
-
export let hist = false
|
|
73
|
-
export let boxplot = false
|
|
74
107
|
let reqCols
|
|
75
108
|
|
|
76
|
-
|
|
77
|
-
export let xType = undefined // category or value
|
|
78
|
-
export let xAxisTitle = 'false' // Default false. If true, use formatTitle(x). Or you can supply a custom string
|
|
79
|
-
export let xBaseline = true
|
|
80
|
-
$: xBaseline = toBoolean(xBaseline)
|
|
81
|
-
export let xTickMarks = false
|
|
82
|
-
$: xTickMarks = toBoolean(xTickMarks)
|
|
83
|
-
export let xGridlines = false
|
|
84
|
-
$: xGridlines = toBoolean(xGridlines)
|
|
85
|
-
export let xAxisLabels = true
|
|
86
|
-
$: xAxisLabels = toBoolean(xAxisLabels)
|
|
87
|
-
export let sort = true // sorts x values in case x is out of order in dataset (e.g., would create line chart that is out of order)
|
|
88
|
-
$: sort = toBoolean(sort)
|
|
89
|
-
export let xFmt = undefined
|
|
90
|
-
export let xMin = undefined
|
|
91
|
-
export let xMax = undefined
|
|
92
|
-
|
|
93
|
-
// Y axis:
|
|
94
|
-
export let yLog = false
|
|
95
|
-
$: yLog = toBoolean(yLog)
|
|
96
|
-
export let yType = yLog === true ? 'log' : 'value' // value or log
|
|
97
|
-
export let yLogBase = 10
|
|
98
|
-
export let yAxisTitle = 'false' // Default false. If true, use formatTitle(x). Or you can supply a custom string
|
|
99
|
-
export let yBaseline = false
|
|
100
|
-
$: yBaseline = toBoolean(yBaseline)
|
|
101
|
-
|
|
102
|
-
export let yTickMarks = false
|
|
103
|
-
$: yTickMarks = toBoolean(yTickMarks)
|
|
104
|
-
export let yGridlines = true
|
|
105
|
-
$: yGridlines = toBoolean(yGridlines)
|
|
106
|
-
export let yAxisLabels = true
|
|
107
|
-
$: yAxisLabels = toBoolean(yAxisLabels)
|
|
108
|
-
|
|
109
|
-
export let yMin = undefined
|
|
110
|
-
export let yMax = undefined
|
|
111
|
-
export let yScale = false
|
|
112
|
-
$: yScale = toBoolean(yScale)
|
|
113
|
-
export let yFmt = undefined
|
|
114
|
-
|
|
115
|
-
export let yAxisColor = 'true'
|
|
116
|
-
$: yAxisColorStore = resolveColor(yAxisColor)
|
|
117
|
-
|
|
118
|
-
// Y2 axis:
|
|
119
|
-
export let y2AxisTitle = 'false' // Default false. If true, use formatTitle(x). Or you can supply a custom string
|
|
120
|
-
export let y2Baseline = false
|
|
121
|
-
$: y2Baseline = toBoolean(y2Baseline)
|
|
122
|
-
export let y2TickMarks = false
|
|
123
|
-
$: y2TickMarks = toBoolean(y2TickMarks)
|
|
124
|
-
export let y2Gridlines = true
|
|
125
|
-
$: y2Gridlines = toBoolean(y2Gridlines)
|
|
126
|
-
export let y2AxisLabels = true
|
|
127
|
-
$: y2AxisLabels = toBoolean(y2AxisLabels)
|
|
128
|
-
export let y2Min = undefined
|
|
129
|
-
export let y2Max = undefined
|
|
130
|
-
export let y2Scale = false
|
|
131
|
-
$: y2Scale = toBoolean(y2Scale)
|
|
132
|
-
export let y2Fmt = undefined
|
|
133
|
-
|
|
134
|
-
export let y2AxisColor = 'true'
|
|
135
|
-
$: y2AxisColorStore = resolveColor(y2AxisColor)
|
|
136
|
-
|
|
137
|
-
// Other column formats:
|
|
138
|
-
export let sizeFmt = undefined
|
|
139
|
-
|
|
140
|
-
// Color palette:
|
|
141
|
-
export let colorPalette = 'default'
|
|
142
|
-
$: colorPaletteStore = resolveColorPalette(colorPalette)
|
|
143
|
-
|
|
144
|
-
// Legend:
|
|
145
|
-
export let legend = undefined
|
|
146
|
-
|
|
147
|
-
// Additional Config Options:
|
|
148
|
-
export let echartsOptions = undefined // additional ECharts config object that will append to the config generated by our API
|
|
149
|
-
export let seriesOptions = undefined // additional ECharts config object that will be applied to every series in the config
|
|
150
|
-
|
|
151
|
-
export let seriesColors = undefined
|
|
152
|
-
$: seriesColorsStore = resolveColorsObject(seriesColors)
|
|
153
|
-
|
|
154
|
-
export let stackType = undefined // used in BarChart (stacked, grouped) and AreaChart (stacked)
|
|
155
|
-
export let stacked100 = false
|
|
156
|
-
|
|
157
|
-
export let chartAreaHeight = undefined
|
|
158
|
-
|
|
159
|
-
export let connectGroup = undefined // string represent name of group for connected charts. Charts with same connectGroup will have connected interactions
|
|
160
|
-
|
|
161
|
-
export let leftPadding = undefined
|
|
162
|
-
export let rightPadding = undefined
|
|
163
|
-
|
|
164
|
-
export let xLabelWrap = false // false = truncate, true = wrap
|
|
165
|
-
$: xLabelWrap = toBoolean(xLabelWrap)
|
|
166
|
-
|
|
167
|
-
const xAxisLabelOverflow = xLabelWrap ? 'break' : 'truncate'
|
|
109
|
+
let xAxisLabelOverflow = $derived(xLabelWrap_bool ? 'break' : 'truncate')
|
|
168
110
|
|
|
169
111
|
// ---------------------------------------------------------------------------------------
|
|
170
112
|
// Variable Declaration
|
|
@@ -223,8 +165,9 @@
|
|
|
223
165
|
let heightMultiplier
|
|
224
166
|
|
|
225
167
|
// Set final chart height:
|
|
226
|
-
|
|
227
|
-
|
|
168
|
+
// Using a separate writable store for dimensions so they're reactive in the template
|
|
169
|
+
// without causing infinite effect loops (which $state would cause since the effect reads+writes them).
|
|
170
|
+
let dimensions = writable<{height?: string, width?: string}>({})
|
|
228
171
|
|
|
229
172
|
let missingCols = []
|
|
230
173
|
|
|
@@ -236,13 +179,14 @@
|
|
|
236
179
|
let optCols = []
|
|
237
180
|
let i
|
|
238
181
|
|
|
182
|
+
// svelte-ignore non_reactive_update
|
|
239
183
|
let error
|
|
240
184
|
|
|
241
185
|
// Date String Handling:
|
|
242
186
|
let columnSummaryArray
|
|
243
187
|
let dateCols
|
|
244
188
|
|
|
245
|
-
|
|
189
|
+
$effect(() => {
|
|
246
190
|
try {
|
|
247
191
|
error = undefined
|
|
248
192
|
missingCols = []
|
|
@@ -251,10 +195,10 @@
|
|
|
251
195
|
inputCols = []
|
|
252
196
|
optCols = []
|
|
253
197
|
uColName = []
|
|
254
|
-
// Normalize list-like inputs first
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
ySet =
|
|
198
|
+
// Normalize list-like inputs first - use local variables instead of reassigning props
|
|
199
|
+
let yLocal = parseCommaList(y)
|
|
200
|
+
let y2Local = parseCommaList(y2)
|
|
201
|
+
ySet = yLocal.length > 0
|
|
258
202
|
xSet = x ? true : false
|
|
259
203
|
|
|
260
204
|
checkInputs(data) // check that dataset exists
|
|
@@ -272,14 +216,15 @@
|
|
|
272
216
|
// Make assumptions to complete required props
|
|
273
217
|
// ---------------------------------------------------------------------------------------
|
|
274
218
|
// If no x column was supplied, assume first column in dataset is x
|
|
219
|
+
let xLocal = x
|
|
275
220
|
if (!xSet) {
|
|
276
|
-
|
|
221
|
+
xLocal = columnNames[0]
|
|
277
222
|
}
|
|
278
223
|
|
|
279
224
|
// If no y column(s) supplied, assume all number columns other than x are the y columns:
|
|
280
225
|
if (!ySet) {
|
|
281
226
|
uColNames = columnNames.filter(function (col) {
|
|
282
|
-
return ![
|
|
227
|
+
return ![xLocal, series, size].includes(col)
|
|
283
228
|
})
|
|
284
229
|
|
|
285
230
|
for (let i = 0; i < uColNames.length; i++) {
|
|
@@ -290,25 +235,25 @@
|
|
|
290
235
|
}
|
|
291
236
|
}
|
|
292
237
|
|
|
293
|
-
|
|
238
|
+
yLocal = unusedColumns // always array; empty handled by required prop checks
|
|
294
239
|
}
|
|
295
240
|
// Establish required columns based on chart type:
|
|
296
241
|
if (bubble) {
|
|
297
242
|
reqCols = {
|
|
298
|
-
x:
|
|
299
|
-
y:
|
|
243
|
+
x: xLocal,
|
|
244
|
+
y: yLocal,
|
|
300
245
|
size: size,
|
|
301
246
|
}
|
|
302
247
|
} else if (hist) {
|
|
303
248
|
reqCols = {
|
|
304
|
-
x:
|
|
249
|
+
x: xLocal,
|
|
305
250
|
}
|
|
306
251
|
} else if (boxplot) {
|
|
307
252
|
reqCols = {}
|
|
308
253
|
} else {
|
|
309
254
|
reqCols = {
|
|
310
|
-
x:
|
|
311
|
-
y:
|
|
255
|
+
x: xLocal,
|
|
256
|
+
y: yLocal,
|
|
312
257
|
}
|
|
313
258
|
}
|
|
314
259
|
|
|
@@ -326,17 +271,17 @@
|
|
|
326
271
|
}
|
|
327
272
|
|
|
328
273
|
// Fix for stacked100 overwriting y variable. Bandaid fix - not a long-term solution:
|
|
329
|
-
if (stacked100 === true && Array.isArray(
|
|
330
|
-
|
|
274
|
+
if (stacked100 === true && Array.isArray(yLocal) && yLocal.some(col => col.includes('_pct')) && originalRun === false) {
|
|
275
|
+
yLocal = yLocal.map(col => col.replace('_pct', ''))
|
|
331
276
|
originalRun = false
|
|
332
277
|
}
|
|
333
278
|
|
|
334
279
|
// Check the inputs supplied to the chart:
|
|
335
|
-
if (
|
|
336
|
-
inputCols.push(
|
|
280
|
+
if (xLocal) {
|
|
281
|
+
inputCols.push(xLocal)
|
|
337
282
|
}
|
|
338
|
-
if (Array.isArray(
|
|
339
|
-
if (Array.isArray(
|
|
283
|
+
if (Array.isArray(yLocal)) for (i = 0; i < yLocal.length; i++) inputCols.push(yLocal[i])
|
|
284
|
+
if (Array.isArray(y2Local)) for (i = 0; i < y2Local.length; i++) inputCols.push(y2Local[i])
|
|
340
285
|
if (size) {
|
|
341
286
|
inputCols.push(size)
|
|
342
287
|
}
|
|
@@ -352,18 +297,18 @@
|
|
|
352
297
|
// ---------------------------------------------------------------------------------------
|
|
353
298
|
// Aggregate Data if Required
|
|
354
299
|
// ---------------------------------------------------------------------------------------
|
|
355
|
-
|
|
300
|
+
let dataLocal = data
|
|
356
301
|
if (stacked100 === true) {
|
|
357
|
-
|
|
358
|
-
|
|
302
|
+
dataLocal = getStackPercentages(dataLocal, xLocal, yLocal)
|
|
303
|
+
yLocal = yLocal.map(col => col + '_pct')
|
|
359
304
|
originalRun = false
|
|
360
|
-
columnSummary = getColumnSummary(
|
|
305
|
+
columnSummary = getColumnSummary(dataLocal)
|
|
361
306
|
}
|
|
362
307
|
|
|
363
308
|
// ---------------------------------------------------------------------------------------
|
|
364
309
|
// Define x axis type
|
|
365
310
|
// ---------------------------------------------------------------------------------------
|
|
366
|
-
xDataType = columnSummary[
|
|
311
|
+
xDataType = columnSummary[xLocal].type
|
|
367
312
|
|
|
368
313
|
// Get xDataType into ECharts default types:
|
|
369
314
|
switch (xDataType) {
|
|
@@ -380,67 +325,68 @@
|
|
|
380
325
|
break
|
|
381
326
|
}
|
|
382
327
|
|
|
383
|
-
|
|
328
|
+
let xTypeLocal = xType === 'category' ? 'category' : xDataType
|
|
384
329
|
|
|
385
330
|
// Set xAxisLabel overflow behaviour based on column type
|
|
386
|
-
|
|
331
|
+
let showAllXAxisLabelsLocal = showAllXAxisLabels
|
|
332
|
+
if (!showAllXAxisLabelsLocal) {
|
|
387
333
|
// if user has not set showXAxisLabels
|
|
388
|
-
|
|
334
|
+
showAllXAxisLabelsLocal = xTypeLocal === 'category'
|
|
389
335
|
} else {
|
|
390
336
|
// if user has set showXAxisLabels, convert to boolean
|
|
391
|
-
|
|
337
|
+
showAllXAxisLabelsLocal = showAllXAxisLabelsLocal === 'true' || showAllXAxisLabelsLocal === true
|
|
392
338
|
}
|
|
393
339
|
|
|
394
340
|
// Throw error if attempting to plot value or time on horizontal x-axis:
|
|
395
|
-
if (
|
|
341
|
+
if (swapXY_bool && xTypeLocal !== 'category') {
|
|
396
342
|
throw Error(
|
|
397
343
|
'Horizontal charts do not support a value or time-based x-axis. You can either change your SQL query to output string values or set swapXY=false.',
|
|
398
344
|
)
|
|
399
345
|
}
|
|
400
346
|
|
|
401
347
|
// Throw error if attempting to plot secondary y-axis on horizontal chart:
|
|
402
|
-
if (
|
|
348
|
+
if (swapXY_bool && y2Local.length) {
|
|
403
349
|
throw Error(
|
|
404
350
|
'Horizontal charts do not support a secondary y-axis. You can either set swapXY=false or remove the y2 prop from your chart.',
|
|
405
351
|
)
|
|
406
352
|
}
|
|
407
353
|
|
|
408
354
|
// Override xType if axes are swapped - only category enabled on horizontal axis
|
|
409
|
-
if (
|
|
410
|
-
|
|
355
|
+
if (swapXY_bool) {
|
|
356
|
+
xTypeLocal = 'category'
|
|
411
357
|
}
|
|
412
358
|
|
|
413
359
|
// Check for x mismatch:
|
|
414
|
-
xMismatch = xDataType === 'value' &&
|
|
360
|
+
xMismatch = xDataType === 'value' && xTypeLocal === 'category'
|
|
415
361
|
|
|
416
362
|
// ---------------------------------------------------------------------------------------
|
|
417
363
|
// Sort data based on xType
|
|
418
364
|
// ---------------------------------------------------------------------------------------
|
|
419
|
-
if (
|
|
420
|
-
let sortColumn =
|
|
365
|
+
if (sort_bool) {
|
|
366
|
+
let sortColumn = xLocal
|
|
421
367
|
if (xDataType === 'category') {
|
|
422
|
-
sortColumn = Array.isArray(
|
|
368
|
+
sortColumn = Array.isArray(yLocal) ? (yLocal[0] ?? xLocal) : xLocal
|
|
423
369
|
}
|
|
424
370
|
let sortAscending = xDataType !== 'category'
|
|
425
|
-
|
|
371
|
+
dataLocal = getSortedData(dataLocal, sortColumn, sortAscending)
|
|
426
372
|
}
|
|
427
373
|
|
|
428
374
|
// Always sort time axes by x - this prevents the lines from being drawn out of order
|
|
429
375
|
if (xDataType === 'time') {
|
|
430
|
-
|
|
376
|
+
dataLocal = getSortedData(dataLocal, xLocal, true)
|
|
431
377
|
}
|
|
432
378
|
|
|
433
379
|
// ---------------------------------------------------------------------------------------
|
|
434
380
|
// Standardize date columns
|
|
435
381
|
// ---------------------------------------------------------------------------------------
|
|
436
382
|
|
|
437
|
-
columnSummaryArray = getColumnSummary(
|
|
383
|
+
columnSummaryArray = getColumnSummary(dataLocal, 'array')
|
|
438
384
|
dateCols = columnSummaryArray.filter((d) => d.type === 'date')
|
|
439
385
|
dateCols = dateCols.map((d) => d.id)
|
|
440
386
|
|
|
441
387
|
if (dateCols.length > 0) {
|
|
442
388
|
for (let i = 0; i < dateCols.length; i++) {
|
|
443
|
-
|
|
389
|
+
dataLocal = standardizeDateColumn(dataLocal, dateCols[i])
|
|
444
390
|
}
|
|
445
391
|
}
|
|
446
392
|
|
|
@@ -448,21 +394,21 @@
|
|
|
448
394
|
// Get format codes for axes
|
|
449
395
|
// ---------------------------------------------------------------------------------------
|
|
450
396
|
if (xFmt) {
|
|
451
|
-
xFormat = getFormatObjectFromString(xFmt, columnSummary[
|
|
397
|
+
xFormat = getFormatObjectFromString(xFmt, columnSummary[xLocal].format?.valueType)
|
|
452
398
|
} else {
|
|
453
|
-
xFormat = columnSummary[
|
|
399
|
+
xFormat = columnSummary[xLocal].format
|
|
454
400
|
}
|
|
455
401
|
|
|
456
|
-
if (
|
|
402
|
+
if (yLocal.length === 0) {
|
|
457
403
|
yFormat = 'str'
|
|
458
404
|
} else {
|
|
459
|
-
if (yFmt) yFormat = getFormatObjectFromString(yFmt, columnSummary[
|
|
460
|
-
else yFormat = columnSummary[
|
|
405
|
+
if (yFmt) yFormat = getFormatObjectFromString(yFmt, columnSummary[yLocal[0]].format?.valueType)
|
|
406
|
+
else yFormat = columnSummary[yLocal[0]].format
|
|
461
407
|
}
|
|
462
408
|
|
|
463
|
-
if (
|
|
464
|
-
if (y2Fmt) y2Format = getFormatObjectFromString(y2Fmt, columnSummary[
|
|
465
|
-
else y2Format = columnSummary[
|
|
409
|
+
if (y2Local.length) {
|
|
410
|
+
if (y2Fmt) y2Format = getFormatObjectFromString(y2Fmt, columnSummary[y2Local[0]].format?.valueType)
|
|
411
|
+
else y2Format = columnSummary[y2Local[0]].format
|
|
466
412
|
}
|
|
467
413
|
|
|
468
414
|
if (size) {
|
|
@@ -473,97 +419,122 @@
|
|
|
473
419
|
}
|
|
474
420
|
}
|
|
475
421
|
|
|
476
|
-
xUnitSummary = columnSummary[
|
|
422
|
+
xUnitSummary = columnSummary[xLocal].columnUnitSummary
|
|
477
423
|
|
|
478
|
-
if (
|
|
424
|
+
if (yLocal.length) yUnitSummary = columnSummary[yLocal[0]].columnUnitSummary
|
|
479
425
|
|
|
480
|
-
if (
|
|
426
|
+
if (y2Local.length) y2UnitSummary = columnSummary[y2Local[0]].columnUnitSummary
|
|
481
427
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
428
|
+
let xAxisTitleLocal = xAxisTitle
|
|
429
|
+
if (xAxisTitleLocal === 'true') {
|
|
430
|
+
xAxisTitleLocal = formatTitle(xLocal, xFormat)
|
|
431
|
+
} else if (xAxisTitleLocal === 'false') {
|
|
432
|
+
xAxisTitleLocal = ''
|
|
486
433
|
}
|
|
487
434
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
435
|
+
let yAxisTitleLocal = yAxisTitle
|
|
436
|
+
if (yAxisTitleLocal === 'true') {
|
|
437
|
+
if (yLocal.length === 1) {
|
|
438
|
+
yAxisTitleLocal = formatTitle(yLocal[0], yFormat)
|
|
491
439
|
} else {
|
|
492
|
-
|
|
440
|
+
yAxisTitleLocal = ''
|
|
493
441
|
}
|
|
494
|
-
} else if (
|
|
495
|
-
|
|
442
|
+
} else if (yAxisTitleLocal === 'false') {
|
|
443
|
+
yAxisTitleLocal = ''
|
|
496
444
|
}
|
|
497
445
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
446
|
+
let y2AxisTitleLocal = y2AxisTitle
|
|
447
|
+
if (y2AxisTitleLocal === 'true') {
|
|
448
|
+
if (y2Local.length === 1) {
|
|
449
|
+
y2AxisTitleLocal = formatTitle(y2Local[0], y2Format)
|
|
501
450
|
} else {
|
|
502
|
-
|
|
451
|
+
y2AxisTitleLocal = ''
|
|
503
452
|
}
|
|
504
|
-
} else if (
|
|
505
|
-
|
|
453
|
+
} else if (y2AxisTitleLocal === 'false') {
|
|
454
|
+
y2AxisTitleLocal = ''
|
|
506
455
|
}
|
|
507
456
|
|
|
508
457
|
// ---------------------------------------------------------------------------------------
|
|
509
458
|
// Get total series count
|
|
510
459
|
// ---------------------------------------------------------------------------------------
|
|
511
|
-
let yCount =
|
|
512
|
-
let seriesCount = series ? getDistinctCount(
|
|
460
|
+
let yCount = yLocal.length
|
|
461
|
+
let seriesCount = series ? getDistinctCount(dataLocal, series) : 1
|
|
513
462
|
let ySeriesCount = yCount * seriesCount
|
|
514
463
|
|
|
515
464
|
// y2Count may need to be adjusted to also factor in the series column. For now, we really
|
|
516
465
|
// only need to know that it's multi-series, so > 1 is sufficient
|
|
517
|
-
let y2Count =
|
|
466
|
+
let y2Count = y2Local.length
|
|
518
467
|
let totalSeriesCount = ySeriesCount + y2Count
|
|
519
468
|
|
|
520
469
|
// ---------------------------------------------------------------------------------------
|
|
521
470
|
// Set legend flag
|
|
522
471
|
// ---------------------------------------------------------------------------------------
|
|
523
|
-
|
|
524
|
-
|
|
472
|
+
let legendLocal = legend
|
|
473
|
+
if (legendLocal !== undefined) {
|
|
474
|
+
legendLocal = legendLocal === 'true' || legendLocal === true
|
|
525
475
|
}
|
|
526
476
|
|
|
527
|
-
|
|
477
|
+
legendLocal = legendLocal ?? totalSeriesCount > 1
|
|
528
478
|
|
|
529
479
|
// ---------------------------------------------------------------------------------------
|
|
530
480
|
// Handle errors for log axes (cannot be used with stacked charts)
|
|
531
481
|
// ---------------------------------------------------------------------------------------
|
|
532
482
|
|
|
533
|
-
if (stacked100 === true &&
|
|
483
|
+
if (stacked100 === true && yLog_bool === true) {
|
|
534
484
|
throw Error('Log axis cannot be used in a 100% stacked chart')
|
|
535
|
-
} else if (stackType === 'stacked' && totalSeriesCount > 1 &&
|
|
485
|
+
} else if (stackType === 'stacked' && totalSeriesCount > 1 && yLog_bool === true) {
|
|
536
486
|
throw Error('Log axis cannot be used in a stacked chart')
|
|
537
487
|
}
|
|
538
488
|
|
|
539
489
|
let minYValue
|
|
540
|
-
if (
|
|
541
|
-
minYValue = columnSummary[
|
|
542
|
-
for (let i = 0; i <
|
|
543
|
-
if (columnSummary[
|
|
544
|
-
minYValue = columnSummary[
|
|
490
|
+
if (yLocal.length) {
|
|
491
|
+
minYValue = columnSummary[yLocal[0]].columnUnitSummary.min
|
|
492
|
+
for (let i = 0; i < yLocal.length; i++) {
|
|
493
|
+
if (columnSummary[yLocal[i]].columnUnitSummary.min < minYValue) {
|
|
494
|
+
minYValue = columnSummary[yLocal[i]].columnUnitSummary.min
|
|
545
495
|
}
|
|
546
496
|
}
|
|
547
497
|
}
|
|
548
498
|
|
|
549
|
-
if (
|
|
499
|
+
if (yLog_bool === true && minYValue <= 0 && minYValue !== null) {
|
|
550
500
|
throw Error('Log axis cannot display values less than or equal to zero')
|
|
551
501
|
}
|
|
552
502
|
|
|
503
|
+
// ---------------------------------------------------------------------------------------
|
|
504
|
+
// Compute chartAreaHeight locally
|
|
505
|
+
// ---------------------------------------------------------------------------------------
|
|
506
|
+
let chartAreaHeightLocal = chartAreaHeight
|
|
507
|
+
if (chartAreaHeightLocal) {
|
|
508
|
+
// if chartAreaHeight was user-supplied
|
|
509
|
+
chartAreaHeightLocal = Number(chartAreaHeightLocal)
|
|
510
|
+
if (isNaN(chartAreaHeightLocal)) {
|
|
511
|
+
// input must be a number
|
|
512
|
+
throw Error('chartAreaHeight must be a number')
|
|
513
|
+
} else if (chartAreaHeightLocal <= 0) {
|
|
514
|
+
throw Error('chartAreaHeight must be a positive number')
|
|
515
|
+
}
|
|
516
|
+
} else {
|
|
517
|
+
chartAreaHeightLocal = 220
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Compute yType locally
|
|
521
|
+
let yTypeLocal = yLog_bool === true ? 'log' : (yType ?? 'value')
|
|
522
|
+
|
|
553
523
|
// ---------------------------------------------------------------------------------------
|
|
554
524
|
// Add props to store to let child components access them
|
|
555
525
|
// ---------------------------------------------------------------------------------------
|
|
556
|
-
|
|
526
|
+
chartProps.update((d) => {
|
|
557
527
|
return {
|
|
558
528
|
...d,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
529
|
+
error: undefined,
|
|
530
|
+
data: dataLocal,
|
|
531
|
+
x: xLocal,
|
|
532
|
+
y: yLocal,
|
|
533
|
+
y2: y2Local,
|
|
563
534
|
series,
|
|
564
|
-
swapXY,
|
|
565
|
-
sort,
|
|
566
|
-
xType,
|
|
535
|
+
swapXY: swapXY_bool,
|
|
536
|
+
sort: sort_bool,
|
|
537
|
+
xType: xTypeLocal,
|
|
567
538
|
xFormat,
|
|
568
539
|
yFormat,
|
|
569
540
|
y2Format,
|
|
@@ -573,11 +544,11 @@
|
|
|
573
544
|
yMin,
|
|
574
545
|
y2Min,
|
|
575
546
|
columnSummary,
|
|
576
|
-
xAxisTitle,
|
|
577
|
-
yAxisTitle,
|
|
578
|
-
y2AxisTitle,
|
|
547
|
+
xAxisTitle: xAxisTitleLocal,
|
|
548
|
+
yAxisTitle: yAxisTitleLocal,
|
|
549
|
+
y2AxisTitle: y2AxisTitleLocal,
|
|
579
550
|
tooltipTitle,
|
|
580
|
-
chartAreaHeight,
|
|
551
|
+
chartAreaHeight: chartAreaHeightLocal,
|
|
581
552
|
chartType,
|
|
582
553
|
yCount,
|
|
583
554
|
y2Count,
|
|
@@ -587,16 +558,16 @@
|
|
|
587
558
|
// ---------------------------------------------------------------------------------------
|
|
588
559
|
// Axis Configuration
|
|
589
560
|
// ---------------------------------------------------------------------------------------
|
|
590
|
-
xDistinct = getDistinctValues(
|
|
561
|
+
xDistinct = getDistinctValues(dataLocal, xLocal)
|
|
591
562
|
let secondaryAxis
|
|
592
563
|
|
|
593
|
-
if (
|
|
564
|
+
if (swapXY_bool) {
|
|
594
565
|
horizAxisConfig = {
|
|
595
|
-
type:
|
|
566
|
+
type: yTypeLocal,
|
|
596
567
|
logBase: yLogBase,
|
|
597
568
|
position: 'top',
|
|
598
569
|
axisLabel: {
|
|
599
|
-
show:
|
|
570
|
+
show: yAxisLabels_bool,
|
|
600
571
|
hideOverlap: true,
|
|
601
572
|
showMaxLabel: true,
|
|
602
573
|
formatter: function (value) {
|
|
@@ -606,23 +577,24 @@
|
|
|
606
577
|
},
|
|
607
578
|
min: yMin,
|
|
608
579
|
max: yMax,
|
|
609
|
-
|
|
580
|
+
minInterval: yUnitSummary?.maxDecimals === 0 ? 1 : undefined,
|
|
581
|
+
scale: yScale_bool,
|
|
610
582
|
splitLine: {
|
|
611
|
-
show:
|
|
583
|
+
show: yGridlines_bool,
|
|
612
584
|
},
|
|
613
585
|
axisLine: {
|
|
614
|
-
show:
|
|
586
|
+
show: yBaseline_bool,
|
|
615
587
|
onZero: false,
|
|
616
588
|
},
|
|
617
589
|
axisTick: {
|
|
618
|
-
show:
|
|
590
|
+
show: yTickMarks_bool,
|
|
619
591
|
},
|
|
620
592
|
boundaryGap: false,
|
|
621
593
|
z: 2,
|
|
622
594
|
}
|
|
623
595
|
} else {
|
|
624
596
|
horizAxisConfig = {
|
|
625
|
-
type:
|
|
597
|
+
type: xTypeLocal,
|
|
626
598
|
min: xMin,
|
|
627
599
|
max: xMax,
|
|
628
600
|
tooltip: {
|
|
@@ -635,20 +607,20 @@
|
|
|
635
607
|
},
|
|
636
608
|
},
|
|
637
609
|
splitLine: {
|
|
638
|
-
show:
|
|
610
|
+
show: xGridlines_bool,
|
|
639
611
|
},
|
|
640
612
|
axisLine: {
|
|
641
|
-
show:
|
|
613
|
+
show: xBaseline_bool,
|
|
642
614
|
},
|
|
643
615
|
axisTick: {
|
|
644
|
-
show:
|
|
616
|
+
show: xTickMarks_bool,
|
|
645
617
|
},
|
|
646
618
|
axisLabel: {
|
|
647
|
-
show:
|
|
619
|
+
show: xAxisLabels_bool,
|
|
648
620
|
hideOverlap: true,
|
|
649
|
-
showMaxLabel:
|
|
621
|
+
showMaxLabel: xTypeLocal === 'category' || xTypeLocal === 'value', // max label for ECharts' time axis is a stub - default for that is false
|
|
650
622
|
formatter:
|
|
651
|
-
|
|
623
|
+
xTypeLocal === 'time' || xTypeLocal === 'category'
|
|
652
624
|
? false
|
|
653
625
|
: function (value) {
|
|
654
626
|
return formatAxisValue(value, xFormat, xUnitSummary)
|
|
@@ -660,21 +632,21 @@
|
|
|
660
632
|
}
|
|
661
633
|
}
|
|
662
634
|
|
|
663
|
-
if (
|
|
635
|
+
if (swapXY_bool) {
|
|
664
636
|
verticalAxisConfig = {
|
|
665
|
-
type:
|
|
637
|
+
type: xTypeLocal,
|
|
666
638
|
inverse: 'true',
|
|
667
639
|
splitLine: {
|
|
668
|
-
show:
|
|
640
|
+
show: xGridlines_bool,
|
|
669
641
|
},
|
|
670
642
|
axisLine: {
|
|
671
|
-
show:
|
|
643
|
+
show: xBaseline_bool,
|
|
672
644
|
},
|
|
673
645
|
axisTick: {
|
|
674
|
-
show:
|
|
646
|
+
show: xTickMarks_bool,
|
|
675
647
|
},
|
|
676
648
|
axisLabel: {
|
|
677
|
-
show:
|
|
649
|
+
show: xAxisLabels_bool,
|
|
678
650
|
hideOverlap: true,
|
|
679
651
|
// formatter:
|
|
680
652
|
// function(value){
|
|
@@ -688,32 +660,34 @@
|
|
|
688
660
|
}
|
|
689
661
|
} else {
|
|
690
662
|
let primaryAxisColor = (() => {
|
|
691
|
-
if (!(Array.isArray(
|
|
692
|
-
|
|
693
|
-
if (
|
|
694
|
-
return
|
|
663
|
+
if (!(Array.isArray(y2Local) && y2Local.length)) return undefined
|
|
664
|
+
let yColor = get(yAxisColorStore)
|
|
665
|
+
if (yColor === 'true') return $colorPaletteResolved?.[0]
|
|
666
|
+
if (yColor === 'false') return undefined
|
|
667
|
+
return yColor
|
|
695
668
|
})()
|
|
696
669
|
let secondaryAxisColor = (() => {
|
|
697
|
-
|
|
698
|
-
if (
|
|
699
|
-
return
|
|
670
|
+
let y2Color = get(y2AxisColorStore)
|
|
671
|
+
if (y2Color === 'true') return $colorPaletteResolved?.[ySeriesCount]
|
|
672
|
+
if (y2Color === 'false') return undefined
|
|
673
|
+
return y2Color
|
|
700
674
|
})()
|
|
701
675
|
|
|
702
676
|
verticalAxisConfig = {
|
|
703
|
-
type:
|
|
677
|
+
type: yTypeLocal,
|
|
704
678
|
logBase: yLogBase,
|
|
705
679
|
splitLine: {
|
|
706
|
-
show:
|
|
680
|
+
show: yGridlines_bool,
|
|
707
681
|
},
|
|
708
682
|
axisLine: {
|
|
709
|
-
show:
|
|
683
|
+
show: yBaseline_bool,
|
|
710
684
|
onZero: false,
|
|
711
685
|
},
|
|
712
686
|
axisTick: {
|
|
713
|
-
show:
|
|
687
|
+
show: yTickMarks_bool,
|
|
714
688
|
},
|
|
715
689
|
axisLabel: {
|
|
716
|
-
show:
|
|
690
|
+
show: yAxisLabels_bool,
|
|
717
691
|
hideOverlap: true,
|
|
718
692
|
margin: 4,
|
|
719
693
|
formatter: function (value) {
|
|
@@ -721,7 +695,7 @@
|
|
|
721
695
|
},
|
|
722
696
|
color: primaryAxisColor,
|
|
723
697
|
},
|
|
724
|
-
name:
|
|
698
|
+
name: yAxisTitleLocal,
|
|
725
699
|
nameLocation: 'end',
|
|
726
700
|
nameTextStyle: {
|
|
727
701
|
align: 'left',
|
|
@@ -732,27 +706,28 @@
|
|
|
732
706
|
nameGap: 6,
|
|
733
707
|
min: yMin,
|
|
734
708
|
max: yMax,
|
|
735
|
-
|
|
736
|
-
|
|
709
|
+
minInterval: yUnitSummary?.maxDecimals === 0 ? 1 : undefined,
|
|
710
|
+
scale: yScale_bool,
|
|
711
|
+
boundaryGap: yUnitSummary?.maxDecimals === 0 ? false : ['0%', '1%'],
|
|
737
712
|
z: 2,
|
|
738
713
|
}
|
|
739
714
|
|
|
740
715
|
secondaryAxis = {
|
|
741
716
|
type: 'value',
|
|
742
|
-
show:
|
|
717
|
+
show: y2Count > 0,
|
|
743
718
|
alignTicks: true,
|
|
744
719
|
splitLine: {
|
|
745
|
-
show:
|
|
720
|
+
show: y2Gridlines_bool,
|
|
746
721
|
},
|
|
747
722
|
axisLine: {
|
|
748
|
-
show:
|
|
723
|
+
show: y2Baseline_bool,
|
|
749
724
|
onZero: false,
|
|
750
725
|
},
|
|
751
726
|
axisTick: {
|
|
752
|
-
show:
|
|
727
|
+
show: y2TickMarks_bool,
|
|
753
728
|
},
|
|
754
729
|
axisLabel: {
|
|
755
|
-
show:
|
|
730
|
+
show: y2AxisLabels_bool,
|
|
756
731
|
hideOverlap: true,
|
|
757
732
|
margin: 4,
|
|
758
733
|
formatter: function (value) {
|
|
@@ -760,7 +735,7 @@
|
|
|
760
735
|
},
|
|
761
736
|
color: secondaryAxisColor,
|
|
762
737
|
},
|
|
763
|
-
name:
|
|
738
|
+
name: y2AxisTitleLocal,
|
|
764
739
|
nameLocation: 'end',
|
|
765
740
|
nameTextStyle: {
|
|
766
741
|
align: 'right',
|
|
@@ -771,8 +746,9 @@
|
|
|
771
746
|
nameGap: 6,
|
|
772
747
|
min: y2Min,
|
|
773
748
|
max: y2Max,
|
|
774
|
-
|
|
775
|
-
|
|
749
|
+
minInterval: y2UnitSummary?.maxDecimals === 0 ? 1 : undefined,
|
|
750
|
+
scale: y2Scale_bool,
|
|
751
|
+
boundaryGap: y2UnitSummary?.maxDecimals === 0 ? false : ['0%', '1%'],
|
|
776
752
|
z: 2,
|
|
777
753
|
}
|
|
778
754
|
|
|
@@ -783,24 +759,11 @@
|
|
|
783
759
|
// Set up chart area
|
|
784
760
|
// ---------------------------------------------------------------------------------------
|
|
785
761
|
|
|
786
|
-
if (chartAreaHeight) {
|
|
787
|
-
// if chartAreaHeight was user-supplied
|
|
788
|
-
chartAreaHeight = Number(chartAreaHeight)
|
|
789
|
-
if (isNaN(chartAreaHeight)) {
|
|
790
|
-
// input must be a number
|
|
791
|
-
throw Error('chartAreaHeight must be a number')
|
|
792
|
-
} else if (chartAreaHeight <= 0) {
|
|
793
|
-
throw Error('chartAreaHeight must be a positive number')
|
|
794
|
-
}
|
|
795
|
-
} else {
|
|
796
|
-
chartAreaHeight = 220
|
|
797
|
-
}
|
|
798
|
-
|
|
799
762
|
hasTitle = title ? true : false
|
|
800
763
|
hasSubtitle = subtitle ? true : false
|
|
801
|
-
hasLegend =
|
|
802
|
-
hasTopAxisTitle =
|
|
803
|
-
hasBottomAxisTitle =
|
|
764
|
+
hasLegend = legendLocal * (series !== null || (yLocal.length > 1))
|
|
765
|
+
hasTopAxisTitle = yAxisTitleLocal !== '' && swapXY_bool
|
|
766
|
+
hasBottomAxisTitle = xAxisTitleLocal !== '' && !swapXY_bool
|
|
804
767
|
|
|
805
768
|
titleFontSize = 15
|
|
806
769
|
subtitleFontSize = 13
|
|
@@ -832,23 +795,22 @@
|
|
|
832
795
|
// Small bars are allowed on normal bar chart (e.g., time series bar chart)
|
|
833
796
|
maxBars = 8
|
|
834
797
|
heightMultiplier = 1
|
|
835
|
-
if (
|
|
798
|
+
if (swapXY_bool) {
|
|
836
799
|
barCount = xDistinct.length
|
|
837
800
|
heightMultiplier = Math.max(1, barCount / maxBars)
|
|
838
801
|
}
|
|
839
802
|
|
|
840
|
-
chartContainerHeight =
|
|
803
|
+
chartContainerHeight = chartAreaHeightLocal * heightMultiplier + chartTop + chartBottom
|
|
841
804
|
|
|
842
805
|
topAxisTitleTop = legendTop + legendHeight + 7
|
|
843
806
|
|
|
844
807
|
// Set final chart height:
|
|
845
|
-
height
|
|
846
|
-
width = '100%'
|
|
808
|
+
dimensions.set({height: chartContainerHeight + 'px', width: '100%'})
|
|
847
809
|
|
|
848
810
|
// ---------------------------------------------------------------------------------------
|
|
849
811
|
// Set up horizontal axis title (custom graphic)
|
|
850
812
|
// ---------------------------------------------------------------------------------------
|
|
851
|
-
horizAxisTitle =
|
|
813
|
+
horizAxisTitle = swapXY_bool ? yAxisTitleLocal : xAxisTitleLocal
|
|
852
814
|
if (horizAxisTitle !== '') {
|
|
853
815
|
horizAxisTitle = horizAxisTitle + ' →' // u2192 is js escaped version of →
|
|
854
816
|
}
|
|
@@ -863,9 +825,9 @@
|
|
|
863
825
|
},
|
|
864
826
|
cursor: 'auto',
|
|
865
827
|
// Positioning (if swapXY, top right; otherwise bottom right)
|
|
866
|
-
right:
|
|
867
|
-
top:
|
|
868
|
-
bottom:
|
|
828
|
+
right: swapXY_bool ? '2%' : '3%',
|
|
829
|
+
top: swapXY_bool ? topAxisTitleTop : null,
|
|
830
|
+
bottom: swapXY_bool ? null : '2%',
|
|
869
831
|
}
|
|
870
832
|
|
|
871
833
|
// ---------------------------------------------------------------------------------------
|
|
@@ -877,7 +839,7 @@
|
|
|
877
839
|
text: title,
|
|
878
840
|
subtext: subtitle,
|
|
879
841
|
subtextStyle: {
|
|
880
|
-
width:
|
|
842
|
+
width: '100%',
|
|
881
843
|
},
|
|
882
844
|
},
|
|
883
845
|
tooltip: {
|
|
@@ -891,14 +853,14 @@
|
|
|
891
853
|
let yCol
|
|
892
854
|
if (totalSeriesCount > 1) {
|
|
893
855
|
// If multi-series, add series name as title of tooltip
|
|
894
|
-
xVal = params[0].value[
|
|
856
|
+
xVal = params[0].value[swapXY_bool ? 1 : 0]
|
|
895
857
|
output = `<span id="tooltip" style='font-weight: 600;'>${formatValue(
|
|
896
858
|
xVal,
|
|
897
859
|
xFormat,
|
|
898
860
|
)}</span>`
|
|
899
861
|
for (let i = params.length - 1; i >= 0; i--) {
|
|
900
862
|
if (params[i].seriesName !== 'stackTotal') {
|
|
901
|
-
yVal = params[i].value[
|
|
863
|
+
yVal = params[i].value[swapXY_bool ? 0 : 1]
|
|
902
864
|
output =
|
|
903
865
|
output +
|
|
904
866
|
`<br> <span style='font-size: 11px;'>${params[i].marker} ${
|
|
@@ -913,13 +875,13 @@
|
|
|
913
875
|
)}</span>`
|
|
914
876
|
}
|
|
915
877
|
}
|
|
916
|
-
} else if (
|
|
878
|
+
} else if (xTypeLocal === 'value') {
|
|
917
879
|
// If single-series and a numerical x-axis, include x column as a normal column rather than title (so as not to show a number as the title)
|
|
918
|
-
xVal = params[0].value[
|
|
919
|
-
yVal = params[0].value[
|
|
880
|
+
xVal = params[0].value[swapXY_bool ? 1 : 0]
|
|
881
|
+
yVal = params[0].value[swapXY_bool ? 0 : 1]
|
|
920
882
|
yCol = params[0].seriesName
|
|
921
883
|
output = `<span id="tooltip" style='font-weight: 600;'>${formatTitle(
|
|
922
|
-
|
|
884
|
+
xLocal,
|
|
923
885
|
xFormat,
|
|
924
886
|
)}: </span><span style='float:right; margin-left: 10px;'>${formatValue(
|
|
925
887
|
xVal,
|
|
@@ -933,8 +895,8 @@
|
|
|
933
895
|
)}</span>`
|
|
934
896
|
} else {
|
|
935
897
|
// If single series and categorical or date x-axis, use x value as title of tooltip
|
|
936
|
-
xVal = params[0].value[
|
|
937
|
-
yVal = params[0].value[
|
|
898
|
+
xVal = params[0].value[swapXY_bool ? 1 : 0]
|
|
899
|
+
yVal = params[0].value[swapXY_bool ? 0 : 1]
|
|
938
900
|
yCol = params[0].seriesName
|
|
939
901
|
output = `<span id="tooltip" style='font-weight: 600;'>${formatValue(
|
|
940
902
|
xVal,
|
|
@@ -959,15 +921,15 @@
|
|
|
959
921
|
order: 'valueDesc',
|
|
960
922
|
},
|
|
961
923
|
legend: {
|
|
962
|
-
show:
|
|
924
|
+
show: legendLocal,
|
|
963
925
|
type: 'scroll',
|
|
964
926
|
top: legendTop,
|
|
965
927
|
padding: [0, 0, 0, 0],
|
|
966
928
|
data: [],
|
|
967
929
|
},
|
|
968
930
|
grid: {
|
|
969
|
-
left: leftPadding ?? (
|
|
970
|
-
right: rightPadding ?? (
|
|
931
|
+
left: leftPadding ?? (swapXY_bool ? '1%' : '0.8%'),
|
|
932
|
+
right: rightPadding ?? (swapXY_bool ? '4%' : '3%'),
|
|
971
933
|
bottom: chartBottom,
|
|
972
934
|
top: chartTop,
|
|
973
935
|
containLabel: true,
|
|
@@ -975,15 +937,16 @@
|
|
|
975
937
|
xAxis: horizAxisConfig,
|
|
976
938
|
yAxis: verticalAxisConfig,
|
|
977
939
|
series: [],
|
|
978
|
-
animation:
|
|
940
|
+
animation: false,
|
|
979
941
|
graphic: horizAxisTitleConfig,
|
|
980
|
-
color: $
|
|
942
|
+
color: $colorPaletteResolved,
|
|
981
943
|
}
|
|
982
944
|
|
|
983
945
|
config.update(() => {
|
|
984
946
|
return chartConfig
|
|
985
947
|
})
|
|
986
948
|
} catch (e) {
|
|
949
|
+
// svelte-ignore non_reactive_update
|
|
987
950
|
error = e.message
|
|
988
951
|
let setTextRed = '\x1b[31m%s\x1b[0m'
|
|
989
952
|
console.error(setTextRed, `Error in ${chartType}: ${e.message}`)
|
|
@@ -999,19 +962,19 @@
|
|
|
999
962
|
let id = `${title || chartType} (${fieldStr.join(' ')})`
|
|
1000
963
|
logError(e, {id})
|
|
1001
964
|
|
|
1002
|
-
|
|
965
|
+
chartProps.update((d) => {
|
|
1003
966
|
return {...d, error}
|
|
1004
967
|
})
|
|
1005
968
|
}
|
|
1006
|
-
}
|
|
969
|
+
})
|
|
1007
970
|
</script>
|
|
1008
971
|
|
|
1009
|
-
{#if
|
|
1010
|
-
|
|
972
|
+
{#if !$chartProps.error}
|
|
973
|
+
{@render children?.()}
|
|
1011
974
|
<ECharts
|
|
1012
975
|
config={$config}
|
|
1013
|
-
{height}
|
|
1014
|
-
{width}
|
|
976
|
+
height={$dimensions.height}
|
|
977
|
+
width={$dimensions.width}
|
|
1015
978
|
{data}
|
|
1016
979
|
{queryID}
|
|
1017
980
|
chartTitle={title}
|
|
@@ -1019,8 +982,8 @@
|
|
|
1019
982
|
{seriesOptions}
|
|
1020
983
|
{connectGroup}
|
|
1021
984
|
{xAxisLabelOverflow}
|
|
1022
|
-
seriesColors={$
|
|
985
|
+
seriesColors={$seriesColorsResolved}
|
|
1023
986
|
/>
|
|
1024
987
|
{:else}
|
|
1025
|
-
<ErrorChart {error} title={chartType} />
|
|
988
|
+
<ErrorChart error={$chartProps.error} title={chartType} />
|
|
1026
989
|
{/if}
|