@graphenedata/cli 0.0.14 → 0.0.16

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.
Files changed (121) hide show
  1. package/LICENSE.md +3 -3
  2. package/README.md +138 -0
  3. package/THIRD_PARTY_NOTICES.md +1 -0
  4. package/bin.js +2 -2
  5. package/dist/cli/bigQuery-I3F46SC6.js +75 -0
  6. package/dist/cli/bigQuery-I3F46SC6.js.map +7 -0
  7. package/dist/cli/chunk-OVWODUTJ.js +12849 -0
  8. package/dist/cli/chunk-OVWODUTJ.js.map +7 -0
  9. package/dist/cli/chunk-QAXEOZ43.js +53 -0
  10. package/dist/cli/chunk-QAXEOZ43.js.map +7 -0
  11. package/dist/cli/cli.js +245 -10290
  12. package/dist/cli/clickhouse-ZN5AN2UL.js +64 -0
  13. package/dist/cli/clickhouse-ZN5AN2UL.js.map +7 -0
  14. package/dist/cli/duckdb-IYBIO5KJ.js +87 -0
  15. package/dist/cli/duckdb-IYBIO5KJ.js.map +7 -0
  16. package/dist/cli/serve2-TNN5EROW.js +447 -0
  17. package/dist/cli/serve2-TNN5EROW.js.map +7 -0
  18. package/dist/cli/snowflake-MOQB5GA4.js +128 -0
  19. package/dist/cli/snowflake-MOQB5GA4.js.map +7 -0
  20. package/dist/index.d.ts +63 -0
  21. package/dist/lang/index.d.ts +63 -0
  22. package/dist/skills/graphene/SKILL.md +235 -0
  23. package/dist/skills/graphene/references/big-value.md +20 -0
  24. package/dist/skills/graphene/references/date-range.md +64 -0
  25. package/dist/skills/graphene/references/dropdown.md +62 -0
  26. package/dist/skills/graphene/references/echarts.md +162 -0
  27. package/dist/skills/graphene/references/gsql.md +393 -0
  28. package/dist/skills/graphene/references/model-gsql.md +72 -0
  29. package/dist/skills/graphene/references/table.md +143 -0
  30. package/dist/skills/graphene/references/text-input.md +29 -0
  31. package/dist/ui/app.css +263 -299
  32. package/dist/ui/component-utilities/dataShaping.ts +484 -0
  33. package/dist/ui/component-utilities/dataSummary.ts +57 -0
  34. package/dist/ui/component-utilities/enrich.ts +763 -0
  35. package/dist/ui/component-utilities/format.ts +177 -0
  36. package/dist/ui/component-utilities/inputUtils.ts +48 -9
  37. package/dist/ui/component-utilities/theme.ts +200 -0
  38. package/dist/ui/component-utilities/themeStores.ts +26 -21
  39. package/dist/ui/component-utilities/types.ts +70 -0
  40. package/dist/ui/components/AreaChart.svelte +57 -105
  41. package/dist/ui/components/BarChart.svelte +71 -129
  42. package/dist/ui/components/BigValue.svelte +24 -40
  43. package/dist/ui/components/Column.svelte +11 -19
  44. package/dist/ui/components/DateRange.svelte +71 -34
  45. package/dist/ui/components/Dropdown.svelte +82 -49
  46. package/dist/ui/components/DropdownOption.svelte +1 -2
  47. package/dist/ui/components/ECharts.svelte +179 -60
  48. package/dist/ui/components/InlineDelta.svelte +51 -32
  49. package/dist/ui/components/LineChart.svelte +54 -125
  50. package/dist/ui/components/PieChart.svelte +27 -37
  51. package/dist/ui/components/QueryLoad.svelte +78 -44
  52. package/dist/ui/components/Row.svelte +2 -1
  53. package/dist/ui/components/ScatterPlot.svelte +52 -0
  54. package/dist/ui/components/Skeleton.svelte +32 -0
  55. package/dist/ui/components/Table.svelte +3 -2
  56. package/dist/ui/components/TableGroupRow.svelte +28 -36
  57. package/dist/ui/components/TableHarness.svelte +32 -0
  58. package/dist/ui/components/TableHeader.svelte +34 -59
  59. package/dist/ui/components/TableRow.svelte +15 -39
  60. package/dist/ui/components/TableSubtotalRow.svelte +26 -21
  61. package/dist/ui/components/TableTotalRow.svelte +27 -37
  62. package/dist/ui/components/TextInput.svelte +17 -14
  63. package/dist/ui/components/Value.svelte +25 -0
  64. package/dist/ui/components/_Table.svelte +80 -76
  65. package/dist/ui/internal/ChartGallery.svelte +527 -0
  66. package/dist/ui/internal/ErrorDisplay.svelte +60 -0
  67. package/dist/ui/internal/LocalApp.svelte +87 -19
  68. package/dist/ui/internal/PageNavGroup.svelte +269 -0
  69. package/dist/ui/internal/Sidebar.svelte +178 -0
  70. package/dist/ui/internal/SidebarToggle.svelte +47 -0
  71. package/dist/ui/internal/StyleGallery.svelte +244 -0
  72. package/dist/ui/internal/clientCache.ts +15 -13
  73. package/dist/ui/internal/pageInputs.svelte.js +292 -0
  74. package/dist/ui/internal/queryEngine.ts +124 -132
  75. package/dist/ui/internal/runSocket.ts +59 -0
  76. package/dist/ui/internal/sidebar.svelte.js +18 -0
  77. package/dist/ui/internal/telemetry.ts +52 -17
  78. package/dist/ui/internal/types.d.ts +7 -0
  79. package/dist/ui/web.js +55 -13
  80. package/package.json +40 -41
  81. package/dist/docs/agent-instructions.md +0 -18
  82. package/dist/docs/base.md +0 -98
  83. package/dist/docs/cli.md +0 -22
  84. package/dist/docs/graphene.md +0 -1462
  85. package/dist/ui/component-utilities/autoFormatting.js +0 -301
  86. package/dist/ui/component-utilities/builtInFormats.js +0 -482
  87. package/dist/ui/component-utilities/chartContext.js +0 -12
  88. package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
  89. package/dist/ui/component-utilities/checkInputs.js +0 -95
  90. package/dist/ui/component-utilities/convert.js +0 -15
  91. package/dist/ui/component-utilities/dateParsing.js +0 -57
  92. package/dist/ui/component-utilities/dropdownContext.ts +0 -1
  93. package/dist/ui/component-utilities/echarts.js +0 -272
  94. package/dist/ui/component-utilities/echartsThemes.js +0 -453
  95. package/dist/ui/component-utilities/formatTitle.js +0 -24
  96. package/dist/ui/component-utilities/formatting.js +0 -250
  97. package/dist/ui/component-utilities/getColumnExtents.js +0 -79
  98. package/dist/ui/component-utilities/getColumnSummary.js +0 -67
  99. package/dist/ui/component-utilities/getCompletedData.js +0 -114
  100. package/dist/ui/component-utilities/getDistinctCount.js +0 -7
  101. package/dist/ui/component-utilities/getDistinctValues.js +0 -15
  102. package/dist/ui/component-utilities/getSeriesConfig.js +0 -237
  103. package/dist/ui/component-utilities/getSortedData.js +0 -7
  104. package/dist/ui/component-utilities/getStackPercentages.js +0 -43
  105. package/dist/ui/component-utilities/getStackedData.js +0 -17
  106. package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
  107. package/dist/ui/component-utilities/globalContexts.js +0 -1
  108. package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
  109. package/dist/ui/component-utilities/replaceNulls.js +0 -14
  110. package/dist/ui/component-utilities/tableUtils.ts +0 -120
  111. package/dist/ui/components/Area.svelte +0 -214
  112. package/dist/ui/components/Bar.svelte +0 -350
  113. package/dist/ui/components/Chart.svelte +0 -989
  114. package/dist/ui/components/ErrorChart.svelte +0 -118
  115. package/dist/ui/components/Line.svelte +0 -227
  116. package/dist/ui/internal/NavSidebar.svelte +0 -396
  117. package/dist/ui/internal/PageError.svelte +0 -23
  118. package/dist/ui/internal/checkSocket.ts +0 -48
  119. package/dist/ui/internal/theme.ts +0 -88
  120. package/dist/ui/public/inter-latin-ext.woff2 +0 -0
  121. package/dist/ui/public/inter-latin.woff2 +0 -0
