origam 2.41.0 → 2.41.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/CHANGELOG.md +49 -0
- package/dist/src/components/Alert/OrigamAlert.vue +1 -2
- package/dist/src/components/Audio/OrigamAudio.vue +15 -14
- package/dist/src/components/Badge/OrigamBadge.vue +6 -1
- package/dist/src/components/Bracket/OrigamBracket.vue +5 -5
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbDivider.vue +1 -2
- package/dist/src/components/Btn/OrigamBtn.vue +14 -15
- package/dist/src/components/Card/OrigamCard.vue +2 -1
- package/dist/src/components/Carousel/OrigamCarousel.vue +14 -13
- package/dist/src/components/Chart/OrigamChartBullet.vue +4 -1
- package/dist/src/components/Chart/OrigamChartPictorial.vue +3 -6
- package/dist/src/components/Chart/OrigamChartPolar.vue +2 -1
- package/dist/src/components/Chart/OrigamChartPolarBar.vue +3 -1
- package/dist/src/components/Chart/OrigamChartSankey.vue +9 -167
- package/dist/src/components/Chart/OrigamChartStreamgraph.vue +14 -12
- package/dist/src/components/Chart/OrigamChartSunburst.vue +10 -2
- package/dist/src/components/Chart/OrigamChartWordCloud.vue +39 -36
- package/dist/src/components/Checkbox/OrigamCheckboxBtn.vue +3 -4
- package/dist/src/components/Chip/OrigamChip.vue +2 -3
- package/dist/src/components/Chip/OrigamChipGroup.vue +2 -3
- package/dist/src/components/Clipboard/OrigamClipboard.vue +1 -1
- package/dist/src/components/Code/OrigamCode.vue +4 -2
- package/dist/src/components/ColorPicker/OrigamColorPicker.vue +5 -1
- package/dist/src/components/ColorPicker/OrigamColorPickerEdit.vue +1 -2
- package/dist/src/components/ColorPicker/OrigamColorPickerPreview.vue +1 -2
- package/dist/src/components/ColorPicker/OrigamColorPickerSwatches.vue +1 -2
- package/dist/src/components/CommandPalette/OrigamCommandPalette.vue +6 -2
- package/dist/src/components/ConfirmWrapper/OrigamConfirmWrapper.vue +2 -4
- package/dist/src/components/Counter/OrigamCounter.vue +1 -0
- package/dist/src/components/DataTable/OrigamDataTable.vue +2 -3
- package/dist/src/components/DataTable/OrigamDataTableGroupHeaderRow.vue +1 -2
- package/dist/src/components/DataTable/OrigamDataTableHeadersCellMobile.vue +3 -2
- package/dist/src/components/DataTable/OrigamDataTableRow.vue +2 -3
- package/dist/src/components/DataTable/OrigamDataTableRows.vue +43 -39
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +3 -4
- package/dist/src/components/DatePicker/OrigamDatePickerMonth.vue +1 -1
- package/dist/src/components/DatePickerField/OrigamDatePickerField.vue +1 -2
- package/dist/src/components/Dialog/OrigamDialog.vue +1 -2
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +2 -3
- package/dist/src/components/Field/OrigamField.vue +2 -6
- package/dist/src/components/FileField/OrigamFileField.vue +23 -6
- package/dist/src/components/FileField/OrigamFileFieldDragNDropItem.vue +3 -4
- package/dist/src/components/FileField/OrigamFileFieldListItem.vue +3 -4
- package/dist/src/components/Form/OrigamForm.vue +0 -2
- package/dist/src/components/InlineEdit/OrigamInlineEdit.vue +7 -7
- package/dist/src/components/Input/OrigamInput.vue +3 -11
- package/dist/src/components/List/OrigamListGroup.vue +2 -3
- package/dist/src/components/List/OrigamListItem.vue +4 -5
- package/dist/src/components/Media/OrigamMediaController.vue +12 -13
- package/dist/src/components/Media/OrigamMediaScrubber.vue +15 -12
- package/dist/src/components/Media/OrigamMediaVolumeControl.vue +4 -5
- package/dist/src/components/Menu/OrigamMenu.vue +1 -2
- package/dist/src/components/NumberField/OrigamNumberField.vue +7 -10
- package/dist/src/components/NumberFormat/OrigamNumberFormat.vue +7 -1
- package/dist/src/components/OtpInputField/OrigamOtpInputField.vue +1 -1
- package/dist/src/components/Pagination/OrigamPagination.vue +4 -5
- package/dist/src/components/Parallax/OrigamParallaxElement.vue +1 -4
- package/dist/src/components/PasswordField/OrigamPasswordField.vue +9 -7
- package/dist/src/components/Radio/OrigamRadioBtn.vue +2 -3
- package/dist/src/components/RatingField/OrigamRatingField.vue +1 -2
- package/dist/src/components/RatingField/OrigamRatingFieldItem.vue +2 -3
- package/dist/src/components/Select/OrigamSelect.vue +135 -105
- package/dist/src/components/SelectionControl/OrigamSelectionControl.vue +7 -2
- package/dist/src/components/Slide/OrigamSlideGroup.vue +7 -10
- package/dist/src/components/Snackbar/OrigamSnackbarItem.vue +9 -10
- package/dist/src/components/Stepper/OrigamStepper.vue +7 -11
- package/dist/src/components/Stepper/OrigamStepperItem.vue +2 -3
- package/dist/src/components/Switch/OrigamSwitch.vue +0 -9
- package/dist/src/components/Tabs/OrigamTabs.vue +1 -1
- package/dist/src/components/TextField/OrigamTextField.vue +2 -5
- package/dist/src/components/TextareaField/OrigamTextareaField.vue +3 -2
- package/dist/src/components/TextareaField/OrigamTextareaFieldRichToolbar.vue +13 -14
- package/dist/src/components/Transition/OrigamExpandX.vue +4 -10
- package/dist/src/components/Transition/OrigamExpandY.vue +4 -10
- package/dist/src/components/Transition/OrigamSnack.vue +2 -8
- package/dist/src/components/Treeview/OrigamTreeviewNode.vue +24 -18
- package/dist/src/components/Video/OrigamVideo.vue +14 -19
- package/dist/src/components/Window/OrigamWindow.vue +2 -3
- package/dist/src/composables/Audio/use-waveform.composable.cjs +24 -19
- package/dist/src/composables/Audio/use-waveform.composable.js +24 -19
- package/dist/src/composables/Calendar/calendar.composable.cjs +11 -11
- package/dist/src/composables/Calendar/calendar.composable.js +1 -1
- package/dist/src/composables/Chart/chart.composable.cjs +541 -415
- package/dist/src/composables/Chart/chart.composable.d.ts +2 -5
- package/dist/src/composables/Chart/chart.composable.js +392 -338
- package/dist/src/composables/Code/code.composable.cjs +4 -4
- package/dist/src/composables/Code/code.composable.js +1 -1
- package/dist/src/composables/Commons/color.composable.cjs +106 -48
- package/dist/src/composables/Commons/color.composable.js +55 -48
- package/dist/src/composables/Commons/display.composable.cjs +7 -1
- package/dist/src/composables/Commons/display.composable.js +2 -2
- package/dist/src/composables/Commons/dragResizer.composable.cjs +11 -10
- package/dist/src/composables/Commons/dragResizer.composable.js +2 -1
- package/dist/src/composables/Commons/group.composable.cjs +17 -14
- package/dist/src/composables/Commons/group.composable.js +19 -15
- package/dist/src/composables/Commons/nested.composable.cjs +16 -16
- package/dist/src/composables/Commons/nested.composable.d.ts +1 -1
- package/dist/src/composables/Commons/nested.composable.js +1 -1
- package/dist/src/composables/Commons/nestedItem.composable.cjs +3 -3
- package/dist/src/composables/Commons/nestedItem.composable.d.ts +1 -1
- package/dist/src/composables/Commons/nestedItem.composable.js +1 -1
- package/dist/src/composables/Commons/size.composable.cjs +1 -1
- package/dist/src/composables/Commons/size.composable.js +1 -1
- package/dist/src/composables/Commons/stateEffect.composable.cjs +54 -32
- package/dist/src/composables/Commons/stateEffect.composable.js +43 -33
- package/dist/src/composables/Commons/teleport.composable.cjs +2 -1
- package/dist/src/composables/Commons/teleport.composable.js +4 -1
- package/dist/src/composables/Commons/touch.composable.cjs +77 -33
- package/dist/src/composables/Commons/touch.composable.js +77 -33
- package/dist/src/composables/Commons/vModel.composable.cjs +1 -1
- package/dist/src/composables/Commons/vModel.composable.js +1 -1
- package/dist/src/composables/Commons/validation.composable.cjs +1 -1
- package/dist/src/composables/Commons/validation.composable.js +1 -1
- package/dist/src/composables/Commons/velocity.composable.cjs +5 -1
- package/dist/src/composables/Commons/velocity.composable.js +5 -1
- package/dist/src/composables/DataTable/headers.composable.cjs +36 -30
- package/dist/src/composables/DataTable/headers.composable.d.ts +1 -1
- package/dist/src/composables/DataTable/headers.composable.js +29 -23
- package/dist/src/composables/DataTable/headersCell.composable.cjs +2 -2
- package/dist/src/composables/DataTable/headersCell.composable.js +1 -1
- package/dist/src/composables/DataTable/select.composable.cjs +4 -4
- package/dist/src/composables/DataTable/select.composable.js +1 -1
- package/dist/src/composables/DataTable/sort.composable.cjs +6 -6
- package/dist/src/composables/DataTable/sort.composable.js +1 -1
- package/dist/src/composables/Form/form.composable.cjs +1 -1
- package/dist/src/composables/Form/form.composable.js +3 -1
- package/dist/src/composables/Masonry/masonry.composable.cjs +29 -20
- package/dist/src/composables/Masonry/masonry.composable.d.ts +0 -14
- package/dist/src/composables/Masonry/masonry.composable.js +29 -20
- package/dist/src/composables/NumberFormat/number-format.composable.cjs +28 -23
- package/dist/src/composables/NumberFormat/number-format.composable.js +28 -23
- package/dist/src/composables/Parallax/parallax.composable.cjs +9 -9
- package/dist/src/composables/Parallax/parallax.composable.js +3 -3
- package/dist/src/composables/Parallax/transform.composable.cjs +14 -13
- package/dist/src/composables/Parallax/transform.composable.js +2 -1
- package/dist/src/composables/PasswordField/passwordStrength.composable.cjs +2 -2
- package/dist/src/composables/PasswordField/passwordStrength.composable.js +1 -1
- package/dist/src/composables/QrCode/qr-code.composable.cjs +1 -1
- package/dist/src/composables/QrCode/qr-code.composable.js +1 -1
- package/dist/src/composables/Sheet/sheetSwipe.composable.cjs +3 -4
- package/dist/src/composables/Sheet/sheetSwipe.composable.js +4 -4
- package/dist/src/composables/TextareaField/textarea-field-rich.composable.cjs +31 -31
- package/dist/src/composables/TextareaField/textarea-field-rich.composable.js +1 -1
- package/dist/src/composables/Watermark/watermark.composable.cjs +1 -1
- package/dist/src/composables/Watermark/watermark.composable.js +1 -1
- package/dist/src/consts/Audio/audio.const.cjs +5 -4
- package/dist/src/consts/Audio/audio.const.d.ts +2 -1
- package/dist/src/consts/Audio/audio.const.js +2 -1
- package/dist/src/consts/Blockquote/blockquote.const.cjs +3 -3
- package/dist/src/consts/Blockquote/blockquote.const.js +1 -1
- package/dist/src/consts/Bracket/bracket.const.cjs +4 -3
- package/dist/src/consts/Bracket/bracket.const.js +2 -1
- package/dist/src/consts/Code/code.const.cjs +3 -3
- package/dist/src/consts/Code/code.const.d.ts +1 -1
- package/dist/src/consts/Code/code.const.js +1 -1
- package/dist/src/consts/Commons/autocomplete.const.cjs +2 -2
- package/dist/src/consts/Commons/autocomplete.const.d.ts +1 -1
- package/dist/src/consts/Commons/autocomplete.const.js +1 -1
- package/dist/src/consts/Commons/display.const.cjs +2 -2
- package/dist/src/consts/Commons/display.const.js +1 -1
- package/dist/src/consts/Commons/hotkey.const.cjs +2 -2
- package/dist/src/consts/Commons/hotkey.const.js +1 -1
- package/dist/src/consts/Commons/margin.const.cjs +1 -1
- package/dist/src/consts/Commons/margin.const.js +1 -1
- package/dist/src/consts/Commons/padding.const.cjs +1 -1
- package/dist/src/consts/Commons/padding.const.js +1 -1
- package/dist/src/consts/Commons/rounded.const.cjs +6 -2
- package/dist/src/consts/Commons/rounded.const.js +6 -2
- package/dist/src/consts/EmptyState/empty-state.const.cjs +12 -12
- package/dist/src/consts/EmptyState/empty-state.const.js +6 -6
- package/dist/src/consts/PasswordField/password-field.const.cjs +1 -1
- package/dist/src/consts/PasswordField/password-field.const.js +1 -1
- package/dist/src/consts/QrCode/qr-code.const.cjs +2 -2
- package/dist/src/consts/QrCode/qr-code.const.js +1 -1
- package/dist/src/consts/TextField/text-field.const.cjs +21 -21
- package/dist/src/consts/TextField/text-field.const.js +1 -1
- package/dist/src/consts/TextareaField/textarea-field.const.cjs +32 -4
- package/dist/src/consts/TextareaField/textarea-field.const.d.ts +1 -0
- package/dist/src/consts/TextareaField/textarea-field.const.js +29 -1
- package/dist/src/directives/Contrast/contrast.directive.cjs +5 -3
- package/dist/src/directives/Contrast/contrast.directive.js +5 -3
- package/dist/src/directives/Intersect/intersect.directive.cjs +2 -1
- package/dist/src/directives/Intersect/intersect.directive.js +2 -1
- package/dist/src/interfaces/Chart/chart.interface.d.ts +70 -1
- package/dist/src/interfaces/ColorPicker/color-picker.interface.d.ts +1 -1
- package/dist/src/interfaces/Commons/border.interface.d.ts +11 -10
- package/dist/src/interfaces/Commons/filters.interface.d.ts +7 -0
- package/dist/src/interfaces/Commons/margin.interface.d.ts +12 -11
- package/dist/src/interfaces/Commons/padding.interface.d.ts +12 -11
- package/dist/src/interfaces/Commons/ripple.interface.d.ts +1 -3
- package/dist/src/interfaces/Commons/rounded.interface.d.ts +10 -9
- package/dist/src/interfaces/DataTable/sort.interface.d.ts +6 -0
- package/dist/src/interfaces/Grid/grid.interface.d.ts +4 -4
- package/dist/src/interfaces/SliderField/slider-field.interface.d.ts +4 -4
- package/dist/src/origam-core.cjs +51 -33
- package/dist/src/origam-core.js +21 -27
- package/dist/src/types/Commons/box-value.type.cjs +1 -0
- package/dist/src/types/Commons/box-value.type.d.ts +1 -0
- package/dist/src/types/Commons/box-value.type.js +0 -0
- package/dist/src/types/Commons/location.type.d.ts +13 -0
- package/dist/src/types/Commons/point.type.d.ts +1 -1
- package/dist/src/types/DataTable/data-table.type.d.ts +1 -0
- package/dist/src/types/Grid/grid.type.d.ts +7 -0
- package/dist/src/types/SliderField/slider-field.type.d.ts +8 -0
- package/dist/src/utils/Bracket/bracket-surface.util.cjs +9 -2
- package/dist/src/utils/Bracket/bracket-surface.util.js +9 -2
- package/dist/src/utils/Calendar/rrule.util.cjs +12 -7
- package/dist/src/utils/Calendar/rrule.util.js +12 -7
- package/dist/src/utils/Chart/chart-point.util.cjs +15 -0
- package/dist/src/utils/Chart/chart-point.util.d.ts +11 -0
- package/dist/src/utils/Chart/chart-point.util.js +8 -0
- package/dist/src/utils/Chart/sankey-layout.util.cjs +144 -0
- package/dist/src/utils/Chart/sankey-layout.util.d.ts +27 -0
- package/dist/src/utils/Chart/sankey-layout.util.js +130 -0
- package/dist/src/utils/Code/parse-highlight-lines.util.cjs +17 -14
- package/dist/src/utils/Code/parse-highlight-lines.util.js +17 -14
- package/dist/src/utils/CommandPalette/fuzzy-match.util.cjs +13 -9
- package/dist/src/utils/CommandPalette/fuzzy-match.util.js +13 -9
- package/dist/src/utils/Commons/anchor.util.cjs +6 -1
- package/dist/src/utils/Commons/anchor.util.js +6 -1
- package/dist/src/utils/Commons/apply-mask.util.cjs +11 -14
- package/dist/src/utils/Commons/apply-mask.util.js +7 -10
- package/dist/src/utils/Commons/apply-theme.util.cjs +6 -4
- package/dist/src/utils/Commons/apply-theme.util.js +6 -4
- package/dist/src/utils/Commons/bindProps.util.cjs +3 -5
- package/dist/src/utils/Commons/bindProps.util.js +3 -5
- package/dist/src/utils/Commons/color.util.cjs +43 -36
- package/dist/src/utils/Commons/color.util.js +44 -31
- package/dist/src/utils/Commons/commons.util.cjs +3 -3
- package/dist/src/utils/Commons/commons.util.js +3 -3
- package/dist/src/utils/Commons/console.util.cjs +6 -0
- package/dist/src/utils/Commons/console.util.d.ts +11 -0
- package/dist/src/utils/Commons/console.util.js +5 -0
- package/dist/src/utils/Commons/date.util.cjs +2 -27
- package/dist/src/utils/Commons/date.util.js +2 -27
- package/dist/src/utils/Commons/display.util.cjs +10 -1
- package/dist/src/utils/Commons/display.util.d.ts +8 -1
- package/dist/src/utils/Commons/display.util.js +9 -1
- package/dist/src/utils/Commons/eventListener.util.cjs +1 -2
- package/dist/src/utils/Commons/eventListener.util.js +1 -2
- package/dist/src/utils/Commons/filters.util.cjs +48 -34
- package/dist/src/utils/Commons/filters.util.d.ts +3 -8
- package/dist/src/utils/Commons/filters.util.js +47 -34
- package/dist/src/utils/Commons/forwardRefs.util.cjs +44 -40
- package/dist/src/utils/Commons/forwardRefs.util.js +44 -40
- package/dist/src/utils/Commons/group.util.cjs +1 -1
- package/dist/src/utils/Commons/group.util.js +1 -1
- package/dist/src/utils/Commons/hotkey.util.cjs +65 -61
- package/dist/src/utils/Commons/hotkey.util.js +56 -53
- package/dist/src/utils/Commons/hover.util.cjs +2 -2
- package/dist/src/utils/Commons/hover.util.js +2 -2
- package/dist/src/utils/Commons/locale.util.cjs +1 -1
- package/dist/src/utils/Commons/locale.util.js +1 -1
- package/dist/src/utils/Commons/location.util.cjs +87 -92
- package/dist/src/utils/Commons/location.util.js +75 -83
- package/dist/src/utils/Commons/nested.util.cjs +11 -11
- package/dist/src/utils/Commons/nested.util.js +1 -1
- package/dist/src/utils/Commons/point.util.cjs +16 -14
- package/dist/src/utils/Commons/point.util.js +13 -8
- package/dist/src/utils/Commons/ripple.util.cjs +4 -4
- package/dist/src/utils/Commons/ripple.util.js +4 -4
- package/dist/src/utils/Commons/scroll.util.cjs +9 -6
- package/dist/src/utils/Commons/scroll.util.js +9 -6
- package/dist/src/utils/Commons/token-name.util.cjs +22 -21
- package/dist/src/utils/Commons/token-name.util.js +22 -21
- package/dist/src/utils/Commons/validate-pattern.util.cjs +6 -6
- package/dist/src/utils/Commons/validate-pattern.util.js +1 -1
- package/dist/src/utils/DataTable/headers.util.cjs +20 -26
- package/dist/src/utils/DataTable/headers.util.js +18 -26
- package/dist/src/utils/DataTable/sort.util.cjs +41 -47
- package/dist/src/utils/DataTable/sort.util.d.ts +2 -7
- package/dist/src/utils/DataTable/sort.util.js +49 -47
- package/dist/src/utils/List/list-item.util.cjs +6 -1
- package/dist/src/utils/List/list-item.util.js +6 -1
- package/dist/src/utils/Parallax/parallax-element.util.cjs +13 -14
- package/dist/src/utils/Parallax/parallax-element.util.js +10 -11
- package/dist/src/utils/Slide/slide-group.util.cjs +4 -4
- package/dist/src/utils/Slide/slide-group.util.js +4 -4
- package/dist/src/utils/TextareaField/html-to-markdown.util.cjs +5 -36
- package/dist/src/utils/TextareaField/html-to-markdown.util.js +5 -36
- package/dist/src/utils/TextareaField/sanitize-html.util.cjs +18 -22
- package/dist/src/utils/TextareaField/sanitize-html.util.js +19 -23
- package/dist/src/utils/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
computed,
|
|
3
3
|
ref
|
|
4
4
|
} from "vue";
|
|
5
|
-
import { CHART_SMOOTHING, CHART_STACKING, CHART_TYPE
|
|
5
|
+
import { CHART_SMOOTHING, CHART_STACKING, CHART_TYPE } from "../../enums/Chart/chart.enum.js";
|
|
6
|
+
import { INTENT } from "../../enums/Commons/intent.enum.js";
|
|
6
7
|
import {
|
|
7
8
|
arcPath,
|
|
8
9
|
areaPath,
|
|
@@ -247,28 +248,30 @@ const computeYRange = (series, stacked, stacking, yMinOverride, yMaxOverride) =>
|
|
|
247
248
|
if (stacked && stacking === CHART_STACKING.PERCENT) {
|
|
248
249
|
return { min: CHART_PERCENT_MIN, max: CHART_PERCENT_MAX };
|
|
249
250
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
stackMax = Math.max(stackMax, positive);
|
|
265
|
-
stackMin = Math.min(stackMin, negative);
|
|
251
|
+
return stacked ? stackedYRange(visible, yMinOverride, yMaxOverride) : plainYRange(visible, yMinOverride, yMaxOverride);
|
|
252
|
+
};
|
|
253
|
+
const entryValue = (entry) => typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
254
|
+
const stackedYRange = (visible, yMinOverride, yMaxOverride) => {
|
|
255
|
+
const maxLength = Math.max(...visible.map((s) => s.data.length));
|
|
256
|
+
let stackMax = 0;
|
|
257
|
+
let stackMin = 0;
|
|
258
|
+
for (let i = 0; i < maxLength; i++) {
|
|
259
|
+
let positive = 0;
|
|
260
|
+
let negative = 0;
|
|
261
|
+
for (const s of visible) {
|
|
262
|
+
const y = entryValue(s.data[i]);
|
|
263
|
+
if (y >= 0) positive += y;
|
|
264
|
+
else negative += y;
|
|
266
265
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
max: yMaxOverride ?? stackMax
|
|
270
|
-
};
|
|
266
|
+
stackMax = Math.max(stackMax, positive);
|
|
267
|
+
stackMin = Math.min(stackMin, negative);
|
|
271
268
|
}
|
|
269
|
+
return {
|
|
270
|
+
min: yMinOverride ?? stackMin,
|
|
271
|
+
max: yMaxOverride ?? stackMax
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
const dataYExtent = (visible) => {
|
|
272
275
|
let min = Number.POSITIVE_INFINITY;
|
|
273
276
|
let max = Number.NEGATIVE_INFINITY;
|
|
274
277
|
for (const s of visible) {
|
|
@@ -278,6 +281,10 @@ const computeYRange = (series, stacked, stacking, yMinOverride, yMaxOverride) =>
|
|
|
278
281
|
if (y > max) max = y;
|
|
279
282
|
}
|
|
280
283
|
}
|
|
284
|
+
return { min, max };
|
|
285
|
+
};
|
|
286
|
+
const plainYRange = (visible, yMinOverride, yMaxOverride) => {
|
|
287
|
+
let { min, max } = dataYExtent(visible);
|
|
281
288
|
if (!Number.isFinite(min)) min = 0;
|
|
282
289
|
if (!Number.isFinite(max)) max = 1;
|
|
283
290
|
if (min === max) {
|
|
@@ -288,6 +295,282 @@ const computeYRange = (series, stacked, stacking, yMinOverride, yMaxOverride) =>
|
|
|
288
295
|
max: yMaxOverride ?? max
|
|
289
296
|
};
|
|
290
297
|
};
|
|
298
|
+
const indexVisibleSeries = (series) => series.map((s, i) => ({ s, i })).filter(({ s }) => s.visible !== false);
|
|
299
|
+
const maxDataLength = (visible) => Math.max(...visible.map(({ s }) => s.data.length), 0);
|
|
300
|
+
const positiveColumnTotal = (visible, dataIdx) => {
|
|
301
|
+
let total = 0;
|
|
302
|
+
for (const { s } of visible) {
|
|
303
|
+
const y = entryValue(s.data[dataIdx]);
|
|
304
|
+
if (y > 0) total += y;
|
|
305
|
+
}
|
|
306
|
+
return total;
|
|
307
|
+
};
|
|
308
|
+
const setSeriesSlot = (map, seriesIdx, dataIdx, value) => {
|
|
309
|
+
if (!map.has(seriesIdx)) map.set(seriesIdx, []);
|
|
310
|
+
map.get(seriesIdx)[dataIdx] = value;
|
|
311
|
+
};
|
|
312
|
+
const fillPercentStackOffsets = (offsets, visible) => {
|
|
313
|
+
const length = maxDataLength(visible);
|
|
314
|
+
for (let dataIdx = 0; dataIdx < length; dataIdx++) {
|
|
315
|
+
const safeTot = positiveColumnTotal(visible, dataIdx) || 1;
|
|
316
|
+
let runningPct = 0;
|
|
317
|
+
for (const { s, i } of visible) {
|
|
318
|
+
const y = entryValue(s.data[dataIdx]);
|
|
319
|
+
setSeriesSlot(offsets, i, dataIdx, runningPct);
|
|
320
|
+
if (y > 0) runningPct += y / safeTot * CHART_PERCENT_MAX;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
const fillSignedStackOffsets = (offsets, visible) => {
|
|
325
|
+
const length = maxDataLength(visible);
|
|
326
|
+
for (let dataIdx = 0; dataIdx < length; dataIdx++) {
|
|
327
|
+
let runningPositive = 0;
|
|
328
|
+
let runningNegative = 0;
|
|
329
|
+
for (const { s, i } of visible) {
|
|
330
|
+
const y = entryValue(s.data[dataIdx]);
|
|
331
|
+
setSeriesSlot(offsets, i, dataIdx, y >= 0 ? runningPositive : runningNegative);
|
|
332
|
+
if (y >= 0) runningPositive += y;
|
|
333
|
+
else runningNegative += y;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const isLineFamily = (kind) => kind === CHART_TYPE.LINE || kind === CHART_TYPE.AREA || kind === CHART_TYPE.SPLINE || kind === CHART_TYPE.STEPPED_LINE;
|
|
338
|
+
const lineGeometry = (kind, smoothing, pts) => {
|
|
339
|
+
if (kind === CHART_TYPE.STEPPED_LINE) return { dLine: steppedPath(pts), areaMode: "stepped" };
|
|
340
|
+
const effectiveSmoothing = kind === CHART_TYPE.SPLINE && smoothing === CHART_SMOOTHING.NONE ? CHART_SMOOTHING.MONOTONE : smoothing;
|
|
341
|
+
if (effectiveSmoothing === CHART_SMOOTHING.MONOTONE) return { dLine: monotonePath(pts), areaMode: "monotone" };
|
|
342
|
+
if (effectiveSmoothing === CHART_SMOOTHING.CURVE) return { dLine: smoothPath(pts), areaMode: true };
|
|
343
|
+
return { dLine: linePath(pts), areaMode: false };
|
|
344
|
+
};
|
|
345
|
+
const pushLinePaths = (out, frame) => {
|
|
346
|
+
const { series, seriesIdx, color, kind, pts, smoothing, baseline } = frame;
|
|
347
|
+
const { dLine, areaMode } = lineGeometry(kind, smoothing, pts);
|
|
348
|
+
const length = kind === CHART_TYPE.STEPPED_LINE ? steppedPathLength(pts) : computePathLength(pts);
|
|
349
|
+
if (kind === CHART_TYPE.AREA) {
|
|
350
|
+
out.push({
|
|
351
|
+
seriesIndex: seriesIdx,
|
|
352
|
+
kind: "path",
|
|
353
|
+
d: areaPath(pts, baseline, areaMode),
|
|
354
|
+
color,
|
|
355
|
+
series,
|
|
356
|
+
pathLength: length,
|
|
357
|
+
variant: "fill"
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
out.push({
|
|
361
|
+
seriesIndex: seriesIdx,
|
|
362
|
+
kind: "path",
|
|
363
|
+
d: dLine,
|
|
364
|
+
color,
|
|
365
|
+
series,
|
|
366
|
+
pathLength: length,
|
|
367
|
+
variant: kind === CHART_TYPE.AREA ? "stroke" : void 0
|
|
368
|
+
});
|
|
369
|
+
for (let dataIdx = 0; dataIdx < pts.length; dataIdx++) {
|
|
370
|
+
out.push({
|
|
371
|
+
seriesIndex: seriesIdx,
|
|
372
|
+
kind: "circle",
|
|
373
|
+
circle: {
|
|
374
|
+
cx: pts[dataIdx][0],
|
|
375
|
+
cy: pts[dataIdx][1],
|
|
376
|
+
r: CHART_POINT_MARKER_RADIUS
|
|
377
|
+
},
|
|
378
|
+
color,
|
|
379
|
+
series,
|
|
380
|
+
dataIndex: dataIdx
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const projectToPlotX = (v, min, span, x0, x1) => {
|
|
385
|
+
const ratio = (v - min) / span;
|
|
386
|
+
const px = x0 + ratio * (x1 - x0);
|
|
387
|
+
if (px < x0) return x0;
|
|
388
|
+
if (px > x1) return x1;
|
|
389
|
+
return px;
|
|
390
|
+
};
|
|
391
|
+
const barThickness = (frame, slotPx) => frame.stacked ? slotPx * CHART_BAR_SLOT_FILL_RATIO : slotPx * CHART_BAR_SLOT_FILL_RATIO / Math.max(1, frame.visibleCount);
|
|
392
|
+
const barBandStart = (frame, slotCenter, slotPx, thickness) => frame.stacked ? slotCenter - thickness / 2 : slotCenter - slotPx * CHART_BAR_SLOT_FILL_RATIO / 2 + frame.visibleIdxInGroup * thickness;
|
|
393
|
+
const columnRect = (frame, dataIdx, slotPx, renderY, offset) => {
|
|
394
|
+
const centerX = frame.plot.x0 + (dataIdx + 0.5) * slotPx;
|
|
395
|
+
const barWidth = barThickness(frame, slotPx);
|
|
396
|
+
const top = frame.yFn(renderY + offset);
|
|
397
|
+
const base = frame.yFn(offset);
|
|
398
|
+
return {
|
|
399
|
+
x: barBandStart(frame, centerX, slotPx, barWidth),
|
|
400
|
+
y: Math.min(top, base),
|
|
401
|
+
width: barWidth,
|
|
402
|
+
height: Math.abs(base - top)
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
const horizontalBarRect = (frame, dataIdx, slotPx, renderY, offset, horizSpan) => {
|
|
406
|
+
const { x0, x1, y0, y1 } = frame.plot;
|
|
407
|
+
const slots = Math.max(1, frame.groupCount);
|
|
408
|
+
const slotCenterY = slots === 1 ? (y0 + y1) / 2 : y0 + (dataIdx + 0.5) * slotPx;
|
|
409
|
+
const barHeight = barThickness(frame, slotPx);
|
|
410
|
+
const rightPx = projectToPlotX(renderY + offset, frame.yRange.min, horizSpan, x0, x1);
|
|
411
|
+
const basePx = projectToPlotX(offset, frame.yRange.min, horizSpan, x0, x1);
|
|
412
|
+
return {
|
|
413
|
+
x: Math.min(rightPx, basePx),
|
|
414
|
+
y: barBandStart(frame, slotCenterY, slotPx, barHeight),
|
|
415
|
+
width: Math.abs(rightPx - basePx),
|
|
416
|
+
height: barHeight
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
const pushBarPaths = (out, frame) => {
|
|
420
|
+
const { plot, kind, groupCount, series, seriesIdx, color, normalised, stacked, isPercent } = frame;
|
|
421
|
+
const slotPx = kind === CHART_TYPE.COLUMN ? (plot.x1 - plot.x0) / Math.max(1, groupCount) : (plot.y1 - plot.y0) / Math.max(1, groupCount);
|
|
422
|
+
const horizSpan = Math.max(CHART_EPSILON, frame.yRange.max - frame.yRange.min);
|
|
423
|
+
for (let dataIdx = 0; dataIdx < normalised.length; dataIdx++) {
|
|
424
|
+
const renderY = isPercent ? frame.percentShares?.[dataIdx] ?? 0 : normalised[dataIdx].y;
|
|
425
|
+
const offset = stacked ? frame.stackOffsets[dataIdx] ?? 0 : 0;
|
|
426
|
+
out.push({
|
|
427
|
+
seriesIndex: seriesIdx,
|
|
428
|
+
kind: "rect",
|
|
429
|
+
rect: kind === CHART_TYPE.COLUMN ? columnRect(frame, dataIdx, slotPx, renderY, offset) : horizontalBarRect(frame, dataIdx, slotPx, renderY, offset, horizSpan),
|
|
430
|
+
color,
|
|
431
|
+
series,
|
|
432
|
+
dataIndex: dataIdx
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const scatterX = (entry) => {
|
|
437
|
+
const xv = typeof entry === "number" ? entry : entry.x;
|
|
438
|
+
return typeof xv === "number" ? xv : 0;
|
|
439
|
+
};
|
|
440
|
+
const scatterZ = (entry) => typeof entry !== "number" && typeof entry.z === "number" && Number.isFinite(entry.z) ? entry.z : void 0;
|
|
441
|
+
const boundsOf = (values) => {
|
|
442
|
+
let min = Infinity;
|
|
443
|
+
let max = -Infinity;
|
|
444
|
+
for (const v of values) {
|
|
445
|
+
if (v < min) min = v;
|
|
446
|
+
if (v > max) max = v;
|
|
447
|
+
}
|
|
448
|
+
return { min, max };
|
|
449
|
+
};
|
|
450
|
+
const scatterExtent = (scatterSeries) => {
|
|
451
|
+
const entries = scatterSeries.flatMap((sp) => [...sp.data]);
|
|
452
|
+
const { min: xMin, max: xMax } = boundsOf(entries.map(scatterX));
|
|
453
|
+
const zs = entries.map(scatterZ).filter((z) => z !== void 0);
|
|
454
|
+
const { min: zMin, max: zMax } = boundsOf(zs);
|
|
455
|
+
return { xMin, xMax, zMin, zMax, hasZ: zs.length > 0 };
|
|
456
|
+
};
|
|
457
|
+
const pushScatterPaths = (out, frame) => {
|
|
458
|
+
const { plot, series, seriesIdx, color, normalised, yFn } = frame;
|
|
459
|
+
const { xMin, xMax, zMin, zMax, hasZ } = scatterExtent(frame.scatterSeries);
|
|
460
|
+
const xSpan = Math.max(CHART_EPSILON, xMax - xMin);
|
|
461
|
+
const zSpan = Math.max(CHART_EPSILON, zMax - zMin);
|
|
462
|
+
const radiusFor = (z) => {
|
|
463
|
+
if (!hasZ || typeof z !== "number" || !Number.isFinite(z)) return CHART_SCATTER_DEFAULT_RADIUS;
|
|
464
|
+
const ratio = zSpan === 0 ? 0.5 : (z - zMin) / zSpan;
|
|
465
|
+
return CHART_SCATTER_MIN_RADIUS + ratio * (CHART_SCATTER_MAX_RADIUS - CHART_SCATTER_MIN_RADIUS);
|
|
466
|
+
};
|
|
467
|
+
for (let dataIdx = 0; dataIdx < normalised.length; dataIdx++) {
|
|
468
|
+
const p = normalised[dataIdx];
|
|
469
|
+
const cxRaw = typeof p.x === "number" ? p.x : Number(p.x);
|
|
470
|
+
out.push({
|
|
471
|
+
seriesIndex: seriesIdx,
|
|
472
|
+
kind: "circle",
|
|
473
|
+
circle: {
|
|
474
|
+
cx: projectToPlotX(Number.isFinite(cxRaw) ? cxRaw : 0, xMin, xSpan, plot.x0, plot.x1),
|
|
475
|
+
cy: yFn(p.y),
|
|
476
|
+
r: radiusFor(p.z)
|
|
477
|
+
},
|
|
478
|
+
color,
|
|
479
|
+
series,
|
|
480
|
+
dataIndex: dataIdx
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const pushRadarPaths = (out, frame) => {
|
|
485
|
+
const { plot, axes, series, seriesIdx, color, normalised, yRange } = frame;
|
|
486
|
+
if (!axes) return;
|
|
487
|
+
const radius = Math.max(
|
|
488
|
+
CHART_RADAR_MIN_RADIUS,
|
|
489
|
+
Math.min(plot.x1 - plot.x0, plot.y1 - plot.y0) / 2 - CHART_RADAR_RADIUS_INSET
|
|
490
|
+
);
|
|
491
|
+
const pts = normalised.map((p, i) => {
|
|
492
|
+
const yRangeSize = Math.max(CHART_EPSILON, yRange.max - yRange.min);
|
|
493
|
+
const ratio = (p.y - yRange.min) / yRangeSize;
|
|
494
|
+
const angle = i / axes * Math.PI * 2;
|
|
495
|
+
return polarToCartesian(plot.cx, plot.cy, radius * ratio, angle);
|
|
496
|
+
});
|
|
497
|
+
out.push({
|
|
498
|
+
seriesIndex: seriesIdx,
|
|
499
|
+
kind: "polygon",
|
|
500
|
+
d: polygonPath(pts),
|
|
501
|
+
color,
|
|
502
|
+
series
|
|
503
|
+
});
|
|
504
|
+
for (let i = 0; i < pts.length; i++) {
|
|
505
|
+
out.push({
|
|
506
|
+
seriesIndex: seriesIdx,
|
|
507
|
+
kind: "circle",
|
|
508
|
+
circle: { cx: pts[i][0], cy: pts[i][1], r: CHART_RADAR_MARKER_RADIUS },
|
|
509
|
+
color,
|
|
510
|
+
series,
|
|
511
|
+
dataIndex: i
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const pieSliceLabel = (cats, i, entry) => {
|
|
516
|
+
if (cats[i] != null) return String(cats[i]);
|
|
517
|
+
if (entry != null && typeof entry === "object") return String(entry.x);
|
|
518
|
+
return `${CHART_SLICE_LABEL_PREFIX} ${i + 1}`;
|
|
519
|
+
};
|
|
520
|
+
const pieSliceColor = (scheme, dataIdx, series) => {
|
|
521
|
+
if (series.color) return resolveColor(series.color);
|
|
522
|
+
return resolveColor(scheme[dataIdx % scheme.length]);
|
|
523
|
+
};
|
|
524
|
+
const pieRingSlices = (data, isSingleRing, hidden, cats) => {
|
|
525
|
+
const slices = [];
|
|
526
|
+
for (let i = 0; i < data.length; i++) {
|
|
527
|
+
const entry = data[i];
|
|
528
|
+
if (isSingleRing && hidden.has(pieSliceLabel(cats, i, entry))) continue;
|
|
529
|
+
const v = entryValue(entry);
|
|
530
|
+
if (Number.isFinite(v) && v > 0) slices.push({ v, i });
|
|
531
|
+
}
|
|
532
|
+
return slices;
|
|
533
|
+
};
|
|
534
|
+
const buildPiePaths = (frame) => {
|
|
535
|
+
const out = [];
|
|
536
|
+
const { plot, series, scheme, hidden } = frame;
|
|
537
|
+
const outerR = Math.max(
|
|
538
|
+
CHART_PIE_MIN_RADIUS,
|
|
539
|
+
Math.min(plot.x1 - plot.x0, plot.y1 - plot.y0) / 2 - CHART_PIE_RADIUS_INSET
|
|
540
|
+
);
|
|
541
|
+
const baseInner = frame.isDonut ? outerR * frame.donutHoleSize : 0;
|
|
542
|
+
const visibleSeries = frame.pieSeriesList.filter((s) => s.visible !== false);
|
|
543
|
+
if (visibleSeries.length === 0) return out;
|
|
544
|
+
const bandThickness = (outerR - baseInner) / visibleSeries.length;
|
|
545
|
+
const isSingleRing = visibleSeries.length === 1;
|
|
546
|
+
for (let ringIdx = 0; ringIdx < visibleSeries.length; ringIdx++) {
|
|
547
|
+
const s = visibleSeries[ringIdx];
|
|
548
|
+
const ringInner = baseInner + bandThickness * ringIdx;
|
|
549
|
+
const ringOuter = baseInner + bandThickness * (ringIdx + 1);
|
|
550
|
+
const slices = pieRingSlices(
|
|
551
|
+
s.data,
|
|
552
|
+
isSingleRing,
|
|
553
|
+
hidden,
|
|
554
|
+
frame.categories
|
|
555
|
+
);
|
|
556
|
+
const ringTotal = slices.reduce((acc, { v }) => acc + v, 0);
|
|
557
|
+
if (ringTotal === 0) continue;
|
|
558
|
+
let angle = 0;
|
|
559
|
+
for (const { v, i } of slices) {
|
|
560
|
+
const endAngle = angle + v / ringTotal * Math.PI * 2;
|
|
561
|
+
out.push({
|
|
562
|
+
seriesIndex: series.indexOf(s),
|
|
563
|
+
kind: "path",
|
|
564
|
+
d: arcPath(plot.cx, plot.cy, ringOuter, ringInner, angle, endAngle),
|
|
565
|
+
color: pieSliceColor(scheme, i, s),
|
|
566
|
+
series: s,
|
|
567
|
+
dataIndex: i
|
|
568
|
+
});
|
|
569
|
+
angle = endAngle;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return out;
|
|
573
|
+
};
|
|
291
574
|
const niceStep = (range, count) => {
|
|
292
575
|
if (range <= 0 || count <= 0) return 1;
|
|
293
576
|
const rough = range / count;
|
|
@@ -491,345 +774,116 @@ export const useChart = (options) => {
|
|
|
491
774
|
const stackOffsets = computed(() => {
|
|
492
775
|
const offsets = /* @__PURE__ */ new Map();
|
|
493
776
|
if (!options.stacked()) return offsets;
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
if (isPercent) {
|
|
498
|
-
for (let dataIdx = 0; dataIdx < length; dataIdx++) {
|
|
499
|
-
let total = 0;
|
|
500
|
-
for (const { s } of visible) {
|
|
501
|
-
const entry = s.data[dataIdx];
|
|
502
|
-
const y = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
503
|
-
if (y > 0) total += y;
|
|
504
|
-
}
|
|
505
|
-
const safeTot = total || 1;
|
|
506
|
-
let runningPct = 0;
|
|
507
|
-
for (const { s, i } of visible) {
|
|
508
|
-
const entry = s.data[dataIdx];
|
|
509
|
-
const y = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
510
|
-
if (!offsets.has(i)) offsets.set(i, []);
|
|
511
|
-
offsets.get(i)[dataIdx] = runningPct;
|
|
512
|
-
if (y > 0) runningPct += y / safeTot * CHART_PERCENT_MAX;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
777
|
+
const visible = indexVisibleSeries(options.series());
|
|
778
|
+
if (effectiveStacking.value === CHART_STACKING.PERCENT) {
|
|
779
|
+
fillPercentStackOffsets(offsets, visible);
|
|
515
780
|
} else {
|
|
516
|
-
|
|
517
|
-
let runningPositive = 0;
|
|
518
|
-
let runningNegative = 0;
|
|
519
|
-
for (const { s, i } of visible) {
|
|
520
|
-
const entry = s.data[dataIdx];
|
|
521
|
-
const y = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
522
|
-
if (!offsets.has(i)) offsets.set(i, []);
|
|
523
|
-
offsets.get(i)[dataIdx] = y >= 0 ? runningPositive : runningNegative;
|
|
524
|
-
if (y >= 0) runningPositive += y;
|
|
525
|
-
else runningNegative += y;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
781
|
+
fillSignedStackOffsets(offsets, visible);
|
|
528
782
|
}
|
|
529
783
|
return offsets;
|
|
530
784
|
});
|
|
531
785
|
const percentValues = computed(() => {
|
|
532
786
|
const pctMap = /* @__PURE__ */ new Map();
|
|
533
787
|
if (!options.stacked() || effectiveStacking.value !== CHART_STACKING.PERCENT) return pctMap;
|
|
534
|
-
const visible = options.series()
|
|
535
|
-
const length =
|
|
788
|
+
const visible = indexVisibleSeries(options.series());
|
|
789
|
+
const length = maxDataLength(visible);
|
|
536
790
|
for (let dataIdx = 0; dataIdx < length; dataIdx++) {
|
|
537
|
-
|
|
538
|
-
for (const { s } of visible) {
|
|
539
|
-
const entry = s.data[dataIdx];
|
|
540
|
-
const y = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
541
|
-
if (y > 0) total += y;
|
|
542
|
-
}
|
|
543
|
-
const safeTot = total || 1;
|
|
791
|
+
const safeTot = positiveColumnTotal(visible, dataIdx) || 1;
|
|
544
792
|
for (const { s, i } of visible) {
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
if (!pctMap.has(i)) pctMap.set(i, []);
|
|
548
|
-
pctMap.get(i)[dataIdx] = y > 0 ? y / safeTot * CHART_PERCENT_MAX : 0;
|
|
793
|
+
const y = entryValue(s.data[dataIdx]);
|
|
794
|
+
setSeriesSlot(pctMap, i, dataIdx, y > 0 ? y / safeTot * CHART_PERCENT_MAX : 0);
|
|
549
795
|
}
|
|
550
796
|
}
|
|
551
797
|
return pctMap;
|
|
552
798
|
});
|
|
799
|
+
const pushSeriesPaths = (out, series, seriesIdx, cats, smoothing) => {
|
|
800
|
+
const s = series[seriesIdx];
|
|
801
|
+
if (s.visible === false) return;
|
|
802
|
+
const plotRect = plot.value;
|
|
803
|
+
const kind = effectiveType(s);
|
|
804
|
+
const normalised = toPoints(s);
|
|
805
|
+
const onSecondaryAxis = (s.yAxis ?? 0) === 1;
|
|
806
|
+
const yFn = onSecondaryAxis ? scaleY1.value : scales.value.y;
|
|
807
|
+
const seriesRange = onSecondaryAxis ? secondaryYRange.value : yRange.value;
|
|
808
|
+
const frame = {
|
|
809
|
+
series: s,
|
|
810
|
+
seriesIdx,
|
|
811
|
+
color: colorFor(s, seriesIdx),
|
|
812
|
+
kind,
|
|
813
|
+
normalised,
|
|
814
|
+
yFn
|
|
815
|
+
};
|
|
816
|
+
if (isLineFamily(kind)) {
|
|
817
|
+
const linePathFrame = {
|
|
818
|
+
...frame,
|
|
819
|
+
pts: normalised.map((p) => [
|
|
820
|
+
scales.value.x(p.x, p.dataIndex, slotCount.value),
|
|
821
|
+
yFn(p.y)
|
|
822
|
+
]),
|
|
823
|
+
smoothing,
|
|
824
|
+
baseline: yFn(Math.max(0, seriesRange.min))
|
|
825
|
+
};
|
|
826
|
+
pushLinePaths(out, linePathFrame);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (kind === CHART_TYPE.BAR || kind === CHART_TYPE.COLUMN) {
|
|
830
|
+
const stacked = options.stacked();
|
|
831
|
+
const barFrame = {
|
|
832
|
+
...frame,
|
|
833
|
+
plot: plotRect,
|
|
834
|
+
groupCount: slotCount.value,
|
|
835
|
+
visibleCount: series.filter((other) => other.visible !== false).length,
|
|
836
|
+
visibleIdxInGroup: series.slice(0, seriesIdx).filter((other) => other.visible !== false).length,
|
|
837
|
+
stacked,
|
|
838
|
+
isPercent: stacked && effectiveStacking.value === CHART_STACKING.PERCENT,
|
|
839
|
+
stackOffsets: stackOffsets.value.get(seriesIdx) ?? [],
|
|
840
|
+
percentShares: percentValues.value.get(seriesIdx),
|
|
841
|
+
yRange: yRange.value
|
|
842
|
+
};
|
|
843
|
+
pushBarPaths(out, barFrame);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (kind === CHART_TYPE.SCATTER) {
|
|
847
|
+
const scatterFrame = {
|
|
848
|
+
...frame,
|
|
849
|
+
plot: plotRect,
|
|
850
|
+
scatterSeries: series.filter((other) => effectiveType(other) === CHART_TYPE.SCATTER && other.visible !== false)
|
|
851
|
+
};
|
|
852
|
+
pushScatterPaths(out, scatterFrame);
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
if (kind === CHART_TYPE.RADAR) {
|
|
856
|
+
const radarFrame = {
|
|
857
|
+
...frame,
|
|
858
|
+
plot: plotRect,
|
|
859
|
+
axes: Math.max(cats.length, normalised.length),
|
|
860
|
+
yRange: yRange.value
|
|
861
|
+
};
|
|
862
|
+
pushRadarPaths(out, radarFrame);
|
|
863
|
+
}
|
|
864
|
+
};
|
|
553
865
|
const paths = computed(() => {
|
|
554
|
-
const out = [];
|
|
555
866
|
const series = options.series();
|
|
556
867
|
const cats = categories.value;
|
|
557
|
-
const
|
|
868
|
+
const plotRect = plot.value;
|
|
558
869
|
const smoothing = options.smoothing();
|
|
559
870
|
const pieSeriesList = series.filter((s) => effectiveType(s) === CHART_TYPE.PIE || effectiveType(s) === CHART_TYPE.DONUT);
|
|
560
871
|
if (pieSeriesList.length > 0) {
|
|
561
|
-
const outerR = Math.max(
|
|
562
|
-
CHART_PIE_MIN_RADIUS,
|
|
563
|
-
Math.min(x1 - x0, y1 - y0) / 2 - CHART_PIE_RADIUS_INSET
|
|
564
|
-
);
|
|
565
872
|
const isDonut = effectiveType(pieSeriesList[0]) === CHART_TYPE.DONUT;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
return resolveColor(scheme[dataIdx % scheme.length]);
|
|
577
|
-
};
|
|
578
|
-
const labelFor = (i, entry) => {
|
|
579
|
-
if (cats2[i] != null) return String(cats2[i]);
|
|
580
|
-
if (entry != null && typeof entry === "object") return String(entry.x);
|
|
581
|
-
return `${CHART_SLICE_LABEL_PREFIX} ${i + 1}`;
|
|
582
|
-
};
|
|
583
|
-
for (let ringIdx = 0; ringIdx < visibleSeries.length; ringIdx++) {
|
|
584
|
-
const s = visibleSeries[ringIdx];
|
|
585
|
-
const ringInner = baseInner + bandThickness * ringIdx;
|
|
586
|
-
const ringOuter = baseInner + bandThickness * (ringIdx + 1);
|
|
587
|
-
const data = s.data;
|
|
588
|
-
const ringTotal = data.reduce((acc, entry, i) => {
|
|
589
|
-
if (isSingleRing && hidden.has(labelFor(i, entry))) return acc;
|
|
590
|
-
const v = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
591
|
-
return acc + (Number.isFinite(v) && v > 0 ? v : 0);
|
|
592
|
-
}, 0);
|
|
593
|
-
if (ringTotal === 0) continue;
|
|
594
|
-
let angle = 0;
|
|
595
|
-
for (let i = 0; i < data.length; i++) {
|
|
596
|
-
const entry = data[i];
|
|
597
|
-
if (isSingleRing && hidden.has(labelFor(i, entry))) continue;
|
|
598
|
-
const v = typeof entry === "number" ? entry : entry?.y ?? 0;
|
|
599
|
-
if (!Number.isFinite(v) || v <= 0) continue;
|
|
600
|
-
const sweep = v / ringTotal * Math.PI * 2;
|
|
601
|
-
const endAngle = angle + sweep;
|
|
602
|
-
out.push({
|
|
603
|
-
seriesIndex: series.indexOf(s),
|
|
604
|
-
kind: "path",
|
|
605
|
-
d: arcPath(cx, cy, ringOuter, ringInner, angle, endAngle),
|
|
606
|
-
color: categoryColor(i, s),
|
|
607
|
-
series: s,
|
|
608
|
-
dataIndex: i
|
|
609
|
-
});
|
|
610
|
-
angle = endAngle;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return out;
|
|
873
|
+
return buildPiePaths({
|
|
874
|
+
series,
|
|
875
|
+
pieSeriesList,
|
|
876
|
+
plot: plotRect,
|
|
877
|
+
isDonut,
|
|
878
|
+
donutHoleSize: isDonut ? options.donutHoleSize() : 0,
|
|
879
|
+
scheme: options.colorScheme().length ? options.colorScheme() : CHART_DEFAULT_PALETTE,
|
|
880
|
+
hidden: options.hiddenLabels?.() ?? /* @__PURE__ */ new Set(),
|
|
881
|
+
categories: options.categories()
|
|
882
|
+
});
|
|
614
883
|
}
|
|
884
|
+
const out = [];
|
|
615
885
|
for (let seriesIdx = 0; seriesIdx < series.length; seriesIdx++) {
|
|
616
|
-
|
|
617
|
-
if (s.visible === false) continue;
|
|
618
|
-
const color = colorFor(s, seriesIdx);
|
|
619
|
-
const kind = effectiveType(s);
|
|
620
|
-
const normalised = toPoints(s);
|
|
621
|
-
const seriesAxisIndex = s.yAxis ?? 0;
|
|
622
|
-
const yFn = seriesAxisIndex === 1 ? scaleY1.value : scales.value.y;
|
|
623
|
-
const seriesRange = seriesAxisIndex === 1 ? secondaryYRange.value : yRange.value;
|
|
624
|
-
const seriesBaseline = yFn(Math.max(0, seriesRange.min));
|
|
625
|
-
if (kind === CHART_TYPE.LINE || kind === CHART_TYPE.AREA || kind === CHART_TYPE.SPLINE || kind === CHART_TYPE.STEPPED_LINE) {
|
|
626
|
-
const pts = normalised.map((p) => [
|
|
627
|
-
scales.value.x(p.x, p.dataIndex, slotCount.value),
|
|
628
|
-
yFn(p.y)
|
|
629
|
-
]);
|
|
630
|
-
const effectiveSmoothing = kind === CHART_TYPE.SPLINE && smoothing === CHART_SMOOTHING.NONE ? CHART_SMOOTHING.MONOTONE : smoothing;
|
|
631
|
-
let dLine;
|
|
632
|
-
let areaMode = false;
|
|
633
|
-
if (kind === CHART_TYPE.STEPPED_LINE) {
|
|
634
|
-
dLine = steppedPath(pts);
|
|
635
|
-
areaMode = "stepped";
|
|
636
|
-
} else if (effectiveSmoothing === CHART_SMOOTHING.MONOTONE) {
|
|
637
|
-
dLine = monotonePath(pts);
|
|
638
|
-
areaMode = "monotone";
|
|
639
|
-
} else if (effectiveSmoothing === CHART_SMOOTHING.CURVE) {
|
|
640
|
-
dLine = smoothPath(pts);
|
|
641
|
-
areaMode = true;
|
|
642
|
-
} else {
|
|
643
|
-
dLine = linePath(pts);
|
|
644
|
-
areaMode = false;
|
|
645
|
-
}
|
|
646
|
-
const length = kind === CHART_TYPE.STEPPED_LINE ? steppedPathLength(pts) : computePathLength(pts);
|
|
647
|
-
if (kind === CHART_TYPE.AREA) {
|
|
648
|
-
out.push({
|
|
649
|
-
seriesIndex: seriesIdx,
|
|
650
|
-
kind: "path",
|
|
651
|
-
d: areaPath(pts, seriesBaseline, areaMode),
|
|
652
|
-
color,
|
|
653
|
-
series: s,
|
|
654
|
-
pathLength: length,
|
|
655
|
-
variant: "fill"
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
out.push({
|
|
659
|
-
seriesIndex: seriesIdx,
|
|
660
|
-
kind: "path",
|
|
661
|
-
d: dLine,
|
|
662
|
-
color,
|
|
663
|
-
series: s,
|
|
664
|
-
pathLength: length,
|
|
665
|
-
variant: kind === CHART_TYPE.AREA ? "stroke" : void 0
|
|
666
|
-
});
|
|
667
|
-
{
|
|
668
|
-
for (let dataIdx = 0; dataIdx < pts.length; dataIdx++) {
|
|
669
|
-
out.push({
|
|
670
|
-
seriesIndex: seriesIdx,
|
|
671
|
-
kind: "circle",
|
|
672
|
-
circle: {
|
|
673
|
-
cx: pts[dataIdx][0],
|
|
674
|
-
cy: pts[dataIdx][1],
|
|
675
|
-
r: CHART_POINT_MARKER_RADIUS
|
|
676
|
-
},
|
|
677
|
-
color,
|
|
678
|
-
series: s,
|
|
679
|
-
dataIndex: dataIdx
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
if (kind === CHART_TYPE.BAR || kind === CHART_TYPE.COLUMN) {
|
|
686
|
-
const visibleCount = series.filter((other) => other.visible !== false).length;
|
|
687
|
-
const groupCount = slotCount.value;
|
|
688
|
-
const slotPx = kind === CHART_TYPE.COLUMN ? (x1 - x0) / Math.max(1, groupCount) : (y1 - y0) / Math.max(1, groupCount);
|
|
689
|
-
const stacked = options.stacked();
|
|
690
|
-
const isPercent = stacked && effectiveStacking.value === CHART_STACKING.PERCENT;
|
|
691
|
-
const visibleIdxInGroup = series.slice(0, seriesIdx).filter((other) => other.visible !== false).length;
|
|
692
|
-
const stackOff = stackOffsets.value.get(seriesIdx) ?? [];
|
|
693
|
-
const horizRange = yRange.value;
|
|
694
|
-
const horizSpan = Math.max(CHART_EPSILON, horizRange.max - horizRange.min);
|
|
695
|
-
const xValuePx = (v) => {
|
|
696
|
-
const ratio = (v - horizRange.min) / horizSpan;
|
|
697
|
-
const px = x0 + ratio * (x1 - x0);
|
|
698
|
-
if (px < x0) return x0;
|
|
699
|
-
if (px > x1) return x1;
|
|
700
|
-
return px;
|
|
701
|
-
};
|
|
702
|
-
for (let dataIdx = 0; dataIdx < normalised.length; dataIdx++) {
|
|
703
|
-
const p = normalised[dataIdx];
|
|
704
|
-
const renderY = isPercent ? percentValues.value.get(seriesIdx)?.[dataIdx] ?? 0 : p.y;
|
|
705
|
-
if (kind === CHART_TYPE.COLUMN) {
|
|
706
|
-
const centerX = x0 + (dataIdx + 0.5) * slotPx;
|
|
707
|
-
const barWidth = stacked ? slotPx * CHART_BAR_SLOT_FILL_RATIO : slotPx * CHART_BAR_SLOT_FILL_RATIO / Math.max(1, visibleCount);
|
|
708
|
-
const left = stacked ? centerX - barWidth / 2 : centerX - slotPx * CHART_BAR_SLOT_FILL_RATIO / 2 + visibleIdxInGroup * barWidth;
|
|
709
|
-
const offset = stacked ? stackOff[dataIdx] ?? 0 : 0;
|
|
710
|
-
const top = yFn(renderY + offset);
|
|
711
|
-
const base = yFn(offset);
|
|
712
|
-
out.push({
|
|
713
|
-
seriesIndex: seriesIdx,
|
|
714
|
-
kind: "rect",
|
|
715
|
-
rect: {
|
|
716
|
-
x: left,
|
|
717
|
-
y: Math.min(top, base),
|
|
718
|
-
width: barWidth,
|
|
719
|
-
height: Math.abs(base - top)
|
|
720
|
-
},
|
|
721
|
-
color,
|
|
722
|
-
series: s,
|
|
723
|
-
dataIndex: dataIdx
|
|
724
|
-
});
|
|
725
|
-
} else {
|
|
726
|
-
const slots = Math.max(1, groupCount);
|
|
727
|
-
const slotCenterY = slots === 1 ? (y0 + y1) / 2 : y0 + (dataIdx + 0.5) * slotPx;
|
|
728
|
-
const barHeight = stacked ? slotPx * CHART_BAR_SLOT_FILL_RATIO : slotPx * CHART_BAR_SLOT_FILL_RATIO / Math.max(1, visibleCount);
|
|
729
|
-
const top = stacked ? slotCenterY - barHeight / 2 : slotCenterY - slotPx * CHART_BAR_SLOT_FILL_RATIO / 2 + visibleIdxInGroup * barHeight;
|
|
730
|
-
const offset = stacked ? stackOff[dataIdx] ?? 0 : 0;
|
|
731
|
-
const rightPx = xValuePx(renderY + offset);
|
|
732
|
-
const basePx = xValuePx(offset);
|
|
733
|
-
out.push({
|
|
734
|
-
seriesIndex: seriesIdx,
|
|
735
|
-
kind: "rect",
|
|
736
|
-
rect: {
|
|
737
|
-
x: Math.min(rightPx, basePx),
|
|
738
|
-
y: top,
|
|
739
|
-
width: Math.abs(rightPx - basePx),
|
|
740
|
-
height: barHeight
|
|
741
|
-
},
|
|
742
|
-
color,
|
|
743
|
-
series: s,
|
|
744
|
-
dataIndex: dataIdx
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
continue;
|
|
749
|
-
}
|
|
750
|
-
if (kind === CHART_TYPE.SCATTER) {
|
|
751
|
-
const scatterSeries = series.filter((other) => effectiveType(other) === CHART_TYPE.SCATTER && other.visible !== false);
|
|
752
|
-
let xMin = Infinity;
|
|
753
|
-
let xMax = -Infinity;
|
|
754
|
-
let zMin = Infinity;
|
|
755
|
-
let zMax = -Infinity;
|
|
756
|
-
let hasZ = false;
|
|
757
|
-
for (const sp of scatterSeries) {
|
|
758
|
-
for (const entry of sp.data) {
|
|
759
|
-
const xv = typeof entry === "number" ? entry : entry.x;
|
|
760
|
-
const x = typeof xv === "number" ? xv : 0;
|
|
761
|
-
if (x < xMin) xMin = x;
|
|
762
|
-
if (x > xMax) xMax = x;
|
|
763
|
-
if (typeof entry !== "number" && typeof entry.z === "number" && Number.isFinite(entry.z)) {
|
|
764
|
-
hasZ = true;
|
|
765
|
-
if (entry.z < zMin) zMin = entry.z;
|
|
766
|
-
if (entry.z > zMax) zMax = entry.z;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
const xSpan = Math.max(CHART_EPSILON, xMax - xMin);
|
|
771
|
-
const xPx = (v) => {
|
|
772
|
-
const ratio = (v - xMin) / xSpan;
|
|
773
|
-
const px = x0 + ratio * (x1 - x0);
|
|
774
|
-
if (px < x0) return x0;
|
|
775
|
-
if (px > x1) return x1;
|
|
776
|
-
return px;
|
|
777
|
-
};
|
|
778
|
-
const zSpan = Math.max(CHART_EPSILON, zMax - zMin);
|
|
779
|
-
const radiusFor = (z) => {
|
|
780
|
-
if (!hasZ || typeof z !== "number" || !Number.isFinite(z)) return CHART_SCATTER_DEFAULT_RADIUS;
|
|
781
|
-
const ratio = zSpan === 0 ? 0.5 : (z - zMin) / zSpan;
|
|
782
|
-
return CHART_SCATTER_MIN_RADIUS + ratio * (CHART_SCATTER_MAX_RADIUS - CHART_SCATTER_MIN_RADIUS);
|
|
783
|
-
};
|
|
784
|
-
for (let dataIdx = 0; dataIdx < normalised.length; dataIdx++) {
|
|
785
|
-
const p = normalised[dataIdx];
|
|
786
|
-
const cxRaw = typeof p.x === "number" ? p.x : Number(p.x);
|
|
787
|
-
out.push({
|
|
788
|
-
seriesIndex: seriesIdx,
|
|
789
|
-
kind: "circle",
|
|
790
|
-
circle: {
|
|
791
|
-
cx: xPx(Number.isFinite(cxRaw) ? cxRaw : 0),
|
|
792
|
-
cy: yFn(p.y),
|
|
793
|
-
r: radiusFor(p.z)
|
|
794
|
-
},
|
|
795
|
-
color,
|
|
796
|
-
series: s,
|
|
797
|
-
dataIndex: dataIdx
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
continue;
|
|
801
|
-
}
|
|
802
|
-
if (kind === CHART_TYPE.RADAR) {
|
|
803
|
-
const axes = Math.max(cats.length, normalised.length);
|
|
804
|
-
if (!axes) continue;
|
|
805
|
-
const radius = Math.max(
|
|
806
|
-
CHART_RADAR_MIN_RADIUS,
|
|
807
|
-
Math.min(x1 - x0, y1 - y0) / 2 - CHART_RADAR_RADIUS_INSET
|
|
808
|
-
);
|
|
809
|
-
const pts = normalised.map((p, i) => {
|
|
810
|
-
const yRangeSize = Math.max(CHART_EPSILON, yRange.value.max - yRange.value.min);
|
|
811
|
-
const ratio = (p.y - yRange.value.min) / yRangeSize;
|
|
812
|
-
const angle = i / axes * Math.PI * 2;
|
|
813
|
-
return polarToCartesian(cx, cy, radius * ratio, angle);
|
|
814
|
-
});
|
|
815
|
-
out.push({
|
|
816
|
-
seriesIndex: seriesIdx,
|
|
817
|
-
kind: "polygon",
|
|
818
|
-
d: polygonPath(pts),
|
|
819
|
-
color,
|
|
820
|
-
series: s
|
|
821
|
-
});
|
|
822
|
-
for (let i = 0; i < pts.length; i++) {
|
|
823
|
-
out.push({
|
|
824
|
-
seriesIndex: seriesIdx,
|
|
825
|
-
kind: "circle",
|
|
826
|
-
circle: { cx: pts[i][0], cy: pts[i][1], r: CHART_RADAR_MARKER_RADIUS },
|
|
827
|
-
color,
|
|
828
|
-
series: s,
|
|
829
|
-
dataIndex: i
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
}
|
|
886
|
+
pushSeriesPaths(out, series, seriesIdx, cats, smoothing);
|
|
833
887
|
}
|
|
834
888
|
return out;
|
|
835
889
|
});
|