@graphenedata/cli 0.0.1
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/LICENSE.md +100 -0
- package/THIRD_PARTY_NOTICES.md +12 -0
- package/cli.ts +157 -0
- package/dist/cli/cli.js +43 -0
- package/dist/docs/data_apps/components/charts/annotations.md +673 -0
- package/dist/docs/data_apps/components/charts/area-chart.md +202 -0
- package/dist/docs/data_apps/components/charts/bar-chart.md +317 -0
- package/dist/docs/data_apps/components/charts/box-plot.md +190 -0
- package/dist/docs/data_apps/components/charts/bubble-chart.md +151 -0
- package/dist/docs/data_apps/components/charts/calendar-heatmap.md +112 -0
- package/dist/docs/data_apps/components/charts/custom-echarts.md +308 -0
- package/dist/docs/data_apps/components/charts/echarts-options.md +217 -0
- package/dist/docs/data_apps/components/charts/funnel-chart.md +106 -0
- package/dist/docs/data_apps/components/charts/heatmap.md +180 -0
- package/dist/docs/data_apps/components/charts/histogram.md +107 -0
- package/dist/docs/data_apps/components/charts/line-chart.md +265 -0
- package/dist/docs/data_apps/components/charts/mixed-type-charts.md +240 -0
- package/dist/docs/data_apps/components/charts/sankey-diagram.md +301 -0
- package/dist/docs/data_apps/components/charts/scatter-plot.md +134 -0
- package/dist/docs/data_apps/components/charts/sparkline.md +68 -0
- package/dist/docs/data_apps/components/data/big-value.md +153 -0
- package/dist/docs/data_apps/components/data/delta.md +89 -0
- package/dist/docs/data_apps/components/data/table.md +470 -0
- package/dist/docs/data_apps/components/data/value.md +97 -0
- package/dist/docs/data_apps/components/inputs/button-group.md +154 -0
- package/dist/docs/data_apps/components/inputs/checkbox.md +52 -0
- package/dist/docs/data_apps/components/inputs/date-input.md +131 -0
- package/dist/docs/data_apps/components/inputs/date-range.md +124 -0
- package/dist/docs/data_apps/components/inputs/dimension-grid.md +67 -0
- package/dist/docs/data_apps/components/inputs/dropdown.md +199 -0
- package/dist/docs/data_apps/components/inputs/index.md +3 -0
- package/dist/docs/data_apps/components/inputs/slider.md +126 -0
- package/dist/docs/data_apps/components/inputs/text-input.md +86 -0
- package/dist/docs/data_apps/components/maps/area-map.md +397 -0
- package/dist/docs/data_apps/components/maps/base-map.md +269 -0
- package/dist/docs/data_apps/components/maps/bubble-map.md +361 -0
- package/dist/docs/data_apps/components/maps/point-map.md +326 -0
- package/dist/docs/data_apps/components/maps/us-map.md +167 -0
- package/dist/docs/data_apps/components/ui/accordion.md +116 -0
- package/dist/docs/data_apps/components/ui/alert.md +37 -0
- package/dist/docs/data_apps/components/ui/big-link.md +19 -0
- package/dist/docs/data_apps/components/ui/details.md +58 -0
- package/dist/docs/data_apps/components/ui/download-data.md +41 -0
- package/dist/docs/data_apps/components/ui/embed.md +47 -0
- package/dist/docs/data_apps/components/ui/grid.md +45 -0
- package/dist/docs/data_apps/components/ui/image.md +61 -0
- package/dist/docs/data_apps/components/ui/info.md +47 -0
- package/dist/docs/data_apps/components/ui/last-refreshed.md +28 -0
- package/dist/docs/data_apps/components/ui/link-button.md +20 -0
- package/dist/docs/data_apps/components/ui/link.md +40 -0
- package/dist/docs/data_apps/components/ui/modal.md +57 -0
- package/dist/docs/data_apps/components/ui/note.md +32 -0
- package/dist/docs/data_apps/components/ui/print-format-components.md +85 -0
- package/dist/docs/data_apps/components/ui/tabs.md +122 -0
- package/dist/docs/graphene.md +129 -0
- package/dist/ui/app.css +332 -0
- package/dist/ui/assets/favicon.ico +0 -0
- package/dist/ui/component-utilities/autoFormatting.js +301 -0
- package/dist/ui/component-utilities/builtInFormats.js +482 -0
- package/dist/ui/component-utilities/chartContext.js +12 -0
- package/dist/ui/component-utilities/chartWindowDebug.js +21 -0
- package/dist/ui/component-utilities/checkInputs.js +95 -0
- package/dist/ui/component-utilities/convert.js +15 -0
- package/dist/ui/component-utilities/dateParsing.js +57 -0
- package/dist/ui/component-utilities/dropdownContext.ts +1 -0
- package/dist/ui/component-utilities/echarts.js +262 -0
- package/dist/ui/component-utilities/echartsThemes.js +453 -0
- package/dist/ui/component-utilities/formatTitle.js +24 -0
- package/dist/ui/component-utilities/formatting.js +258 -0
- package/dist/ui/component-utilities/getColumnExtents.js +79 -0
- package/dist/ui/component-utilities/getColumnSummary.js +67 -0
- package/dist/ui/component-utilities/getCompletedData.js +114 -0
- package/dist/ui/component-utilities/getDistinctCount.js +7 -0
- package/dist/ui/component-utilities/getDistinctValues.js +15 -0
- package/dist/ui/component-utilities/getSeriesConfig.js +236 -0
- package/dist/ui/component-utilities/getSortedData.js +7 -0
- package/dist/ui/component-utilities/getStackPercentages.js +43 -0
- package/dist/ui/component-utilities/getStackedData.js +17 -0
- package/dist/ui/component-utilities/getYAxisIndex.js +15 -0
- package/dist/ui/component-utilities/globalContexts.js +1 -0
- package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +119 -0
- package/dist/ui/component-utilities/inputUtils.ts +25 -0
- package/dist/ui/component-utilities/replaceNulls.js +14 -0
- package/dist/ui/component-utilities/tableUtils.ts +120 -0
- package/dist/ui/component-utilities/themeStores.ts +116 -0
- package/dist/ui/components/Area.svelte +174 -0
- package/dist/ui/components/AreaChart.svelte +150 -0
- package/dist/ui/components/Bar.svelte +326 -0
- package/dist/ui/components/BarChart.svelte +194 -0
- package/dist/ui/components/BigValue.svelte +69 -0
- package/dist/ui/components/Chart.svelte +1070 -0
- package/dist/ui/components/Column.svelte +172 -0
- package/dist/ui/components/DateRange.svelte +324 -0
- package/dist/ui/components/Dropdown.svelte +738 -0
- package/dist/ui/components/DropdownOption.svelte +21 -0
- package/dist/ui/components/ECharts.svelte +77 -0
- package/dist/ui/components/ErrorChart.svelte +54 -0
- package/dist/ui/components/GrapheneQuery.svelte +12 -0
- package/dist/ui/components/InlineDelta.svelte +150 -0
- package/dist/ui/components/Line.svelte +210 -0
- package/dist/ui/components/LineChart.svelte +178 -0
- package/dist/ui/components/PieChart.svelte +36 -0
- package/dist/ui/components/QueryLoad.svelte +82 -0
- package/dist/ui/components/Row.svelte +14 -0
- package/dist/ui/components/SortIcon.svelte +32 -0
- package/dist/ui/components/Table.svelte +19 -0
- package/dist/ui/components/TableCell.svelte +75 -0
- package/dist/ui/components/TableGroupRow.svelte +136 -0
- package/dist/ui/components/TableGroupToggle.svelte +42 -0
- package/dist/ui/components/TableHeader.svelte +242 -0
- package/dist/ui/components/TableRow.svelte +283 -0
- package/dist/ui/components/TableSubtotalRow.svelte +62 -0
- package/dist/ui/components/TableTotalRow.svelte +88 -0
- package/dist/ui/components/TextInput.svelte +92 -0
- package/dist/ui/components/_Table.svelte +516 -0
- package/dist/ui/internal/clientCache.ts +43 -0
- package/dist/ui/internal/queryEngine.ts +169 -0
- package/dist/ui/internal/telemetry.ts +28 -0
- package/dist/ui/internal/theme.ts +88 -0
- package/dist/ui/layout.svelte +3 -0
- package/dist/ui/playwright.config.ts +30 -0
- package/dist/ui/web.js +106 -0
- package/package.json +71 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {getContext, beforeUpdate} from 'svelte'
|
|
3
|
+
import {propKey, configKey} from '../component-utilities/chartContext.js'
|
|
4
|
+
const props = getContext(propKey)
|
|
5
|
+
const config = getContext(configKey)
|
|
6
|
+
|
|
7
|
+
import getSeriesConfig from '../component-utilities/getSeriesConfig.js'
|
|
8
|
+
import getStackedData from '../component-utilities/getStackedData.js'
|
|
9
|
+
import getSortedData from '../component-utilities/getSortedData.js'
|
|
10
|
+
import formatTitle from '../component-utilities/formatTitle.js'
|
|
11
|
+
import getCompletedData from '../component-utilities/getCompletedData.js'
|
|
12
|
+
import getYAxisIndex from '../component-utilities/getYAxisIndex.js'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
formatValue,
|
|
16
|
+
getFormatObjectFromString,
|
|
17
|
+
} from '../component-utilities/formatting.js'
|
|
18
|
+
import {getThemeStores} from '../component-utilities/themeStores'
|
|
19
|
+
|
|
20
|
+
const {resolveColor} = getThemeStores()
|
|
21
|
+
|
|
22
|
+
export let y = undefined
|
|
23
|
+
const ySet = y ? true : false // Hack, see chart.svelte
|
|
24
|
+
export let y2 = undefined
|
|
25
|
+
const y2Set = y2 ? true : false // Hack, see chart.svelte
|
|
26
|
+
export let series = undefined
|
|
27
|
+
const seriesSet = series ? true : false // Hack, see chart.svelte
|
|
28
|
+
export let options = undefined
|
|
29
|
+
export let name = undefined // name to appear in legend (for single series graphics)
|
|
30
|
+
export let type = 'stacked' // stacked, grouped, or stacked100
|
|
31
|
+
export let stackName = undefined
|
|
32
|
+
|
|
33
|
+
export let fillColor = undefined
|
|
34
|
+
$: fillColorStore = resolveColor(fillColor)
|
|
35
|
+
|
|
36
|
+
export let fillOpacity = undefined
|
|
37
|
+
|
|
38
|
+
export let outlineColor = undefined
|
|
39
|
+
$: outlineColorStore = resolveColor(outlineColor)
|
|
40
|
+
|
|
41
|
+
export let outlineWidth = undefined
|
|
42
|
+
|
|
43
|
+
export let labels = false
|
|
44
|
+
$: labels = labels === 'true' || labels === true
|
|
45
|
+
export let seriesLabels = true
|
|
46
|
+
$: seriesLabels = seriesLabels === 'true' || seriesLabels === true
|
|
47
|
+
export let labelSize = 11
|
|
48
|
+
export let labelPosition = undefined
|
|
49
|
+
|
|
50
|
+
export let labelColor = undefined
|
|
51
|
+
$: labelColorStore = resolveColor(labelColor)
|
|
52
|
+
|
|
53
|
+
export let labelFmt = undefined
|
|
54
|
+
let labelFormat
|
|
55
|
+
if (labelFmt) {
|
|
56
|
+
labelFormat = getFormatObjectFromString(labelFmt)
|
|
57
|
+
}
|
|
58
|
+
export let yLabelFmt = undefined
|
|
59
|
+
let yLabelFormat
|
|
60
|
+
if (yLabelFmt) {
|
|
61
|
+
yLabelFormat = getFormatObjectFromString(yLabelFmt)
|
|
62
|
+
}
|
|
63
|
+
export let y2LabelFmt = undefined
|
|
64
|
+
let y2LabelFormat
|
|
65
|
+
if (y2LabelFmt) {
|
|
66
|
+
y2LabelFormat = getFormatObjectFromString(y2LabelFmt)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export let y2SeriesType = 'bar'
|
|
70
|
+
|
|
71
|
+
export let stackTotalLabel = true
|
|
72
|
+
$: stackTotalLabel = stackTotalLabel === 'true' || stackTotalLabel === true
|
|
73
|
+
export let showAllLabels = false
|
|
74
|
+
export let seriesOrder = undefined
|
|
75
|
+
let barMaxWidth = 60
|
|
76
|
+
|
|
77
|
+
// Prop check. If local props supplied, use those. Otherwise fall back to global props.
|
|
78
|
+
$: data = $props.data
|
|
79
|
+
$: x = $props.x
|
|
80
|
+
$: y = ySet ? y : $props.y
|
|
81
|
+
$: y2 = y2Set ? y2 : $props.y2
|
|
82
|
+
$: yFormat = $props.yFormat
|
|
83
|
+
$: y2Format = $props.y2Format
|
|
84
|
+
$: yCount = $props.yCount
|
|
85
|
+
$: y2Count = $props.y2Count
|
|
86
|
+
$: swapXY = $props.swapXY
|
|
87
|
+
$: xType = $props.xType
|
|
88
|
+
$: xMismatch = $props.xMismatch
|
|
89
|
+
$: columnSummary = $props.columnSummary
|
|
90
|
+
$: sort = $props.sort
|
|
91
|
+
$: series = seriesSet ? series : $props.series
|
|
92
|
+
|
|
93
|
+
let stackedData
|
|
94
|
+
let sortOrder
|
|
95
|
+
let defaultLabelPosition
|
|
96
|
+
|
|
97
|
+
$: if (!series && typeof y !== 'object') {
|
|
98
|
+
// Single Series
|
|
99
|
+
name = name ?? formatTitle(y, columnSummary[y].title)
|
|
100
|
+
|
|
101
|
+
if (swapXY && xType !== 'category') {
|
|
102
|
+
data = getCompletedData(data, x, y, series, true, xType !== 'time')
|
|
103
|
+
xType = 'category'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
stackName = 'stack1'
|
|
107
|
+
|
|
108
|
+
defaultLabelPosition = swapXY ? 'right' : 'top'
|
|
109
|
+
} else {
|
|
110
|
+
// Multi Series
|
|
111
|
+
// Sort by stack total for category axis
|
|
112
|
+
if (sort === true && xType === 'category') {
|
|
113
|
+
stackedData = getStackedData(data, x, y)
|
|
114
|
+
|
|
115
|
+
if (typeof y === 'object') {
|
|
116
|
+
stackedData = getSortedData(stackedData, 'stackTotal', false)
|
|
117
|
+
} else {
|
|
118
|
+
stackedData = getSortedData(stackedData, y, false)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
sortOrder = stackedData.map((d) => d[x])
|
|
122
|
+
data = [...data].sort(function (a, b) {
|
|
123
|
+
return sortOrder.indexOf(a[x]) - sortOrder.indexOf(b[x])
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Run fill for missing series entries, only if it's a stacked bar
|
|
128
|
+
if (swapXY || ((xType === 'value' || xType === 'category') && type.includes('stacked'))) {
|
|
129
|
+
data = getCompletedData(data, x, y, series, true, xType === 'value')
|
|
130
|
+
xType = 'category'
|
|
131
|
+
} else if (xType === 'time' && type.includes('stacked')) {
|
|
132
|
+
data = getCompletedData(data, x, y, series, true, true)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (type.includes('stacked')) {
|
|
136
|
+
// Set up stacks
|
|
137
|
+
stackName = stackName ?? 'stack1'
|
|
138
|
+
defaultLabelPosition = 'inside'
|
|
139
|
+
} else {
|
|
140
|
+
stackName = undefined
|
|
141
|
+
defaultLabelPosition = swapXY ? 'right' : 'top'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let stackTotalSeries
|
|
146
|
+
$: if (type === 'stacked') {
|
|
147
|
+
stackTotalSeries = getStackedData(data, x, y)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Value label positions:
|
|
151
|
+
const labelPositions = {
|
|
152
|
+
outside: 'top',
|
|
153
|
+
inside: 'inside',
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const swapXYLabelPositions = {
|
|
157
|
+
outside: 'right',
|
|
158
|
+
inside: 'inside',
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
$: labelPosition =
|
|
162
|
+
(swapXY ? swapXYLabelPositions[labelPosition] : labelPositions[labelPosition]) ??
|
|
163
|
+
defaultLabelPosition
|
|
164
|
+
|
|
165
|
+
$: baseConfig = {
|
|
166
|
+
type: 'bar',
|
|
167
|
+
stack: stackName,
|
|
168
|
+
label: {
|
|
169
|
+
show: labels && seriesLabels,
|
|
170
|
+
// formatter: function (params) {
|
|
171
|
+
// let output;
|
|
172
|
+
// output =
|
|
173
|
+
// params.value[swapXY ? 0 : 1] === 0
|
|
174
|
+
// ? ''
|
|
175
|
+
// : formatValue(params.value[swapXY ? 0 : 1], labelFormat ?? yFormat);
|
|
176
|
+
// return output;
|
|
177
|
+
// },
|
|
178
|
+
formatter: function (params) {
|
|
179
|
+
return params.value[swapXY ? 0 : 1] === 0
|
|
180
|
+
? ''
|
|
181
|
+
: formatValue(
|
|
182
|
+
params.value[swapXY ? 0 : 1],
|
|
183
|
+
[yLabelFormat ?? labelFormat ?? yFormat, y2LabelFormat ?? labelFormat ?? y2Format][
|
|
184
|
+
getYAxisIndex(params.componentIndex, yCount, y2Count)
|
|
185
|
+
],
|
|
186
|
+
)
|
|
187
|
+
},
|
|
188
|
+
position: labelPosition,
|
|
189
|
+
fontSize: labelSize,
|
|
190
|
+
color: $labelColorStore,
|
|
191
|
+
},
|
|
192
|
+
labelLayout: {
|
|
193
|
+
hideOverlap: showAllLabels ? false : true,
|
|
194
|
+
},
|
|
195
|
+
emphasis: {
|
|
196
|
+
focus: 'series',
|
|
197
|
+
},
|
|
198
|
+
barMaxWidth: barMaxWidth,
|
|
199
|
+
itemStyle: {
|
|
200
|
+
color: $fillColorStore,
|
|
201
|
+
opacity: fillOpacity,
|
|
202
|
+
borderColor: $outlineColorStore,
|
|
203
|
+
borderWidth: outlineWidth,
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export let seriesLabelFmt = undefined
|
|
208
|
+
|
|
209
|
+
$: seriesConfig = getSeriesConfig(
|
|
210
|
+
data,
|
|
211
|
+
x,
|
|
212
|
+
y,
|
|
213
|
+
series,
|
|
214
|
+
swapXY,
|
|
215
|
+
baseConfig,
|
|
216
|
+
name,
|
|
217
|
+
xMismatch,
|
|
218
|
+
columnSummary,
|
|
219
|
+
seriesOrder,
|
|
220
|
+
undefined,
|
|
221
|
+
undefined,
|
|
222
|
+
y2,
|
|
223
|
+
seriesLabelFmt,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
$: config.update((d) => {
|
|
227
|
+
d.series.push(...seriesConfig)
|
|
228
|
+
// Push series into legend:
|
|
229
|
+
d.legend.data.push(...seriesConfig.map((d) => d.name.toString()))
|
|
230
|
+
|
|
231
|
+
// Stacked chart total label:
|
|
232
|
+
// series !== x is to avoid an issue where same column is used for both - stackTotalLabel can't handle that
|
|
233
|
+
if (
|
|
234
|
+
labels === true &&
|
|
235
|
+
type === 'stacked' &&
|
|
236
|
+
(typeof y === 'object') | (series !== undefined) &&
|
|
237
|
+
stackTotalLabel === true &&
|
|
238
|
+
series !== x
|
|
239
|
+
) {
|
|
240
|
+
// push stack total series for total label
|
|
241
|
+
d.series.push({
|
|
242
|
+
type: 'bar',
|
|
243
|
+
stack: stackName,
|
|
244
|
+
name: 'stackTotal',
|
|
245
|
+
color: 'none',
|
|
246
|
+
data: stackTotalSeries.map((row) => {
|
|
247
|
+
let axisValue = xMismatch ? row[x].toString() : row[x]
|
|
248
|
+
if (swapXY) return [0, axisValue]
|
|
249
|
+
return [axisValue, 0]
|
|
250
|
+
}),
|
|
251
|
+
label: {
|
|
252
|
+
show: true,
|
|
253
|
+
position: swapXY ? 'right' : 'top',
|
|
254
|
+
formatter: function (params) {
|
|
255
|
+
let sum = 0
|
|
256
|
+
seriesConfig.forEach((s) => {
|
|
257
|
+
sum += s.data[params.dataIndex][swapXY ? 0 : 1]
|
|
258
|
+
})
|
|
259
|
+
return sum === 0 ? '' : formatValue(sum, labelFormat ?? yFormat)
|
|
260
|
+
},
|
|
261
|
+
fontWeight: 'bold',
|
|
262
|
+
fontSize: labelSize,
|
|
263
|
+
padding: swapXY ? [0, 0, 0, 5] : undefined,
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// disable legend selected mode when stackTotalLabel is displayed:
|
|
268
|
+
d.legend.selectedMode = false
|
|
269
|
+
}
|
|
270
|
+
return d
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
$: chartOverrides = {
|
|
274
|
+
// Evidence definition of axes (yAxis = dependent, xAxis = independent)
|
|
275
|
+
xAxis: {
|
|
276
|
+
boundaryGap: ['1%', '2%'],
|
|
277
|
+
type: xType,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
beforeUpdate(() => {
|
|
282
|
+
// beforeUpdate ensures that these overrides always run before we render the chart.
|
|
283
|
+
// otherwise, this block won't re-execute after a change to the data object, and
|
|
284
|
+
// the chart will re-render using the base config from Chart.svelte
|
|
285
|
+
|
|
286
|
+
if (options) {
|
|
287
|
+
config.update((d) => {
|
|
288
|
+
return {...d, ...options}
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (chartOverrides) {
|
|
293
|
+
config.update((d) => {
|
|
294
|
+
if (type.includes('stacked')) {
|
|
295
|
+
d.tooltip = {...d.tooltip, order: 'seriesDesc'}
|
|
296
|
+
} else {
|
|
297
|
+
d.tooltip = {...d.tooltip, order: 'seriesAsc'}
|
|
298
|
+
}
|
|
299
|
+
if (type === 'stacked100') {
|
|
300
|
+
if (swapXY) {
|
|
301
|
+
d.xAxis = {...d.xAxis, max: 1}
|
|
302
|
+
} else {
|
|
303
|
+
d.yAxis[0] = {...d.yAxis[0], max: 1}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (swapXY) {
|
|
307
|
+
d.yAxis = {...d.yAxis, ...chartOverrides.xAxis}
|
|
308
|
+
d.xAxis = {...d.xAxis, ...chartOverrides.yAxis}
|
|
309
|
+
} else {
|
|
310
|
+
d.yAxis[0] = {...d.yAxis[0], ...chartOverrides.yAxis}
|
|
311
|
+
d.xAxis = {...d.xAxis, ...chartOverrides.xAxis}
|
|
312
|
+
if (y2) {
|
|
313
|
+
d.yAxis[1] = {...d.yAxis[1], show: true}
|
|
314
|
+
if (['line', 'bar', 'scatter'].includes(y2SeriesType)) {
|
|
315
|
+
for (let i = 0; i < y2Count; i++) {
|
|
316
|
+
d.series[yCount + i].type = y2SeriesType
|
|
317
|
+
d.series[yCount + i].stack = undefined
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return d
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
</script>
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from './Chart.svelte'
|
|
3
|
+
import Bar from './Bar.svelte'
|
|
4
|
+
import QueryLoad from './QueryLoad.svelte'
|
|
5
|
+
import {getThemeStores} from '../component-utilities/themeStores'
|
|
6
|
+
|
|
7
|
+
const {resolveColor, resolveColorsObject, resolveColorPalette} = getThemeStores()
|
|
8
|
+
|
|
9
|
+
export let data = undefined
|
|
10
|
+
export let x = undefined
|
|
11
|
+
export let y = undefined
|
|
12
|
+
export let y2 = undefined
|
|
13
|
+
export let series = undefined
|
|
14
|
+
export let xType = undefined
|
|
15
|
+
export let yLog = undefined
|
|
16
|
+
export let yLogBase = undefined
|
|
17
|
+
|
|
18
|
+
export let y2SeriesType = undefined
|
|
19
|
+
|
|
20
|
+
export let yFmt = undefined
|
|
21
|
+
export let y2Fmt = undefined
|
|
22
|
+
export let xFmt = undefined
|
|
23
|
+
|
|
24
|
+
export let title = undefined
|
|
25
|
+
export let subtitle = undefined
|
|
26
|
+
export let legend = undefined
|
|
27
|
+
export let xAxisTitle = undefined
|
|
28
|
+
export let yAxisTitle = y2 ? 'true' : undefined
|
|
29
|
+
export let y2AxisTitle = y2 ? 'true' : undefined
|
|
30
|
+
export let xGridlines = undefined
|
|
31
|
+
export let yGridlines = undefined
|
|
32
|
+
export let y2Gridlines = undefined
|
|
33
|
+
export let xAxisLabels = undefined
|
|
34
|
+
export let yAxisLabels = undefined
|
|
35
|
+
export let y2AxisLabels = undefined
|
|
36
|
+
export let xBaseline = undefined
|
|
37
|
+
export let yBaseline = undefined
|
|
38
|
+
export let y2Baseline = undefined
|
|
39
|
+
export let xTickMarks = undefined
|
|
40
|
+
export let yTickMarks = undefined
|
|
41
|
+
export let y2TickMarks = undefined
|
|
42
|
+
export let yMin = undefined
|
|
43
|
+
export let yMax = undefined
|
|
44
|
+
export let yScale = undefined
|
|
45
|
+
export let y2Min = undefined
|
|
46
|
+
export let y2Max = undefined
|
|
47
|
+
export let y2Scale = undefined
|
|
48
|
+
export let swapXY = false
|
|
49
|
+
|
|
50
|
+
/** @type {boolean} */
|
|
51
|
+
export let showAllXAxisLabels = undefined
|
|
52
|
+
|
|
53
|
+
$: {
|
|
54
|
+
if (swapXY === 'true' || swapXY === true) {
|
|
55
|
+
swapXY = true
|
|
56
|
+
} else {
|
|
57
|
+
swapXY = false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export let type = 'stacked' // stacked, grouped, or stacked100
|
|
62
|
+
let stacked100 = type === 'stacked100'
|
|
63
|
+
|
|
64
|
+
export let fillColor = undefined
|
|
65
|
+
$: fillColorStore = resolveColor(fillColor)
|
|
66
|
+
|
|
67
|
+
export let fillOpacity = undefined
|
|
68
|
+
|
|
69
|
+
export let outlineColor = undefined
|
|
70
|
+
$: outlineColorStore = resolveColor(outlineColor)
|
|
71
|
+
|
|
72
|
+
export let outlineWidth = undefined
|
|
73
|
+
export let chartAreaHeight = undefined
|
|
74
|
+
|
|
75
|
+
export let sort = undefined
|
|
76
|
+
|
|
77
|
+
export let colorPalette = 'default'
|
|
78
|
+
$: colorPaletteStore = resolveColorPalette(colorPalette)
|
|
79
|
+
|
|
80
|
+
export let labels = undefined
|
|
81
|
+
export let labelSize = undefined
|
|
82
|
+
export let labelPosition = undefined
|
|
83
|
+
|
|
84
|
+
export let labelColor = undefined
|
|
85
|
+
$: labelColorStore = resolveColor(labelColor)
|
|
86
|
+
|
|
87
|
+
export let labelFmt = undefined
|
|
88
|
+
export let yLabelFmt = undefined
|
|
89
|
+
export let y2LabelFmt = undefined
|
|
90
|
+
|
|
91
|
+
export let stackTotalLabel = undefined
|
|
92
|
+
export let seriesLabels = undefined
|
|
93
|
+
export let showAllLabels = undefined
|
|
94
|
+
|
|
95
|
+
export let yAxisColor = undefined
|
|
96
|
+
$: yAxisColorStore = resolveColor(yAxisColor)
|
|
97
|
+
|
|
98
|
+
export let y2AxisColor = undefined
|
|
99
|
+
$: y2AxisColorStore = resolveColor(y2AxisColor)
|
|
100
|
+
|
|
101
|
+
export let echartsOptions = undefined
|
|
102
|
+
export let seriesOptions = undefined
|
|
103
|
+
export let seriesColors = undefined
|
|
104
|
+
$: seriesColorsStore = resolveColorsObject(seriesColors)
|
|
105
|
+
|
|
106
|
+
export let seriesOrder = undefined
|
|
107
|
+
export let connectGroup = undefined
|
|
108
|
+
|
|
109
|
+
export let seriesLabelFmt = undefined
|
|
110
|
+
|
|
111
|
+
export let leftPadding = undefined
|
|
112
|
+
export let rightPadding = undefined
|
|
113
|
+
|
|
114
|
+
export let xLabelWrap = undefined
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<QueryLoad data={data} fields={[x, y, y2, series]} let:loaded>
|
|
118
|
+
<Chart
|
|
119
|
+
data={loaded}
|
|
120
|
+
{x}
|
|
121
|
+
{y}
|
|
122
|
+
{y2}
|
|
123
|
+
{xFmt}
|
|
124
|
+
{yFmt}
|
|
125
|
+
{y2Fmt}
|
|
126
|
+
{series}
|
|
127
|
+
{xType}
|
|
128
|
+
{yLog}
|
|
129
|
+
{yLogBase}
|
|
130
|
+
{legend}
|
|
131
|
+
{xAxisTitle}
|
|
132
|
+
{yAxisTitle}
|
|
133
|
+
{y2AxisTitle}
|
|
134
|
+
{xGridlines}
|
|
135
|
+
{yGridlines}
|
|
136
|
+
{y2Gridlines}
|
|
137
|
+
{xAxisLabels}
|
|
138
|
+
{yAxisLabels}
|
|
139
|
+
{y2AxisLabels}
|
|
140
|
+
{xBaseline}
|
|
141
|
+
{yBaseline}
|
|
142
|
+
{y2Baseline}
|
|
143
|
+
{xTickMarks}
|
|
144
|
+
{yTickMarks}
|
|
145
|
+
{y2TickMarks}
|
|
146
|
+
yAxisColor={yAxisColorStore}
|
|
147
|
+
y2AxisColor={y2AxisColorStore}
|
|
148
|
+
{yMin}
|
|
149
|
+
{yMax}
|
|
150
|
+
{yScale}
|
|
151
|
+
{y2Min}
|
|
152
|
+
{y2Max}
|
|
153
|
+
{y2Scale}
|
|
154
|
+
{swapXY}
|
|
155
|
+
{title}
|
|
156
|
+
{subtitle}
|
|
157
|
+
chartType="Bar Chart"
|
|
158
|
+
stackType={type}
|
|
159
|
+
{sort}
|
|
160
|
+
{stacked100}
|
|
161
|
+
{chartAreaHeight}
|
|
162
|
+
{showAllXAxisLabels}
|
|
163
|
+
colorPalette={colorPaletteStore}
|
|
164
|
+
{echartsOptions}
|
|
165
|
+
{seriesOptions}
|
|
166
|
+
{connectGroup}
|
|
167
|
+
{xLabelWrap}
|
|
168
|
+
seriesColors={seriesColorsStore}
|
|
169
|
+
{leftPadding}
|
|
170
|
+
{rightPadding}
|
|
171
|
+
>
|
|
172
|
+
<Bar
|
|
173
|
+
{type}
|
|
174
|
+
fillColor={fillColorStore}
|
|
175
|
+
{fillOpacity}
|
|
176
|
+
outlineColor={outlineColorStore}
|
|
177
|
+
{outlineWidth}
|
|
178
|
+
{labels}
|
|
179
|
+
{labelSize}
|
|
180
|
+
{labelPosition}
|
|
181
|
+
labelColor={labelColorStore}
|
|
182
|
+
{labelFmt}
|
|
183
|
+
{yLabelFmt}
|
|
184
|
+
{y2LabelFmt}
|
|
185
|
+
{stackTotalLabel}
|
|
186
|
+
{seriesLabels}
|
|
187
|
+
{showAllLabels}
|
|
188
|
+
{y2SeriesType}
|
|
189
|
+
{seriesOrder}
|
|
190
|
+
{seriesLabelFmt}
|
|
191
|
+
/>
|
|
192
|
+
<slot />
|
|
193
|
+
</Chart>
|
|
194
|
+
</QueryLoad>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import QueryLoad from './QueryLoad.svelte'
|
|
3
|
+
|
|
4
|
+
export let data: string | {rows?: any[]}
|
|
5
|
+
export let value: string | undefined = undefined
|
|
6
|
+
export let fmt: string | undefined = undefined
|
|
7
|
+
export let title: string | undefined = undefined
|
|
8
|
+
export let subtitle: string | undefined = undefined
|
|
9
|
+
|
|
10
|
+
function formatValue (input: any) {
|
|
11
|
+
if (input === null || input === undefined) return '—'
|
|
12
|
+
if (!fmt) return String(input)
|
|
13
|
+
|
|
14
|
+
if (fmt.startsWith('num')) {
|
|
15
|
+
let fraction = parseInt(fmt.replace(/[^0-9]/g, '') || '0', 10)
|
|
16
|
+
let formatter = new Intl.NumberFormat('en-US', {
|
|
17
|
+
maximumFractionDigits: fraction,
|
|
18
|
+
minimumFractionDigits: fraction,
|
|
19
|
+
})
|
|
20
|
+
return formatter.format(Number(input))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (fmt.startsWith('pct')) {
|
|
24
|
+
let fraction = parseInt(fmt.replace(/[^0-9]/g, '') || '0', 10)
|
|
25
|
+
let formatter = new Intl.NumberFormat('en-US', {
|
|
26
|
+
style: 'percent',
|
|
27
|
+
maximumFractionDigits: fraction,
|
|
28
|
+
minimumFractionDigits: fraction,
|
|
29
|
+
})
|
|
30
|
+
return formatter.format(Number(input))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return String(input)
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<QueryLoad {data} fields={[value]} let:loaded>
|
|
38
|
+
<div class="big-value">
|
|
39
|
+
{#if title}<div class="big-value__title">{title}</div>{/if}
|
|
40
|
+
{#if subtitle}<div class="big-value__subtitle">{subtitle}</div>{/if}
|
|
41
|
+
<div class="big-value__value">{formatValue(loaded?.[0]?.[value])}</div>
|
|
42
|
+
</div>
|
|
43
|
+
</QueryLoad>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.big-value {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
gap: 4px;
|
|
50
|
+
margin: 8px 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.big-value__title {
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
color: var(--graphene-big-value-title, #111827);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.big-value__subtitle {
|
|
60
|
+
font-size: 13px;
|
|
61
|
+
color: var(--graphene-big-value-subtitle, #4b5563);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.big-value__value {
|
|
65
|
+
font-size: 32px;
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
color: var(--graphene-big-value-value, #111827);
|
|
68
|
+
}
|
|
69
|
+
</style>
|