@@ -1,116 +1,68 @@
1
1
  <script lang="ts">
2
- import type {Snippet} from 'svelte'
3
- import Chart from './Chart.svelte'
4
- import Area from './Area.svelte'
5
- import QueryLoad from './QueryLoad.svelte'
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?: any, x?: any, y?: any, series?: any, xType?: any, yLog?: any, yLogBase?: any
11
- yFmt?: any, xFmt?: any, title?: any, subtitle?: any, legend?: any, xAxisTitle?: any, yAxisTitle?: any
12
- xGridlines?: any, yGridlines?: any, xAxisLabels?: any, yAxisLabels?: any, xBaseline?: any, yBaseline?: any
13
- xTickMarks?: any, yTickMarks?: any, yMin?: any, yMax?: any, yScale?: any, sort?: any, line?: any
14
- fillColor?: any, lineColor?: any, fillOpacity?: any, chartAreaHeight?: any, markers?: any
15
- markerShape?: any, markerSize?: any, handleMissing?: any, step?: any, stepPosition?: any, type?: string
16
- colorPalette?: string, labels?: any, labelSize?: any, labelPosition?: any, labelColor?: any
17
- labelFmt?: any, showAllLabels?: any, echartsOptions?: any, seriesOptions?: any, seriesColors?: any
18
- seriesOrder?: any, connectGroup?: any, seriesLabelFmt?: any, leftPadding?: any, rightPadding?: any
19
- xLabelWrap?: any, children?: Snippet
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 = undefined, x = undefined, y = undefined, series = undefined, xType = undefined, yLog = undefined,
26
- yLogBase = undefined, yFmt = undefined, xFmt = undefined, title = undefined, subtitle = undefined,
27
- legend = undefined, xAxisTitle = undefined, yAxisTitle = undefined, xGridlines = undefined,
28
- yGridlines = undefined, xAxisLabels = undefined, yAxisLabels = undefined, xBaseline = undefined,
29
- yBaseline = undefined, xTickMarks = undefined, yTickMarks = undefined, yMin = undefined, yMax = undefined,
30
- yScale = undefined, sort = undefined, line = undefined, fillColor = undefined, lineColor = undefined,
31
- fillOpacity = undefined, chartAreaHeight = undefined, markers = undefined, markerShape = undefined,
32
- markerSize = undefined, handleMissing = undefined, step = undefined, stepPosition = undefined,
33
- type = 'stacked', colorPalette = 'default', labels = undefined, labelSize = undefined,
34
- labelPosition = undefined, labelColor = undefined, labelFmt = undefined, showAllLabels = undefined,
35
- echartsOptions = undefined, seriesOptions = undefined, seriesColors = undefined, seriesOrder = undefined,
36
- connectGroup = undefined, seriesLabelFmt = undefined, leftPadding = undefined, rightPadding = undefined,
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 stacked100 = $derived(type === 'stacked100')
35
+ let logger = untrack(() => componentLogger('AreaChart', {data: typeof data == 'string' ? data : undefined, x, y}))
36
+ untrack(() => logExtraProps(logger, 'AreaChart', extraProps))
41
37
 
