@graphenedata/cli 0.0.15 → 0.0.17
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/README.md +174 -0
- package/dist/cli/bigQuery-OQUNH3VT.js +75 -0
- package/dist/cli/bigQuery-OQUNH3VT.js.map +7 -0
- package/dist/cli/chunk-56K2FF57.js +53 -0
- package/dist/cli/chunk-56K2FF57.js.map +7 -0
- package/dist/cli/chunk-TZTTALAV.js +12868 -0
- package/dist/cli/chunk-TZTTALAV.js.map +7 -0
- package/dist/cli/cli.js +260 -11196
- package/dist/cli/clickhouse-S3BJSKND.js +65 -0
- package/dist/cli/clickhouse-S3BJSKND.js.map +7 -0
- package/dist/cli/duckdb-TKVMONRK.js +87 -0
- package/dist/cli/duckdb-TKVMONRK.js.map +7 -0
- package/dist/cli/serve2-S2LL4D4D.js +448 -0
- package/dist/cli/serve2-S2LL4D4D.js.map +7 -0
- package/dist/cli/snowflake-3VPDEYYP.js +128 -0
- package/dist/cli/snowflake-3VPDEYYP.js.map +7 -0
- package/dist/index.d.ts +63 -0
- package/dist/lang/index.d.ts +63 -0
- package/dist/skills/graphene/SKILL.md +156 -95
- package/dist/skills/graphene/references/big-value.md +6 -41
- package/dist/skills/graphene/references/date-range.md +64 -0
- package/dist/skills/graphene/references/dropdown.md +3 -4
- package/dist/skills/graphene/references/echarts.md +162 -0
- package/dist/skills/graphene/references/gsql.md +55 -25
- package/dist/skills/graphene/references/model-gsql.md +70 -0
- package/dist/skills/graphene/references/table.md +13 -14
- package/dist/skills/graphene/references/text-input.md +2 -1
- package/dist/ui/app.css +239 -340
- package/dist/ui/component-utilities/dataShaping.ts +484 -0
- package/dist/ui/component-utilities/dataSummary.ts +57 -0
- package/dist/ui/component-utilities/enrich.ts +793 -0
- package/dist/ui/component-utilities/format.ts +177 -0
- package/dist/ui/component-utilities/inputUtils.ts +44 -8
- package/dist/ui/component-utilities/theme.ts +200 -0
- package/dist/ui/component-utilities/themeStores.ts +21 -8
- package/dist/ui/component-utilities/types.ts +70 -0
- package/dist/ui/components/AreaChart.svelte +57 -105
- package/dist/ui/components/BarChart.svelte +71 -129
- package/dist/ui/components/BigValue.svelte +24 -40
- package/dist/ui/components/Column.svelte +10 -18
- package/dist/ui/components/DateRange.svelte +54 -21
- package/dist/ui/components/Dropdown.svelte +47 -26
- package/dist/ui/components/DropdownOption.svelte +1 -2
- package/dist/ui/components/ECharts.svelte +181 -67
- package/dist/ui/components/InlineDelta.svelte +50 -31
- package/dist/ui/components/LineChart.svelte +54 -125
- package/dist/ui/components/PieChart.svelte +27 -37
- package/dist/ui/components/QueryLoad.svelte +77 -45
- package/dist/ui/components/Row.svelte +2 -1
- package/dist/ui/components/ScatterPlot.svelte +52 -0
- package/dist/ui/components/Skeleton.svelte +32 -0
- package/dist/ui/components/Table.svelte +3 -2
- package/dist/ui/components/TableGroupRow.svelte +28 -36
- package/dist/ui/components/TableHarness.svelte +32 -0
- package/dist/ui/components/TableHeader.svelte +34 -59
- package/dist/ui/components/TableRow.svelte +14 -38
- package/dist/ui/components/TableSubtotalRow.svelte +18 -21
- package/dist/ui/components/TableTotalRow.svelte +27 -37
- package/dist/ui/components/TextInput.svelte +13 -12
- package/dist/ui/components/Value.svelte +25 -0
- package/dist/ui/components/_Table.svelte +72 -70
- package/dist/ui/internal/ChartGallery.svelte +527 -0
- package/dist/ui/internal/ErrorDisplay.svelte +22 -97
- package/dist/ui/internal/LocalApp.svelte +84 -19
- package/dist/ui/internal/PageNavGroup.svelte +269 -0
- package/dist/ui/internal/Sidebar.svelte +178 -0
- package/dist/ui/internal/SidebarToggle.svelte +47 -0
- package/dist/ui/internal/StyleGallery.svelte +244 -0
- package/dist/ui/internal/clientCache.ts +2 -2
- package/dist/ui/internal/pageInputs.svelte.js +292 -0
- package/dist/ui/internal/queryEngine.ts +112 -129
- package/dist/ui/internal/runSocket.ts +31 -14
- package/dist/ui/internal/sidebar.svelte.js +18 -0
- package/dist/ui/internal/telemetry.ts +51 -16
- package/dist/ui/internal/types.d.ts +7 -0
- package/dist/ui/web.js +30 -11
- package/package.json +40 -38
- package/dist/skills/graphene/references/area-chart.md +0 -95
- package/dist/skills/graphene/references/bar-chart.md +0 -112
- package/dist/skills/graphene/references/line-chart.md +0 -108
- package/dist/skills/graphene/references/pie-chart.md +0 -29
- package/dist/skills/graphene/references/value-formats.md +0 -104
- package/dist/ui/component-utilities/autoFormatting.js +0 -280
- package/dist/ui/component-utilities/builtInFormats.js +0 -481
- package/dist/ui/component-utilities/chartContext.js +0 -12
- package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
- package/dist/ui/component-utilities/checkInputs.js +0 -84
- package/dist/ui/component-utilities/convert.js +0 -15
- package/dist/ui/component-utilities/dateParsing.js +0 -56
- package/dist/ui/component-utilities/dropdownContext.ts +0 -1
- package/dist/ui/component-utilities/echarts.js +0 -252
- package/dist/ui/component-utilities/echartsThemes.js +0 -443
- package/dist/ui/component-utilities/formatTitle.js +0 -24
- package/dist/ui/component-utilities/formatting.js +0 -241
- package/dist/ui/component-utilities/getColumnExtents.js +0 -79
- package/dist/ui/component-utilities/getColumnSummary.js +0 -62
- package/dist/ui/component-utilities/getCompletedData.js +0 -122
- package/dist/ui/component-utilities/getDistinctCount.js +0 -7
- package/dist/ui/component-utilities/getDistinctValues.js +0 -15
- package/dist/ui/component-utilities/getSeriesConfig.js +0 -231
- package/dist/ui/component-utilities/getSortedData.js +0 -9
- package/dist/ui/component-utilities/getStackPercentages.js +0 -45
- package/dist/ui/component-utilities/getStackedData.js +0 -19
- package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
- package/dist/ui/component-utilities/globalContexts.js +0 -1
- package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
- package/dist/ui/component-utilities/replaceNulls.js +0 -16
- package/dist/ui/component-utilities/tableUtils.ts +0 -107
- package/dist/ui/component-utilities/tidyWithTypes.js +0 -9
- package/dist/ui/components/Area.svelte +0 -214
- package/dist/ui/components/Bar.svelte +0 -347
- package/dist/ui/components/Chart.svelte +0 -995
- package/dist/ui/components/Line.svelte +0 -227
- package/dist/ui/internal/NavSidebar.svelte +0 -396
- package/dist/ui/internal/theme.ts +0 -60
- package/dist/ui/public/inter-latin-ext.woff2 +0 -0
- package/dist/ui/public/inter-latin.woff2 +0 -0
|
@@ -1,116 +1,68 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {getThemeStores} from '../component-utilities/themeStores'
|
|
2
|
+
import {untrack} from 'svelte'
|
|
3
|
+
import ECharts from './ECharts.svelte'
|
|
4
|
+
import type {EChartsConfig, QueryResult} from '../component-utilities/types.ts'
|
|
5
|
+
import {componentLogger, logExtraProps} from '../internal/telemetry.ts'
|
|
7
6
|
import {parseCommaList} from '../component-utilities/inputUtils.ts'
|
|
8
7
|
|
|
9
8
|
interface Props {
|
|
10
|
-
data
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
data: string | QueryResult
|
|
10
|
+
x: string
|
|
11
|
+
y: string
|
|
12
|
+
y2?: string
|
|
13
|
+
splitBy?: string
|
|
14
|
+
arrange?: 'stack' | 'stack100'
|
|
15
|
+
sort?: string
|
|
16
|
+
title?: string
|
|
17
|
+
height?: string | number
|
|
18
|
+
width?: string | number
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const {resolveColor, resolveColorsObject, resolveColorPalette} = getThemeStores()
|
|
23
|
-
|
|
24
21
|
let {
|
|
25
|
-
data
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
xLabelWrap = undefined, children,
|
|
38
|
-
}: Props = $props()
|
|
22
|
+
data,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
y2 = undefined,
|
|
26
|
+
splitBy = undefined,
|
|
27
|
+
arrange = 'stack',
|
|
28
|
+
sort = undefined,
|
|
29
|
+
title = undefined,
|
|
30
|
+
height = undefined,
|
|
31
|
+
width = undefined,
|
|
32
|
+
...extraProps
|
|
33
|
+
}: Props & Record<string, unknown> = $props()
|
|
39
34
|
|
|
40
|
-
let
|
|
35
|
+
let logger = untrack(() => componentLogger('AreaChart', {data: typeof data == 'string' ? data : undefined, x, y}))
|
|
36
|
+
untrack(() => logExtraProps(logger, 'AreaChart', extraProps))
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
function buildConfig(): EChartsConfig {
|
|
39
|
+
let yFields = parseCommaList(y)
|
|
40
|
+
if (splitBy && yFields.length > 1) throw new Error('AreaChart does not support splitBy with multiple y fields')
|
|
41
|
+
|
|
42
|
+
let stack = arrange === 'stack' || arrange === 'stack100' ? 'area-stack' : undefined
|
|
43
|
+
let stackPercentage = arrange === 'stack100' ? true : undefined
|
|
44
|
+
let sortHint = typeof sort === 'string' && sort.trim().length > 0 ? {sort} : {}
|
|
45
|
+
|
|
46
|
+
let series
|
|
47
|
+
if (splitBy) {
|
|
48
|
+
// "tall" data, one template split into one series per splitBy value by enrich()
|
|
49
|
+
series = [{type: 'line' as const, areaStyle: {opacity: 0.2}, stack, stackPercentage, encode: {x, y: yFields[0], splitBy, ...sortHint}}]
|
|
50
|
+
} else {
|
|
51
|
+
// "wide" data, one area series per field listed in y
|
|
52
|
+
series = yFields.map(field => ({type: 'line' as const, name: field, areaStyle: {opacity: 0.2}, encode: {x, y: field, ...sortHint}}))
|
|
53
|
+
}
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{legend}
|
|
62
|
-
{xAxisTitle}
|
|
63
|
-
{yAxisTitle}
|
|
64
|
-
{xGridlines}
|
|
65
|
-
{yGridlines}
|
|
66
|
-
{xAxisLabels}
|
|
67
|
-
{yAxisLabels}
|
|
68
|
-
{xBaseline}
|
|
69
|
-
{yBaseline}
|
|
70
|
-
{xTickMarks}
|
|
71
|
-
{yTickMarks}
|
|
72
|
-
{yMin}
|
|
73
|
-
{yMax}
|
|
74
|
-
{yScale}
|
|
75
|
-
{title}
|
|
76
|
-
{subtitle}
|
|
77
|
-
chartType="Area Chart"
|
|
78
|
-
stackType={type}
|
|
79
|
-
{stacked100}
|
|
80
|
-
{sort}
|
|
81
|
-
{chartAreaHeight}
|
|
82
|
-
colorPalette={colorPaletteStore}
|
|
83
|
-
{echartsOptions}
|
|
84
|
-
{seriesOptions}
|
|
85
|
-
{connectGroup}
|
|
86
|
-
seriesColors={seriesColorsStore}
|
|
87
|
-
{leftPadding}
|
|
88
|
-
{rightPadding}
|
|
89
|
-
{xLabelWrap}
|
|
90
|
-
>
|
|
91
|
-
<Area
|
|
92
|
-
{line}
|
|
93
|
-
fillColor={fillColorStore}
|
|
94
|
-
lineColor={lineColorStore}
|
|
95
|
-
{fillOpacity}
|
|
96
|
-
{handleMissing}
|
|
97
|
-
{type}
|
|
98
|
-
{step}
|
|
99
|
-
{stepPosition}
|
|
100
|
-
{markers}
|
|
101
|
-
{markerShape}
|
|
102
|
-
{markerSize}
|
|
103
|
-
{labels}
|
|
104
|
-
{labelSize}
|
|
105
|
-
{labelPosition}
|
|
106
|
-
labelColor={labelColorStore}
|
|
107
|
-
{labelFmt}
|
|
108
|
-
{showAllLabels}
|
|
109
|
-
{seriesOrder}
|
|
110
|
-
{seriesLabelFmt}
|
|
111
|
-
/>
|
|
112
|
-
{@render children?.()}
|
|
113
|
-
</Chart>
|
|
114
|
-
{/snippet}
|
|
55
|
+
if (y2) series.push({type: 'line' as const, name: y2, yAxisIndex: 1, encode: {x, y: y2, ...sortHint}})
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
title: title ? {text: title} : undefined,
|
|
59
|
+
tooltip: {trigger: 'axis'},
|
|
60
|
+
legend: {show: Boolean(splitBy || y2 || yFields.length > 1)},
|
|
61
|
+
xAxis: {},
|
|
62
|
+
yAxis: [{max: stackPercentage ? 1 : undefined}, ...(y2 ? [{}] : [])],
|
|
63
|
+
series,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
115
67
|
|
|
116
|
-
<
|
|
68
|
+
<ECharts data={data} config={buildConfig()} {height} {width} componentId={logger.id} />
|
|
@@ -1,142 +1,84 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {getThemeStores} from '../component-utilities/themeStores'
|
|
2
|
+
import {untrack} from 'svelte'
|
|
3
|
+
import ECharts from './ECharts.svelte'
|
|
4
|
+
import type {EChartsConfig, QueryResult, SeriesWithGroupingHint} from '../component-utilities/types.ts'
|
|
5
|
+
import {componentLogger, logExtraProps} from '../internal/telemetry.ts'
|
|
7
6
|
import {parseCommaList} from '../component-utilities/inputUtils.ts'
|
|
8
7
|
|
|
9
8
|
interface Props {
|
|
10
|
-
data
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
seriesColors?: any, seriesOrder?: any, connectGroup?: any, seriesLabelFmt?: any, leftPadding?: any
|
|
22
|
-
rightPadding?: any, xLabelWrap?: any, children?: Snippet
|
|
9
|
+
data: string | QueryResult
|
|
10
|
+
x: string
|
|
11
|
+
y: string
|
|
12
|
+
y2?: string
|
|
13
|
+
splitBy?: string
|
|
14
|
+
arrange?: 'stack' | 'group' | 'stack100'
|
|
15
|
+
label?: boolean
|
|
16
|
+
sort?: string
|
|
17
|
+
title?: string
|
|
18
|
+
height?: string | number
|
|
19
|
+
width?: string | number
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
const {resolveColor, resolveColorsObject, resolveColorPalette} = getThemeStores()
|
|
26
|
-
|
|
27
22
|
let {
|
|
28
|
-
data
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
echartsOptions = undefined, seriesOptions = undefined, seriesColors = undefined, seriesOrder = undefined,
|
|
42
|
-
connectGroup = undefined, seriesLabelFmt = undefined, leftPadding = undefined, rightPadding = undefined,
|
|
43
|
-
xLabelWrap = undefined, children,
|
|
44
|
-
}: Props = $props()
|
|
23
|
+
data,
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
|
+
y2 = undefined,
|
|
27
|
+
splitBy = undefined,
|
|
28
|
+
arrange = 'stack',
|
|
29
|
+
label = false,
|
|
30
|
+
sort = undefined,
|
|
31
|
+
title = undefined,
|
|
32
|
+
height = undefined,
|
|
33
|
+
width = undefined,
|
|
34
|
+
...extraProps
|
|
35
|
+
}: Props & Record<string, unknown> = $props()
|
|
45
36
|
|
|
46
|
-
let
|
|
37
|
+
let logger = untrack(() => componentLogger('BarChart', {data: typeof data == 'string' ? data : undefined, x, y}))
|
|
38
|
+
untrack(() => logExtraProps(logger, 'BarChart', extraProps))
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
function buildConfig(): EChartsConfig {
|
|
41
|
+
let xFields = parseCommaList(x)
|
|
42
|
+
let yFields = parseCommaList(y)
|
|
43
|
+
let horizontal = xFields.length > 1
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let labelColorStore = $derived(resolveColor(labelColor))
|
|
54
|
-
let yAxisColorStore = $derived(resolveColor(yAxisColor))
|
|
55
|
-
let y2AxisColorStore = $derived(resolveColor(y2AxisColor))
|
|
56
|
-
let seriesColorsStore = $derived(resolveColorsObject(seriesColors))
|
|
45
|
+
if (xFields.length > 1 && yFields.length !== 1) throw new Error('BarChart only supports multiple x fields for horizontal charts with a single y field')
|
|
46
|
+
if (splitBy && horizontal && xFields.length > 1) throw new Error('BarChart does not support splitBy with multiple x fields')
|
|
47
|
+
if (splitBy && !horizontal && yFields.length > 1) throw new Error('BarChart does not support splitBy with multiple y fields')
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
let barLabel = label ? {show: true} : undefined
|
|
50
|
+
let stack = arrange === 'stack' || arrange === 'stack100' ? 'bar-stack' : undefined
|
|
51
|
+
let stackPercentage = arrange === 'stack100' ? true : undefined
|
|
52
|
+
let sortHint = typeof sort === 'string' && sort.trim().length > 0 ? {sort} : {}
|
|
53
|
+
|
|
54
|
+
let series: SeriesWithGroupingHint[]
|
|
55
|
+
|
|
56
|
+
if (splitBy) {
|
|
57
|
+
// "tall" data, series are created for unique values of the valueField (handled by an enrichment)
|
|
58
|
+
let valueField = horizontal ? xFields[0] : yFields[0]
|
|
59
|
+
let encode = {x: horizontal ? valueField : x, y: horizontal ? y : valueField, splitBy, ...sortHint}
|
|
60
|
+
series = [{type: 'bar' as const, encode, stack, stackPercentage, label: barLabel}]
|
|
61
|
+
} else {
|
|
62
|
+
// "wide" data, series are created for field listed in the y (or x, for horizontal) attribute
|
|
63
|
+
if (horizontal) {
|
|
64
|
+
series = xFields.map(field => ({type: 'bar' as const, name: field, encode: {x: field, y, ...sortHint}, label: barLabel}))
|
|
65
|
+
} else {
|
|
66
|
+
series = yFields.map(field => ({type: 'bar' as const, name: field, encode: {x, y: field, ...sortHint}, label: barLabel}))
|
|
67
|
+
}
|
|
68
|
+
}
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{yLogBase}
|
|
76
|
-
{legend}
|
|
77
|
-
{xAxisTitle}
|
|
78
|
-
yAxisTitle={derivedYAxisTitle}
|
|
79
|
-
y2AxisTitle={derivedY2AxisTitle}
|
|
80
|
-
{xGridlines}
|
|
81
|
-
{yGridlines}
|
|
82
|
-
{y2Gridlines}
|
|
83
|
-
{xAxisLabels}
|
|
84
|
-
{yAxisLabels}
|
|
85
|
-
{y2AxisLabels}
|
|
86
|
-
{xBaseline}
|
|
87
|
-
{yBaseline}
|
|
88
|
-
{y2Baseline}
|
|
89
|
-
{xTickMarks}
|
|
90
|
-
{yTickMarks}
|
|
91
|
-
{y2TickMarks}
|
|
92
|
-
yAxisColor={yAxisColorStore}
|
|
93
|
-
y2AxisColor={y2AxisColorStore}
|
|
94
|
-
{yMin}
|
|
95
|
-
{yMax}
|
|
96
|
-
{yScale}
|
|
97
|
-
{y2Min}
|
|
98
|
-
{y2Max}
|
|
99
|
-
{y2Scale}
|
|
100
|
-
swapXY={normalizedSwapXY}
|
|
101
|
-
{title}
|
|
102
|
-
{subtitle}
|
|
103
|
-
chartType="Bar Chart"
|
|
104
|
-
stackType={type}
|
|
105
|
-
{sort}
|
|
106
|
-
{stacked100}
|
|
107
|
-
{chartAreaHeight}
|
|
108
|
-
{showAllXAxisLabels}
|
|
109
|
-
colorPalette={colorPaletteStore}
|
|
110
|
-
{echartsOptions}
|
|
111
|
-
{seriesOptions}
|
|
112
|
-
{connectGroup}
|
|
113
|
-
{xLabelWrap}
|
|
114
|
-
seriesColors={seriesColorsStore}
|
|
115
|
-
{leftPadding}
|
|
116
|
-
{rightPadding}
|
|
117
|
-
>
|
|
118
|
-
<Bar
|
|
119
|
-
{type}
|
|
120
|
-
fillColor={fillColorStore}
|
|
121
|
-
{fillOpacity}
|
|
122
|
-
outlineColor={outlineColorStore}
|
|
123
|
-
{outlineWidth}
|
|
124
|
-
{labels}
|
|
125
|
-
{labelSize}
|
|
126
|
-
{labelPosition}
|
|
127
|
-
labelColor={labelColorStore}
|
|
128
|
-
{labelFmt}
|
|
129
|
-
{yLabelFmt}
|
|
130
|
-
{y2LabelFmt}
|
|
131
|
-
{stackTotalLabel}
|
|
132
|
-
{seriesLabels}
|
|
133
|
-
{showAllLabels}
|
|
134
|
-
{y2SeriesType}
|
|
135
|
-
{seriesOrder}
|
|
136
|
-
{seriesLabelFmt}
|
|
137
|
-
/>
|
|
138
|
-
{@render children?.()}
|
|
139
|
-
</Chart>
|
|
140
|
-
{/snippet}
|
|
70
|
+
// y2 is a special shortcut for adding a line on top of a bar chart
|
|
71
|
+
if (y2) series.push({type: 'line' as const, name: y2, yAxisIndex: 1, encode: {x, y: y2, ...sortHint}})
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
title: title ? {text: title} : undefined,
|
|
75
|
+
tooltip: {trigger: 'axis'},
|
|
76
|
+
legend: {show: Boolean(splitBy || y2 || (!horizontal && yFields.length > 1) || (horizontal && xFields.length > 1))},
|
|
77
|
+
xAxis: {},
|
|
78
|
+
yAxis: [{max: stackPercentage ? 1 : undefined}, ...(y2 ? [{}] : [])],
|
|
79
|
+
series,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
141
83
|
|
|
142
|
-
<
|
|
84
|
+
<ECharts data={data} config={buildConfig()} {height} {width} componentId={logger.id} />
|
|
@@ -1,52 +1,34 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import {untrack} from 'svelte'
|
|
2
3
|
import QueryLoad from './QueryLoad.svelte'
|
|
4
|
+
import {formatFromField} from '../component-utilities/format.ts'
|
|
5
|
+
import type {QueryResult} from '../component-utilities/types.ts'
|
|
6
|
+
import {componentLogger} from '../internal/telemetry.ts'
|
|
3
7
|
|
|
4
8
|
interface Props {
|
|
5
|
-
data: string |
|
|
9
|
+
data: string | QueryResult
|
|
6
10
|
value?: string
|
|
7
|
-
fmt?: string
|
|
8
11
|
title?: string
|
|
9
|
-
subtitle?: string
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
let {data, value = undefined,
|
|
14
|
+
let {data, value = undefined, title = undefined}: Props = $props()
|
|
15
|
+
let logger = untrack(() => componentLogger('BigValue', {data: typeof data == 'string' ? data : undefined, value}))
|
|
13
16
|
|
|
14
|
-
function formatValue(input: any) {
|
|
17
|
+
function formatValue(input: any, loaded: QueryResult) {
|
|
15
18
|
if (input === null || input === undefined) return '—'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (fmt.startsWith('num')) {
|
|
19
|
-
let fraction = parseInt(fmt.replace(/[^0-9]/g, '') || '0', 10)
|
|
20
|
-
let formatter = new Intl.NumberFormat('en-US', {
|
|
21
|
-
maximumFractionDigits: fraction,
|
|
22
|
-
minimumFractionDigits: fraction,
|
|
23
|
-
})
|
|
24
|
-
return formatter.format(Number(input))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (fmt.startsWith('pct')) {
|
|
28
|
-
let fraction = parseInt(fmt.replace(/[^0-9]/g, '') || '0', 10)
|
|
29
|
-
let formatter = new Intl.NumberFormat('en-US', {
|
|
30
|
-
style: 'percent',
|
|
31
|
-
maximumFractionDigits: fraction,
|
|
32
|
-
minimumFractionDigits: fraction,
|
|
33
|
-
})
|
|
34
|
-
return formatter.format(Number(input))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return String(input)
|
|
19
|
+
let field = loaded?.fields?.find((entry: any) => entry?.name === value)
|
|
20
|
+
return formatFromField(field as any, input)
|
|
38
21
|
}
|
|
39
22
|
</script>
|
|
40
23
|
|
|
41
|
-
{#snippet bigValueContent(loaded:
|
|
24
|
+
{#snippet bigValueContent(loaded: QueryResult)}
|
|
42
25
|
<div class="big-value">
|
|
43
26
|
{#if title}<div class="big-value__title">{title}</div>{/if}
|
|
44
|
-
|
|
45
|
-
<div class="big-value__value">{formatValue(loaded?.[0]?.[value])}</div>
|
|
27
|
+
<div class="big-value__value">{formatValue(loaded?.rows?.[0]?.[value], loaded)}</div>
|
|
46
28
|
</div>
|
|
47
29
|
{/snippet}
|
|
48
30
|
|
|
49
|
-
<QueryLoad {data} fields={{value}} children={bigValueContent} />
|
|
31
|
+
<QueryLoad {data} fields={{value}} children={bigValueContent} componentId={logger.id} />
|
|
50
32
|
|
|
51
33
|
<style>
|
|
52
34
|
.big-value {
|
|
@@ -57,19 +39,21 @@
|
|
|
57
39
|
}
|
|
58
40
|
|
|
59
41
|
.big-value__title {
|
|
60
|
-
font-
|
|
42
|
+
font-family: var(--font-ui);
|
|
43
|
+
font-size: 11px;
|
|
61
44
|
font-weight: 600;
|
|
62
|
-
color:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.big-value__subtitle {
|
|
66
|
-
font-size: 13px;
|
|
67
|
-
color: var(--graphene-big-value-subtitle, #4b5563);
|
|
45
|
+
color: #aaa;
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
letter-spacing: 0.07em;
|
|
68
48
|
}
|
|
69
49
|
|
|
70
50
|
.big-value__value {
|
|
71
|
-
font-size:
|
|
51
|
+
font-size: 28px;
|
|
52
|
+
letter-spacing: -0.02em;
|
|
53
|
+
line-height: 1;
|
|
54
|
+
font-family: var(--font-ui);
|
|
55
|
+
font-optical-sizing: auto;
|
|
72
56
|
font-weight: 600;
|
|
73
|
-
color:
|
|
57
|
+
color: #111;
|
|
74
58
|
}
|
|
75
59
|
</style>
|
|
@@ -5,35 +5,33 @@
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import {getContext, onDestroy, onMount, untrack} from 'svelte'
|
|
7
7
|
import {type Writable, get} from 'svelte/store'
|
|
8
|
-
import {propKey, strictBuild} from '../component-utilities/chartContext.js'
|
|
9
8
|
import {getThemeStores} from '../component-utilities/themeStores'
|
|
10
|
-
import {toBoolean} from '../component-utilities/
|
|
11
|
-
import {parseCommaList} from '../component-utilities/inputUtils.ts'
|
|
9
|
+
import {parseCommaList, toBoolean} from '../component-utilities/inputUtils.ts'
|
|
12
10
|
|
|
13
11
|
interface Props {
|
|
14
12
|
id: string, description?: string, contentType?: string, title?: string, align?: string
|
|
15
13
|
wrap?: boolean | string, wrapTitle?: boolean | string, height?: string, width?: string, alt?: string
|
|
16
|
-
openInNewTab?: boolean | string, linkLabel?: string,
|
|
17
|
-
|
|
14
|
+
openInNewTab?: boolean | string, linkLabel?: string, totalAgg?: string
|
|
15
|
+
colorMax?: string, colorMin?: string, colorMid?: string
|
|
18
16
|
colorBreakpoints?: string[], colorScale?: any, scaleColumn?: string, downIsGood?: boolean | string
|
|
19
17
|
showValue?: boolean | string, deltaSymbol?: boolean | string, neutralMin?: number | string
|
|
20
18
|
neutralMax?: number | string, chip?: boolean | string, sparkWidth?: number | string
|
|
21
19
|
sparkHeight?: number | string, sparkColor?: string, sparkX?: string, sparkY?: string
|
|
22
20
|
sparkYScale?: boolean | string, barColor?: string, negativeBarColor?: string, backgroundColor?: string
|
|
23
|
-
hideLabels?: boolean | string, colGroup?: string,
|
|
21
|
+
hideLabels?: boolean | string, colGroup?: string, redNegatives?: boolean | string
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
let {
|
|
27
25
|
id, description = undefined, contentType = undefined, title = undefined, align = undefined,
|
|
28
26
|
wrap = undefined, wrapTitle = undefined, height = undefined, width = undefined, alt = undefined,
|
|
29
|
-
openInNewTab = undefined, linkLabel = undefined,
|
|
30
|
-
|
|
27
|
+
openInNewTab = undefined, linkLabel = undefined, totalAgg = undefined,
|
|
28
|
+
colorMax = undefined,
|
|
31
29
|
colorMin = undefined, colorMid = undefined, colorBreakpoints = undefined, colorScale = 'default',
|
|
32
30
|
scaleColumn = undefined, downIsGood = undefined, showValue = undefined, deltaSymbol = undefined,
|
|
33
31
|
neutralMin = 0, neutralMax = 0, chip = undefined, sparkWidth = undefined, sparkHeight = undefined,
|
|
34
32
|
sparkColor = undefined, sparkX = undefined, sparkY = undefined, sparkYScale = undefined,
|
|
35
33
|
barColor = '#a5cdee', negativeBarColor = '#fca5a5', backgroundColor = 'transparent',
|
|
36
|
-
hideLabels = undefined, colGroup = undefined,
|
|
34
|
+
hideLabels = undefined, colGroup = undefined, redNegatives = undefined,
|
|
37
35
|
}: Props = $props()
|
|
38
36
|
|
|
39
37
|
const {resolveColor, resolveColorPalette} = getThemeStores()
|
|
@@ -44,7 +42,7 @@
|
|
|
44
42
|
let backgroundColorStore = $derived(resolveColor(backgroundColor))
|
|
45
43
|
let colorScaleStore = $derived(resolveColorPalette(colorScale))
|
|
46
44
|
|
|
47
|
-
const chartProps = getContext<Writable<any>>(
|
|
45
|
+
const chartProps = getContext<Writable<any>>('tableProps')
|
|
48
46
|
|
|
49
47
|
const identifier = Symbol('GrapheneColumn')
|
|
50
48
|
|
|
@@ -68,12 +66,7 @@
|
|
|
68
66
|
alt,
|
|
69
67
|
openInNewTab: toBoolean(openInNewTab) ?? false,
|
|
70
68
|
linkLabel,
|
|
71
|
-
fmt,
|
|
72
|
-
fmtColumn,
|
|
73
69
|
totalAgg,
|
|
74
|
-
totalFmt,
|
|
75
|
-
subtotalFmt,
|
|
76
|
-
weightCol,
|
|
77
70
|
downIsGood: toBoolean(downIsGood) ?? false,
|
|
78
71
|
deltaSymbol: toBoolean(deltaSymbol) ?? true,
|
|
79
72
|
chip: toBoolean(chip) ?? false,
|
|
@@ -108,11 +101,10 @@
|
|
|
108
101
|
let data = get(chartProps).data?.[0]
|
|
109
102
|
if (data && !Object.keys(data).includes(id)) {
|
|
110
103
|
let error = `Error in table: ${id} does not exist in the dataset`
|
|
111
|
-
if (strictBuild) throw new Error(error)
|
|
112
104
|
console.warn(error)
|
|
113
105
|
}
|
|
114
106
|
} catch(error) {
|
|
115
|
-
|
|
107
|
+
console.warn(error)
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
// Initial registration
|
|
@@ -127,7 +119,7 @@
|
|
|
127
119
|
$effect(() => {
|
|
128
120
|
// Read all props that could change
|
|
129
121
|
void [id, title, align, wrap, wrapTitle, contentType, height, width, alt, openInNewTab,
|
|
130
|
-
linkLabel,
|
|
122
|
+
linkLabel, totalAgg, downIsGood,
|
|
131
123
|
deltaSymbol, chip, neutralMin, neutralMax, showValue, colorMax, colorMin, colorMid,
|
|
132
124
|
colorScale, colorBreakpoints, scaleColumn, colGroup, description, redNegatives,
|
|
133
125
|
sparkWidth, sparkHeight, sparkColor, sparkX, sparkY, sparkYScale, barColor,
|