frappe-ui 1.0.2 → 1.1.0
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/experimental/Calendar/calendarUtils.ts +33 -21
- package/experimental/MultiEmailInput/MultiEmailInput.vue +64 -12
- package/experimental/MultiEmailInput/types.ts +12 -3
- package/experimental/Stepper/StepIndicator.vue +129 -0
- package/experimental/Stepper/Stepper.api.md +117 -0
- package/experimental/Stepper/Stepper.md +95 -0
- package/experimental/Stepper/Stepper.vue +82 -0
- package/experimental/Stepper/StepperHorizontal.vue +93 -0
- package/experimental/Stepper/StepperVertical.vue +291 -0
- package/experimental/Stepper/index.ts +11 -0
- package/experimental/Stepper/resolve.ts +87 -0
- package/experimental/Stepper/types.ts +89 -0
- package/experimental.ts +2 -0
- package/package.json +1 -1
- package/src/charts/CalendarHeatmapChart.vue +353 -0
- package/src/charts/DonutChart.vue +34 -58
- package/src/charts/HeatmapChart.vue +26 -64
- package/src/charts/NumberCard.vue +62 -7
- package/src/charts/PercentageBarChart.vue +243 -0
- package/src/charts/SankeyChart.vue +14 -11
- package/src/charts/ScatterChart.vue +24 -20
- package/src/charts/axisChartCommon.ts +182 -18
- package/src/charts/axisFormat.ts +8 -3
- package/src/charts/calendarHeatmapOptions.ts +604 -0
- package/src/charts/colorMath.ts +26 -0
- package/src/charts/components/ChartContainer.vue +63 -53
- package/src/charts/components/ChartLegend.vue +216 -24
- package/src/charts/components/ChartScale.vue +85 -0
- package/src/charts/core/dataLabelFit.ts +45 -6
- package/src/charts/core/useAxisChart.ts +36 -19
- package/src/charts/core/useChart.ts +6 -1
- package/src/charts/core/usePlotKeyboard.ts +13 -2
- package/src/charts/docs/BarChart.md +11 -3
- package/src/charts/docs/CalendarHeatmapChart.api.md +165 -0
- package/src/charts/docs/CalendarHeatmapChart.md +33 -0
- package/src/charts/docs/ChartContainer.api.md +6 -0
- package/src/charts/docs/ChartLegend.api.md +1 -1
- package/src/charts/docs/ChartLegend.md +25 -3
- package/src/charts/docs/DonutChart.api.md +12 -0
- package/src/charts/docs/DonutChart.md +17 -0
- package/src/charts/docs/HeatmapChart.api.md +1 -1
- package/src/charts/docs/LineChart.md +5 -3
- package/src/charts/docs/NumberCard.api.md +6 -0
- package/src/charts/docs/NumberCard.md +6 -0
- package/src/charts/docs/Overview.md +13 -6
- package/src/charts/docs/PercentageBarChart.api.md +148 -0
- package/src/charts/docs/PercentageBarChart.md +42 -0
- package/src/charts/docs/ScatterChart.md +2 -3
- package/src/charts/donutChartOptions.ts +22 -130
- package/src/charts/format.ts +4 -1
- package/src/charts/heatmapOptions.ts +17 -12
- package/src/charts/hiddenSeries.ts +8 -3
- package/src/charts/index.ts +12 -0
- package/src/charts/legendOverflow.ts +40 -0
- package/src/charts/numberCardFormat.ts +19 -13
- package/src/charts/referenceLines.ts +2 -1
- package/src/charts/scatterOptions.ts +16 -3
- package/src/charts/seriesData.ts +8 -3
- package/src/charts/slices.ts +228 -0
- package/src/charts/tokens.ts +99 -0
- package/src/charts/types.ts +318 -9
- package/src/components/Avatar/Avatar.md +27 -2
- package/src/components/Avatar/Avatar.vue +29 -12
- package/src/components/Combobox/Combobox.vue +9 -2
- package/src/components/Combobox/ComboboxResults.vue +6 -1
- package/src/components/Combobox/utils.ts +2 -1
- package/src/components/Dialog/Dialog.md +3 -1
- package/src/components/Duration/Duration.api.md +16 -3
- package/src/components/Duration/Duration.md +21 -0
- package/src/components/Duration/Duration.vue +29 -8
- package/src/components/Duration/duration.ts +105 -44
- package/src/components/Duration/index.ts +1 -0
- package/src/components/Duration/types.ts +30 -1
- package/src/components/Menu/utils.ts +3 -2
- package/src/components/MultiSelect/MultiSelect.api.md +5 -0
- package/src/components/MultiSelect/MultiSelect.vue +34 -0
- package/src/components/MultiSelect/MultiSelectResults.vue +3 -4
- package/src/components/MultiSelect/types.ts +6 -0
- package/src/components/Select/Select.vue +4 -4
- package/src/components/Select/utils.ts +1 -0
- package/src/components/Switch/Switch.vue +3 -3
- package/src/components/shared/selection/utils.ts +8 -1
- package/src/data-fetching/useCall/useCall.ts +25 -26
- package/src/data-fetching/useFrappeFetch.ts +48 -2
- package/src/data-fetching/useList/useList.ts +11 -3
- package/src/data-fetching/utils.ts +15 -1
- package/src/molecules/editor/components/MediaNodeView.vue +10 -1
- package/src/molecules/editor/components/MediaResizeGuide.vue +71 -0
- package/src/molecules/editor/components/media-node-view-utils.ts +7 -0
- package/src/molecules/editor/composables/useNodeViewResize.ts +142 -10
- package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +3 -1
- package/src/molecules/editor/useEditor.ts +12 -6
- package/src/utils/dialog.ts +37 -14
- package/tailwind/content.js +1 -0
- package/vite/README.md +5 -3
- package/vite/codeLanguages.js +41 -17
|
@@ -62,7 +62,11 @@
|
|
|
62
62
|
class="relative flex min-w-0 flex-col gap-1.5"
|
|
63
63
|
:class="{ 'pb-10': showSparkline }"
|
|
64
64
|
>
|
|
65
|
-
<div
|
|
65
|
+
<div
|
|
66
|
+
v-if="showTitleRow"
|
|
67
|
+
data-slot="chart-header"
|
|
68
|
+
class="flex min-w-0 items-center justify-between gap-3"
|
|
69
|
+
>
|
|
66
70
|
<!-- The font-size class is on the row, not on the title span, so slot
|
|
67
71
|
content sized in `em` follows the card's smaller title. Zero
|
|
68
72
|
height for the same reason `#actions` has it. -->
|
|
@@ -172,6 +176,39 @@
|
|
|
172
176
|
</span>
|
|
173
177
|
</slot>
|
|
174
178
|
</div>
|
|
179
|
+
|
|
180
|
+
<!-- Past 100 the track shrinks to 100's share of the reading and the
|
|
181
|
+
rest fills beside it, so a reading over its whole shows how far. -->
|
|
182
|
+
<div
|
|
183
|
+
v-if="showProgress"
|
|
184
|
+
class="mt-0.5 flex h-1 gap-0.5"
|
|
185
|
+
role="meter"
|
|
186
|
+
aria-valuemin="0"
|
|
187
|
+
:aria-valuemax="Math.max(progressValue, 100)"
|
|
188
|
+
:aria-valuenow="progressValue"
|
|
189
|
+
:aria-valuetext="`${Math.round(progressValue)}%`"
|
|
190
|
+
:aria-label="title"
|
|
191
|
+
>
|
|
192
|
+
<div
|
|
193
|
+
class="h-full overflow-hidden rounded-full bg-surface-gray-3"
|
|
194
|
+
:style="{ width: `${progressWhole}%` }"
|
|
195
|
+
>
|
|
196
|
+
<!-- At least as wide as it is tall: a reading of 0.05% is not 0. -->
|
|
197
|
+
<div
|
|
198
|
+
v-if="progressValue > 0"
|
|
199
|
+
class="h-full min-w-1 rounded-full"
|
|
200
|
+
:style="{
|
|
201
|
+
width: `${Math.min(progressValue, 100)}%`,
|
|
202
|
+
...progressStyle,
|
|
203
|
+
}"
|
|
204
|
+
/>
|
|
205
|
+
</div>
|
|
206
|
+
<div
|
|
207
|
+
v-if="progressWhole < 100"
|
|
208
|
+
class="h-full flex-1 rounded-full"
|
|
209
|
+
:style="progressStyle"
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
175
212
|
</template>
|
|
176
213
|
</div>
|
|
177
214
|
</ChartCard>
|
|
@@ -225,11 +262,13 @@ const TONE_CLASSES: Record<DeltaTone, string> = {
|
|
|
225
262
|
neutral: 'text-ink-gray-6',
|
|
226
263
|
}
|
|
227
264
|
|
|
228
|
-
const direction = computed(() => deltaDirection(props
|
|
229
|
-
const toneClass = computed(
|
|
230
|
-
() => TONE_CLASSES[deltaTone(props.delta, props.negativeIsBetter)],
|
|
231
|
-
)
|
|
265
|
+
const direction = computed(() => deltaDirection(props))
|
|
266
|
+
const toneClass = computed(() => TONE_CLASSES[deltaTone(props)])
|
|
232
267
|
const formattedDelta = computed(() => formatCardDelta(props, props.delta))
|
|
268
|
+
// An empty row would still take the column's gap above the number.
|
|
269
|
+
const showTitleRow = computed(() =>
|
|
270
|
+
Boolean(props.title || slots['title-suffix'] || slots.actions),
|
|
271
|
+
)
|
|
233
272
|
const showEmptySlot = computed(() => isEmpty.value && Boolean(slots.empty))
|
|
234
273
|
// Only over a reading. The em dash a card with no value prints is not a number
|
|
235
274
|
// the color says anything about, and the loading skeleton is not one either.
|
|
@@ -289,10 +328,15 @@ const areaPath = computed(() =>
|
|
|
289
328
|
)
|
|
290
329
|
|
|
291
330
|
const { tokens } = useChartTokens(root)
|
|
331
|
+
const defaultColor = computed(
|
|
332
|
+
() => paletteColors('sequential', tokens.value, 1)[0],
|
|
333
|
+
)
|
|
292
334
|
const sparklineColor = computed(
|
|
293
|
-
() =>
|
|
294
|
-
props.sparkline?.color ?? paletteColors('sequential', tokens.value, 1)[0],
|
|
335
|
+
() => props.sparkline?.color ?? defaultColor.value,
|
|
295
336
|
)
|
|
337
|
+
const progressStyle = computed(() => ({
|
|
338
|
+
backgroundColor: props.progress?.color ?? defaultColor.value,
|
|
339
|
+
}))
|
|
296
340
|
|
|
297
341
|
// Time runs with the reading direction, so an RTL card reads oldest-first from
|
|
298
342
|
// the right. Mirroring the box is enough: the line carries no text.
|
|
@@ -311,6 +355,17 @@ const formattedValue = computed(() =>
|
|
|
311
355
|
// one would collapse it and take the block's other variants with it.
|
|
312
356
|
const valueText = computed(() => formattedValue.value || '—')
|
|
313
357
|
|
|
358
|
+
const showProgress = computed(
|
|
359
|
+
() =>
|
|
360
|
+
props.progress != null &&
|
|
361
|
+
Number.isFinite(props.progress.value) &&
|
|
362
|
+
!isEmpty.value,
|
|
363
|
+
)
|
|
364
|
+
const progressValue = computed(() => Math.max(props.progress?.value ?? 0, 0))
|
|
365
|
+
const progressWhole = computed(() =>
|
|
366
|
+
progressValue.value > 100 ? (100 / progressValue.value) * 100 : 100,
|
|
367
|
+
)
|
|
368
|
+
|
|
314
369
|
// Not counted up, and never printed beside the em dash: nothing measured
|
|
315
370
|
// against a target reads as a target of its own.
|
|
316
371
|
const targetText = computed(() =>
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ChartContainer
|
|
3
|
+
:title="title"
|
|
4
|
+
:subtitle="subtitle"
|
|
5
|
+
:loading="loading"
|
|
6
|
+
:error="error"
|
|
7
|
+
:empty="isEmpty"
|
|
8
|
+
centered
|
|
9
|
+
:dir="dir"
|
|
10
|
+
>
|
|
11
|
+
<template v-if="$slots.actions" #actions><slot name="actions" /></template>
|
|
12
|
+
<template v-if="$slots['title-suffix']" #title-suffix>
|
|
13
|
+
<slot name="title-suffix" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<!-- The container owns the three states, so an app that wants a retry
|
|
17
|
+
button beside the message or a skeleton of its own reaches them here
|
|
18
|
+
rather than dropping the chart and rebuilding the chrome. -->
|
|
19
|
+
<template v-if="$slots.loading" #loading><slot name="loading" /></template>
|
|
20
|
+
<template v-if="$slots.error" #error="slotProps">
|
|
21
|
+
<slot name="error" v-bind="slotProps" />
|
|
22
|
+
</template>
|
|
23
|
+
<template v-if="$slots.empty" #empty><slot name="empty" /></template>
|
|
24
|
+
|
|
25
|
+
<template #default>
|
|
26
|
+
<div ref="root" class="flex h-full w-full items-center">
|
|
27
|
+
<!-- With every slice at zero the track is drawn bare, as the ring is. -->
|
|
28
|
+
<div
|
|
29
|
+
role="group"
|
|
30
|
+
:aria-label="chartAriaLabel(title, subtitle)"
|
|
31
|
+
class="flex h-3 w-full gap-0.5 rounded-1"
|
|
32
|
+
:style="
|
|
33
|
+
drawn.length ? undefined : { backgroundColor: tokens.gridline }
|
|
34
|
+
"
|
|
35
|
+
>
|
|
36
|
+
<!-- Grown by share rather than by value: grow factors that sum to
|
|
37
|
+
less than 1 leave part of the track empty. The floor keeps a
|
|
38
|
+
sliver of a share on the track, so its legend entry points at
|
|
39
|
+
something. -->
|
|
40
|
+
<button
|
|
41
|
+
v-for="slice in drawn"
|
|
42
|
+
:key="slice.name"
|
|
43
|
+
type="button"
|
|
44
|
+
class="h-full min-w-1 overflow-hidden rounded-1 transition-opacity focus-visible:focus-ring motion-reduce:transition-none"
|
|
45
|
+
:style="{
|
|
46
|
+
flex: `${slice.percent} 1 0`,
|
|
47
|
+
backgroundColor: slice.color,
|
|
48
|
+
opacity:
|
|
49
|
+
highlighted && highlighted !== slice.name
|
|
50
|
+
? BLUR_OPACITY
|
|
51
|
+
: undefined,
|
|
52
|
+
}"
|
|
53
|
+
:aria-label="sliceLabel(slice)"
|
|
54
|
+
@mouseenter="hover(slice, $event)"
|
|
55
|
+
@mousemove="track($event)"
|
|
56
|
+
@mouseleave="clearHover"
|
|
57
|
+
@focus="focusSlice(slice, $event)"
|
|
58
|
+
@blur="clearHover"
|
|
59
|
+
@click="emit('select', sliceEvent(slice))"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<ChartTooltip
|
|
65
|
+
:open="tooltip.open"
|
|
66
|
+
:x="tooltip.x"
|
|
67
|
+
:y="tooltip.y"
|
|
68
|
+
:items="tooltip.items"
|
|
69
|
+
:rows="tooltip.rows"
|
|
70
|
+
:dir="dir"
|
|
71
|
+
>
|
|
72
|
+
<template v-if="$slots.tooltip" #default="slotProps">
|
|
73
|
+
<slot name="tooltip" v-bind="slotProps" />
|
|
74
|
+
</template>
|
|
75
|
+
</ChartTooltip>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<template v-if="legendItems.length" #legend>
|
|
79
|
+
<ChartLegend
|
|
80
|
+
:items="legendItems"
|
|
81
|
+
@change="toggleSlice"
|
|
82
|
+
@highlight="hovered = $event"
|
|
83
|
+
/>
|
|
84
|
+
</template>
|
|
85
|
+
</ChartContainer>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
import { computed, reactive, ref, watch } from 'vue'
|
|
90
|
+
import { BLUR_OPACITY } from './axisChartCommon'
|
|
91
|
+
import { formatPercent, formatValue } from './format'
|
|
92
|
+
import { pruneHiddenSeries, toggleHiddenSeries } from './hiddenSeries'
|
|
93
|
+
import { useTooltipDismiss } from './core/useTooltipDismiss'
|
|
94
|
+
import {
|
|
95
|
+
buildSlices,
|
|
96
|
+
drawnSlices,
|
|
97
|
+
sliceEvent,
|
|
98
|
+
sliceLegendItems,
|
|
99
|
+
sliceTooltipItem,
|
|
100
|
+
} from './slices'
|
|
101
|
+
import { useChartTokens } from './tokens'
|
|
102
|
+
import { chartAriaLabel, documentDir } from './utils'
|
|
103
|
+
import ChartContainer from './components/ChartContainer.vue'
|
|
104
|
+
import ChartLegend from './components/ChartLegend.vue'
|
|
105
|
+
import ChartTooltip from './components/ChartTooltip.vue'
|
|
106
|
+
import type {
|
|
107
|
+
ChartTooltipItem,
|
|
108
|
+
DonutSlice,
|
|
109
|
+
PercentageBarChartEmits,
|
|
110
|
+
PercentageBarChartProps,
|
|
111
|
+
PercentageBarChartSlots,
|
|
112
|
+
} from './types'
|
|
113
|
+
|
|
114
|
+
// The donut's slices laid along one track. No echarts: each slice is a button,
|
|
115
|
+
// so it takes its own tab stop and focus ring where a canvas region cannot.
|
|
116
|
+
|
|
117
|
+
const props = defineProps<PercentageBarChartProps>()
|
|
118
|
+
|
|
119
|
+
const hiddenSlices = defineModel<string[]>('hiddenSlices', {
|
|
120
|
+
default: () => [],
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const emit = defineEmits<PercentageBarChartEmits>()
|
|
124
|
+
|
|
125
|
+
defineSlots<PercentageBarChartSlots>()
|
|
126
|
+
|
|
127
|
+
const root = ref<HTMLElement>()
|
|
128
|
+
const dir = computed(() => props.dir ?? documentDir())
|
|
129
|
+
|
|
130
|
+
const { tokens } = useChartTokens(root)
|
|
131
|
+
|
|
132
|
+
const slices = computed(() =>
|
|
133
|
+
buildSlices(
|
|
134
|
+
{
|
|
135
|
+
data: props.data,
|
|
136
|
+
categoryColumn: props.category,
|
|
137
|
+
valueColumn: props.value,
|
|
138
|
+
maxSlices: props.maxSlices,
|
|
139
|
+
order: props.order,
|
|
140
|
+
palette: props.palette,
|
|
141
|
+
colors: props.colors,
|
|
142
|
+
},
|
|
143
|
+
{ tokens: tokens.value, hiddenSlices: hiddenSlices.value },
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
const drawn = computed(() => drawnSlices(slices.value))
|
|
147
|
+
const isEmpty = computed(() => slices.value.every((slice) => slice.hidden))
|
|
148
|
+
|
|
149
|
+
/** Slice under the pointer, under the keyboard focus, or under the legend. */
|
|
150
|
+
const hovered = ref<string | null>(null)
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The rest of the track steps back from the hovered slice, as the ring does. A
|
|
154
|
+
* hidden slice under the legend has no block to step back from.
|
|
155
|
+
*/
|
|
156
|
+
const highlighted = computed(() =>
|
|
157
|
+
drawn.value.some((slice) => slice.name === hovered.value)
|
|
158
|
+
? hovered.value
|
|
159
|
+
: null,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
const tooltip = reactive({
|
|
163
|
+
open: false,
|
|
164
|
+
x: 0,
|
|
165
|
+
y: 0,
|
|
166
|
+
items: [] as ChartTooltipItem[],
|
|
167
|
+
/** Plural: a slice groups, and "Others" groups the whole tail. */
|
|
168
|
+
rows: [] as Record<string, any>[],
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
useTooltipDismiss({
|
|
172
|
+
plot: root,
|
|
173
|
+
data: () => drawn.value,
|
|
174
|
+
close: () => {
|
|
175
|
+
tooltip.open = false
|
|
176
|
+
},
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
function hover(slice: DonutSlice, event: MouseEvent) {
|
|
180
|
+
readSlice(slice)
|
|
181
|
+
track(event)
|
|
182
|
+
tooltip.open = true
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// A keyboard reader has no pointer to anchor the tooltip to, so it hangs off the
|
|
186
|
+
// bottom of the slice itself.
|
|
187
|
+
function focusSlice(slice: DonutSlice, event: FocusEvent) {
|
|
188
|
+
readSlice(slice)
|
|
189
|
+
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect()
|
|
190
|
+
tooltip.x = rect.left + rect.width / 2
|
|
191
|
+
tooltip.y = rect.bottom
|
|
192
|
+
tooltip.open = true
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function readSlice(slice: DonutSlice) {
|
|
196
|
+
hovered.value = slice.name
|
|
197
|
+
tooltip.items = [sliceTooltipItem(slice, formatMeasure)]
|
|
198
|
+
tooltip.rows = slice.rows
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function track(event: MouseEvent) {
|
|
202
|
+
tooltip.x = event.clientX
|
|
203
|
+
tooltip.y = event.clientY
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function clearHover() {
|
|
207
|
+
hovered.value = null
|
|
208
|
+
tooltip.open = false
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The width is what the bar says, so the name carries the share in words. */
|
|
212
|
+
function sliceLabel(slice: DonutSlice) {
|
|
213
|
+
return `${slice.label}, ${formatMeasure(slice.value)}, ${formatPercent(
|
|
214
|
+
slice.percent,
|
|
215
|
+
)}`
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function formatMeasure(value: number) {
|
|
219
|
+
return props.format ? props.format(value) : formatValue(value)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const legendItems = computed(() =>
|
|
223
|
+
sliceLegendItems(slices.value, formatMeasure),
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
function toggleSlice(name: string) {
|
|
227
|
+
hiddenSlices.value = toggleHiddenSeries(
|
|
228
|
+
hiddenSlices.value,
|
|
229
|
+
name,
|
|
230
|
+
drawn.value.map((slice) => slice.name),
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Slices that disappear while hidden shouldn't stay in the hidden list forever.
|
|
235
|
+
// Only ever assigns when something really went away: `slices` reads
|
|
236
|
+
// `hiddenSlices`, so an unconditional write here would feed itself.
|
|
237
|
+
watch(
|
|
238
|
+
() => slices.value.map((slice) => slice.name),
|
|
239
|
+
(names) => {
|
|
240
|
+
hiddenSlices.value = pruneHiddenSeries(hiddenSlices.value, names)
|
|
241
|
+
},
|
|
242
|
+
)
|
|
243
|
+
</script>
|
|
@@ -60,7 +60,7 @@ import { usePlotKeyboard } from './core/usePlotKeyboard'
|
|
|
60
60
|
import { useTooltipDismiss } from './core/useTooltipDismiss'
|
|
61
61
|
import { buildSankeyGraph, buildSankeyOption } from './sankeyOptions'
|
|
62
62
|
import { formatLabel, formatValue } from './format'
|
|
63
|
-
import { useChartTokens } from './tokens'
|
|
63
|
+
import { useChartTokens, useResolvedConfig } from './tokens'
|
|
64
64
|
import {
|
|
65
65
|
chartAriaLabel,
|
|
66
66
|
documentDir,
|
|
@@ -93,16 +93,19 @@ const plotEl = ref<HTMLElement>()
|
|
|
93
93
|
|
|
94
94
|
const dir = computed(() => props.dir ?? documentDir())
|
|
95
95
|
|
|
96
|
-
const config =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
const config = useResolvedConfig<SankeyChartConfig>(
|
|
97
|
+
() => ({
|
|
98
|
+
data: props.data,
|
|
99
|
+
sourceColumn: props.source,
|
|
100
|
+
targetColumn: props.target,
|
|
101
|
+
valueColumn: props.value,
|
|
102
|
+
vertical: props.vertical,
|
|
103
|
+
nodeAlign: props.nodeAlign,
|
|
104
|
+
palette: props.palette,
|
|
105
|
+
echartOptions: props.echartOptions,
|
|
106
|
+
}),
|
|
107
|
+
plotEl,
|
|
108
|
+
)
|
|
106
109
|
|
|
107
110
|
const { tokens } = useChartTokens(plotEl)
|
|
108
111
|
|
|
@@ -72,7 +72,7 @@ import { useTooltipDismiss } from './core/useTooltipDismiss'
|
|
|
72
72
|
import { buildScatterOption, buildScatterSeries } from './scatterOptions'
|
|
73
73
|
import { formatLabel, formatValue } from './format'
|
|
74
74
|
import { pruneHiddenSeries, toggleHiddenSeries } from './hiddenSeries'
|
|
75
|
-
import { useChartTokens } from './tokens'
|
|
75
|
+
import { useChartTokens, useResolvedConfig } from './tokens'
|
|
76
76
|
import { chartAriaLabel, documentDir, plotReading } from './utils'
|
|
77
77
|
import ChartContainer from './components/ChartContainer.vue'
|
|
78
78
|
import ChartLegend from './components/ChartLegend.vue'
|
|
@@ -119,21 +119,24 @@ const dir = computed(() => props.dir ?? documentDir())
|
|
|
119
119
|
const formatX = computed(() => props.xAxis?.format ?? props.format)
|
|
120
120
|
const formatY = computed(() => props.yAxis?.format ?? props.format)
|
|
121
121
|
|
|
122
|
-
const config =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
const config = useResolvedConfig<ScatterChartConfig>(
|
|
123
|
+
() => ({
|
|
124
|
+
data: props.data,
|
|
125
|
+
xColumn: props.x,
|
|
126
|
+
yColumn: props.y,
|
|
127
|
+
sizeColumn: props.size,
|
|
128
|
+
splitByColumn: props.splitBy,
|
|
129
|
+
labelColumn: props.label,
|
|
130
|
+
showDataLabels: props.showDataLabels,
|
|
131
|
+
xAxis: toValueAxis(props.xAxis),
|
|
132
|
+
yAxis: toValueAxis(props.yAxis),
|
|
133
|
+
referenceLines: props.referenceLines,
|
|
134
|
+
palette: props.palette,
|
|
135
|
+
dir: dir.value,
|
|
136
|
+
echartOptions: props.echartOptions,
|
|
137
|
+
}),
|
|
138
|
+
plotEl,
|
|
139
|
+
)
|
|
137
140
|
|
|
138
141
|
function toValueAxis(axis?: ScatterChartProps['xAxis']) {
|
|
139
142
|
if (!axis) return undefined
|
|
@@ -141,6 +144,7 @@ function toValueAxis(axis?: ScatterChartProps['xAxis']) {
|
|
|
141
144
|
title: axis.title,
|
|
142
145
|
min: axis.min,
|
|
143
146
|
max: axis.max,
|
|
147
|
+
integer: axis.integer,
|
|
144
148
|
echartOptions: axis.echartOptions,
|
|
145
149
|
}
|
|
146
150
|
}
|
|
@@ -157,9 +161,7 @@ const isEmpty = computed(() =>
|
|
|
157
161
|
|
|
158
162
|
// The y-axis title is chrome rather than an echarts axis name, so it lines up
|
|
159
163
|
// with the chart title above the plot. The x-axis title is drawn on its axis.
|
|
160
|
-
const yAxisTitle = computed(() =>
|
|
161
|
-
props.yAxis?.title ? formatLabel(props.yAxis.title) : undefined,
|
|
162
|
-
)
|
|
164
|
+
const yAxisTitle = computed(() => props.yAxis?.title || undefined)
|
|
163
165
|
|
|
164
166
|
// A malformed config throws while building the option; surfacing it as an error
|
|
165
167
|
// state beats letting it bubble out of a render and blank the whole page.
|
|
@@ -303,7 +305,9 @@ function toggleSeries(name: string) {
|
|
|
303
305
|
hiddenSeries.value = toggleHiddenSeries(
|
|
304
306
|
hiddenSeries.value,
|
|
305
307
|
name,
|
|
306
|
-
series.value
|
|
308
|
+
series.value
|
|
309
|
+
.filter((entry) => !hiddenSeries.value.includes(entry.name))
|
|
310
|
+
.map((entry) => entry.name),
|
|
307
311
|
)
|
|
308
312
|
}
|
|
309
313
|
|