42
- let fillColorStore = $derived(resolveColor(fillColor))
43
- let lineColorStore = $derived(resolveColor(lineColor))
44
- let colorPaletteStore = $derived(resolveColorPalette(colorPalette))
45
- let labelColorStore = $derived(resolveColor(labelColor))
46
- let seriesColorsStore = $derived(resolveColorsObject(seriesColors))
47
- </script>
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
- {#snippet areaChartContent(loaded: any[])}
50
- <Chart
51
- data={loaded}
52
- chartContext={{data, x, y, series}}
53
- {x}
54
- {y}
55
- {xFmt}
56
- {yFmt}
57
- {series}
58
- {xType}
59
- {yLog}
60
- {yLogBase}
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
- <QueryLoad data={data} fields={{x, y: parseCommaList(y), series}} children={areaChartContent} />
68
+ <ECharts data={data} config={buildConfig()} {height} {width} componentId={logger.id} />
@@ -1,142 +1,84 @@
1
1
  <script lang="ts">
2
- import type {Snippet} from 'svelte'
3
- import Chart from './Chart.svelte'
4
- import Bar from './Bar.svelte'
5
- import QueryLoad from './QueryLoad.svelte'
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?: any, x?: any, y?: any, y2?: any, series?: any, xType?: any, yLog?: any, yLogBase?: any
11
- y2SeriesType?: any, yFmt?: any, y2Fmt?: any, xFmt?: any, title?: any, subtitle?: any, legend?: any
12
- xAxisTitle?: any, yAxisTitle?: any, y2AxisTitle?: any, xGridlines?: any, yGridlines?: any
13
- y2Gridlines?: any, xAxisLabels?: any, yAxisLabels?: any, y2AxisLabels?: any, xBaseline?: any
14
- yBaseline?: any, y2Baseline?: any, xTickMarks?: any, yTickMarks?: any, y2TickMarks?: any
15
- yMin?: any, yMax?: any, yScale?: any, y2Min?: any, y2Max?: any, y2Scale?: any
16
- swapXY?: boolean | string, showAllXAxisLabels?: boolean, type?: string, fillColor?: any
17
- fillOpacity?: any, outlineColor?: any, outlineWidth?: any, chartAreaHeight?: any, sort?: any
18
- colorPalette?: string, labels?: any, labelSize?: any, labelPosition?: any, labelColor?: any
19
- labelFmt?: any, yLabelFmt?: any, y2LabelFmt?: any, stackTotalLabel?: any, seriesLabels?: any
20
- showAllLabels?: any, yAxisColor?: any, y2AxisColor?: any, echartsOptions?: any, seriesOptions?: any
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 = undefined, x = undefined, y = undefined, y2 = undefined, series = undefined, xType = undefined,
29
- yLog = undefined, yLogBase = undefined, y2SeriesType = undefined, yFmt = undefined, y2Fmt = undefined,
30
- xFmt = undefined, title = undefined, subtitle = undefined, legend = undefined, xAxisTitle = undefined,
31
- yAxisTitle = undefined, y2AxisTitle = undefined, xGridlines = undefined, yGridlines = undefined,
32
- y2Gridlines = undefined, xAxisLabels = undefined, yAxisLabels = undefined, y2AxisLabels = undefined,
33
- xBaseline = undefined, yBaseline = undefined, y2Baseline = undefined, xTickMarks = undefined,
34
- yTickMarks = undefined, y2TickMarks = undefined, yMin = undefined, yMax = undefined, yScale = undefined,
35
- y2Min = undefined, y2Max = undefined, y2Scale = undefined, swapXY = false, showAllXAxisLabels = undefined,
36
- type = 'stacked', fillColor = undefined, fillOpacity = undefined, outlineColor = undefined,
37
- outlineWidth = undefined, chartAreaHeight = undefined, sort = undefined, colorPalette = 'default',
38
- labels = undefined, labelSize = undefined, labelPosition = undefined, labelColor = undefined,
39
- labelFmt = undefined, yLabelFmt = undefined, y2LabelFmt = undefined, stackTotalLabel = undefined,
40
- seriesLabels = undefined, showAllLabels = undefined, yAxisColor = undefined, y2AxisColor = undefined,
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 normalizedSwapXY = $derived(swapXY === 'true' || swapXY === true)
37
+ let logger = untrack(() => componentLogger('BarChart', {data: typeof data == 'string' ? data : undefined, x, y}))
38
+ untrack(() => logExtraProps(logger, 'BarChart', extraProps))
47
39
 
48
- let stacked100 = $derived(type === 'stacked100')
40
+ function buildConfig(): EChartsConfig {
41
+ let xFields = parseCommaList(x)
42
+ let yFields = parseCommaList(y)
43
+ let horizontal = xFields.length > 1
49
44
 
50
- let fillColorStore = $derived(resolveColor(fillColor))
51
- let outlineColorStore = $derived(resolveColor(outlineColor))
52
- let colorPaletteStore = $derived(resolveColorPalette(colorPalette))
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
- let derivedYAxisTitle = $derived(yAxisTitle ?? (y2 ? 'true' : undefined))
59
- let derivedY2AxisTitle = $derived(y2AxisTitle ?? (y2 ? 'true' : undefined))
60
- </script>
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
- {#snippet barChartContent(loaded: any[])}
63
- <Chart
64
- data={loaded}
65
- chartContext={{data, x, y, series}}
66
- {x}
67
- {y}
68
- {y2}
69
- {xFmt}
70
- {yFmt}
71
- {y2Fmt}
72
- {series}
73
- {xType}
74
- {yLog}
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
- <QueryLoad data={data} fields={{x, y: parseCommaList(y), y2: parseCommaList(y2), series}} children={barChartContent} />
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 | {rows?: any[]}
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, fmt = undefined, title = undefined, subtitle = undefined}: Props = $props()
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
- if (!fmt) return String(input)
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: any[])}
24
+ {#snippet bigValueContent(loaded: QueryResult)}
42
25
  <div class="big-value">
43
26
  {#if title}<div class="big-value__title">{title}</div>{/if}
44
- {#if subtitle}<div class="big-value__subtitle">{subtitle}</div>{/if}
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-size: 14px;
42
+ font-family: var(--font-ui);
43
+ font-size: 11px;
61
44
  font-weight: 600;
62
- color: var(--graphene-big-value-title, #111827);
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: 32px;
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: var(--graphene-big-value-value, #111827);
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/convert'
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, fmt?: string, totalAgg?: string, totalFmt?: string
17
- weightCol?: string, subtotalFmt?: string, colorMax?: string, colorMin?: string, colorMid?: string
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, fmtColumn?: string, redNegatives?: boolean | 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, fmt = undefined, totalAgg = undefined,
30
- totalFmt = undefined, weightCol = undefined, subtotalFmt = undefined, colorMax = undefined,
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, fmtColumn = undefined, redNegatives = 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>>(propKey)
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
- } catch (error) {
115
- if (strictBuild) throw error
106
+ } catch(error) {
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, fmt, fmtColumn, totalAgg, totalFmt, subtotalFmt, weightCol, downIsGood,
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,