@antv/infographic 0.2.11 → 0.2.13
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/dist/infographic.min.js +98 -94
- package/dist/infographic.min.js.map +1 -1
- package/esm/designs/components/Btn.js +15 -4
- package/esm/designs/components/BtnsGroup.js +1 -1
- package/esm/designs/components/Illus.js +15 -3
- package/esm/designs/components/ItemDesc.js +17 -11
- package/esm/designs/components/ItemIcon.js +17 -18
- package/esm/designs/components/ItemLabel.js +17 -11
- package/esm/designs/components/ItemValue.js +17 -12
- package/esm/designs/components/ItemsGroup.js +1 -1
- package/esm/designs/components/ShapesGroup.js +1 -1
- package/esm/designs/components/Title.js +2 -2
- package/esm/designs/decorations/simple-arrow.js +14 -2
- package/esm/designs/decorations/triangle.js +14 -2
- package/esm/designs/defs/DropShadow.js +13 -2
- package/esm/designs/defs/LinearGradient.js +1 -1
- package/esm/designs/items/BadgeCard.js +2 -2
- package/esm/designs/items/CandyCardLite.js +1 -1
- package/esm/designs/items/CapsuleItem.js +3 -3
- package/esm/designs/items/CircleNode.js +1 -1
- package/esm/designs/items/CircularProgress.js +3 -2
- package/esm/designs/items/CompactCard.js +1 -1
- package/esm/designs/items/DoneList.js +1 -1
- package/esm/designs/items/HorizontalIconArrow.js +2 -2
- package/esm/designs/items/HorizontalIconLine.js +2 -2
- package/esm/designs/items/IconBadge.js +4 -3
- package/esm/designs/items/IndexedCard.js +1 -1
- package/esm/designs/items/LCornerCard.js +1 -1
- package/esm/designs/items/LetterCard.js +4 -3
- package/esm/designs/items/LinedText.js +6 -5
- package/esm/designs/items/PillBadge.js +2 -2
- package/esm/designs/items/PlainText.js +4 -4
- package/esm/designs/items/ProgressCard.js +4 -4
- package/esm/designs/items/QuarterCircular.js +1 -1
- package/esm/designs/items/QuarterSimpleCard.js +1 -1
- package/esm/designs/items/RibbonCard.js +2 -2
- package/esm/designs/items/RoundedRectNode.js +2 -2
- package/esm/designs/items/SimpleCircleNode.js +1 -1
- package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
- package/esm/designs/items/SimpleIllusItem.js +1 -1
- package/esm/designs/items/SimpleItem.js +3 -3
- package/esm/designs/items/SimpleVerticalArrow.js +2 -2
- package/esm/designs/items/UnderlineText.js +1 -1
- package/esm/designs/items/VerticalIconArrow.js +2 -2
- package/esm/designs/layouts/Align.js +22 -15
- package/esm/designs/layouts/Flex.js +23 -16
- package/esm/designs/structures/chart-bar.js +7 -5
- package/esm/designs/structures/chart-column.js +3 -2
- package/esm/designs/structures/chart-line.js +7 -5
- package/esm/designs/structures/chart-pie.d.ts +25 -0
- package/esm/designs/structures/chart-pie.js +186 -26
- package/esm/designs/structures/chart-wordcloud.js +5 -14
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/esm/designs/structures/compare-hierarchy-row.js +3 -2
- package/esm/designs/structures/compare-quadrant.js +2 -3
- package/esm/designs/structures/hierarchy-mindmap.js +19 -19
- package/esm/designs/structures/hierarchy-structure.js +1 -1
- package/esm/designs/structures/hierarchy-tree.js +15 -24
- package/esm/designs/structures/list-sector.js +5 -6
- package/esm/designs/structures/list-zigzag.js +2 -1
- package/esm/designs/structures/relation-dagre-flow.js +30 -35
- package/esm/designs/structures/relation-network.js +2 -2
- package/esm/designs/structures/sequence-funnel.js +1 -1
- package/esm/designs/structures/sequence-mountain.js +4 -4
- package/esm/designs/structures/sequence-pyramid.js +1 -1
- package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
- package/esm/designs/utils/color.js +8 -4
- package/esm/designs/utils/index.d.ts +1 -0
- package/esm/designs/utils/index.js +1 -0
- package/esm/designs/utils/item.js +3 -2
- package/esm/designs/utils/normalize-percent.d.ts +19 -0
- package/esm/designs/utils/normalize-percent.js +32 -0
- package/esm/editor/commands/Batch.js +21 -8
- package/esm/editor/commands/UpdateElement.js +25 -22
- package/esm/editor/commands/UpdateOptions.js +23 -10
- package/esm/editor/commands/UpdateText.js +24 -11
- package/esm/editor/interactions/brush-select.js +27 -13
- package/esm/editor/interactions/click-select.js +13 -3
- package/esm/editor/interactions/dblclick-edit-text.js +36 -20
- package/esm/editor/interactions/drag-element.js +23 -9
- package/esm/editor/interactions/hotkey-history.js +17 -7
- package/esm/editor/interactions/select-highlight.js +5 -9
- package/esm/editor/interactions/zoom-wheel.d.ts +3 -0
- package/esm/editor/interactions/zoom-wheel.js +46 -22
- package/esm/editor/managers/command.js +45 -27
- package/esm/editor/managers/interaction.js +46 -33
- package/esm/editor/managers/state.js +9 -3
- package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
- package/esm/editor/plugins/edit-bar/components/select.js +10 -8
- package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/esm/editor/plugins/resize-element.js +6 -4
- package/esm/editor/utils/click-handler.js +6 -3
- package/esm/editor/utils/coordinate.js +2 -1
- package/esm/editor/utils/element.js +2 -1
- package/esm/editor/utils/event.js +2 -1
- package/esm/editor/utils/extension.js +1 -1
- package/esm/editor/utils/hotkey.js +2 -1
- package/esm/exporter/font.js +106 -90
- package/esm/exporter/png.js +49 -37
- package/esm/exporter/svg.js +55 -38
- package/esm/jsx/components/Ellipse.js +5 -4
- package/esm/jsx/components/Path.js +2 -4
- package/esm/jsx/components/Polygon.js +15 -6
- package/esm/jsx/components/Text.js +21 -41
- package/esm/jsx/renderer.js +15 -7
- package/esm/jsx/utils/bounds.js +18 -16
- package/esm/jsx/utils/children.js +2 -1
- package/esm/jsx/utils/clone.js +13 -2
- package/esm/jsx/utils/element.js +2 -1
- package/esm/options/parser.js +45 -46
- package/esm/renderer/composites/background.js +3 -2
- package/esm/renderer/composites/icon.js +14 -19
- package/esm/renderer/composites/illus.js +17 -22
- package/esm/renderer/composites/shape.js +4 -2
- package/esm/renderer/composites/svg.js +2 -1
- package/esm/renderer/composites/text.js +5 -3
- package/esm/renderer/fonts/loader.js +4 -3
- package/esm/renderer/fonts/registry.js +1 -1
- package/esm/renderer/palettes/utils.js +3 -2
- package/esm/renderer/renderer.js +7 -5
- package/esm/renderer/stylize/gradient.js +3 -2
- package/esm/renderer/stylize/pattern.js +15 -8
- package/esm/renderer/stylize/rough.js +1 -1
- package/esm/resource/load-tracker.js +22 -10
- package/esm/resource/loader.js +80 -67
- package/esm/resource/loaders/image.js +71 -59
- package/esm/resource/loaders/remote.js +26 -15
- package/esm/resource/loaders/search.js +38 -25
- package/esm/resource/utils/parser.js +2 -1
- package/esm/runtime/Infographic.js +26 -13
- package/esm/runtime/utils.js +5 -8
- package/esm/ssr/renderer.js +42 -35
- package/esm/syntax/index.js +19 -6
- package/esm/syntax/mapper.js +2 -2
- package/esm/templates/built-in.js +91 -269
- package/esm/templates/chart-pie.d.ts +2 -0
- package/esm/templates/chart-pie.js +87 -0
- package/esm/templates/hierarchy-mindmap.js +1 -5
- package/esm/templates/hierarchy-tree.js +1 -5
- package/esm/templates/relation-dagre-flow.js +4 -28
- package/esm/themes/generator.js +8 -14
- package/esm/utils/fetch.js +48 -35
- package/esm/utils/icon.js +1 -4
- package/esm/utils/is-browser.js +2 -2
- package/esm/utils/measure-text.js +2 -1
- package/esm/utils/padding.js +1 -1
- package/esm/utils/recognizer.js +2 -1
- package/esm/utils/text.js +14 -3
- package/esm/utils/viewbox.d.ts +20 -0
- package/esm/utils/viewbox.js +10 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/designs/components/Btn.js +15 -4
- package/lib/designs/components/BtnsGroup.js +1 -1
- package/lib/designs/components/Illus.js +15 -3
- package/lib/designs/components/ItemDesc.js +17 -11
- package/lib/designs/components/ItemIcon.js +17 -18
- package/lib/designs/components/ItemLabel.js +17 -11
- package/lib/designs/components/ItemValue.js +17 -12
- package/lib/designs/components/ItemsGroup.js +1 -1
- package/lib/designs/components/ShapesGroup.js +1 -1
- package/lib/designs/components/Title.js +2 -2
- package/lib/designs/decorations/simple-arrow.js +14 -2
- package/lib/designs/decorations/triangle.js +14 -2
- package/lib/designs/defs/DropShadow.js +13 -2
- package/lib/designs/defs/LinearGradient.js +1 -1
- package/lib/designs/items/BadgeCard.js +2 -2
- package/lib/designs/items/CandyCardLite.js +1 -1
- package/lib/designs/items/CapsuleItem.js +3 -3
- package/lib/designs/items/CircleNode.js +1 -1
- package/lib/designs/items/CircularProgress.js +3 -2
- package/lib/designs/items/CompactCard.js +1 -1
- package/lib/designs/items/DoneList.js +1 -1
- package/lib/designs/items/HorizontalIconArrow.js +2 -2
- package/lib/designs/items/HorizontalIconLine.js +2 -2
- package/lib/designs/items/IconBadge.js +4 -3
- package/lib/designs/items/IndexedCard.js +1 -1
- package/lib/designs/items/LCornerCard.js +1 -1
- package/lib/designs/items/LetterCard.js +4 -3
- package/lib/designs/items/LinedText.js +6 -5
- package/lib/designs/items/PillBadge.js +2 -2
- package/lib/designs/items/PlainText.js +4 -4
- package/lib/designs/items/ProgressCard.js +4 -4
- package/lib/designs/items/QuarterCircular.js +1 -1
- package/lib/designs/items/QuarterSimpleCard.js +1 -1
- package/lib/designs/items/RibbonCard.js +2 -2
- package/lib/designs/items/RoundedRectNode.js +2 -2
- package/lib/designs/items/SimpleCircleNode.js +1 -1
- package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
- package/lib/designs/items/SimpleIllusItem.js +1 -1
- package/lib/designs/items/SimpleItem.js +3 -3
- package/lib/designs/items/SimpleVerticalArrow.js +2 -2
- package/lib/designs/items/UnderlineText.js +1 -1
- package/lib/designs/items/VerticalIconArrow.js +2 -2
- package/lib/designs/layouts/Align.js +22 -15
- package/lib/designs/layouts/Flex.js +23 -16
- package/lib/designs/structures/chart-bar.js +7 -5
- package/lib/designs/structures/chart-column.js +3 -2
- package/lib/designs/structures/chart-line.js +7 -5
- package/lib/designs/structures/chart-pie.d.ts +25 -0
- package/lib/designs/structures/chart-pie.js +186 -25
- package/lib/designs/structures/chart-wordcloud.js +5 -14
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/lib/designs/structures/compare-hierarchy-row.js +3 -2
- package/lib/designs/structures/compare-quadrant.js +2 -3
- package/lib/designs/structures/hierarchy-mindmap.js +19 -19
- package/lib/designs/structures/hierarchy-structure.js +1 -1
- package/lib/designs/structures/hierarchy-tree.js +15 -24
- package/lib/designs/structures/list-sector.js +5 -6
- package/lib/designs/structures/list-zigzag.js +2 -1
- package/lib/designs/structures/relation-dagre-flow.js +30 -35
- package/lib/designs/structures/relation-network.js +2 -2
- package/lib/designs/structures/sequence-funnel.js +1 -1
- package/lib/designs/structures/sequence-mountain.js +4 -4
- package/lib/designs/structures/sequence-pyramid.js +1 -1
- package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
- package/lib/designs/utils/color.js +8 -4
- package/lib/designs/utils/index.d.ts +1 -0
- package/lib/designs/utils/index.js +1 -0
- package/lib/designs/utils/item.js +3 -2
- package/lib/designs/utils/normalize-percent.d.ts +19 -0
- package/lib/designs/utils/normalize-percent.js +35 -0
- package/lib/editor/commands/Batch.js +21 -8
- package/lib/editor/commands/UpdateElement.js +25 -22
- package/lib/editor/commands/UpdateOptions.js +23 -10
- package/lib/editor/commands/UpdateText.js +24 -11
- package/lib/editor/interactions/brush-select.js +27 -13
- package/lib/editor/interactions/click-select.js +13 -3
- package/lib/editor/interactions/dblclick-edit-text.js +36 -20
- package/lib/editor/interactions/drag-element.js +23 -9
- package/lib/editor/interactions/hotkey-history.js +17 -7
- package/lib/editor/interactions/select-highlight.js +5 -9
- package/lib/editor/interactions/zoom-wheel.d.ts +3 -0
- package/lib/editor/interactions/zoom-wheel.js +45 -21
- package/lib/editor/managers/command.js +43 -25
- package/lib/editor/managers/interaction.js +46 -33
- package/lib/editor/managers/state.js +9 -3
- package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
- package/lib/editor/plugins/edit-bar/components/select.js +10 -8
- package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/lib/editor/plugins/resize-element.js +6 -4
- package/lib/editor/utils/click-handler.js +6 -3
- package/lib/editor/utils/coordinate.js +2 -1
- package/lib/editor/utils/element.js +2 -1
- package/lib/editor/utils/event.js +2 -1
- package/lib/editor/utils/extension.js +1 -1
- package/lib/editor/utils/hotkey.js +2 -1
- package/lib/exporter/font.js +106 -90
- package/lib/exporter/png.js +49 -37
- package/lib/exporter/svg.js +55 -38
- package/lib/jsx/components/Ellipse.js +5 -4
- package/lib/jsx/components/Path.js +2 -4
- package/lib/jsx/components/Polygon.js +15 -6
- package/lib/jsx/components/Text.js +21 -41
- package/lib/jsx/renderer.js +15 -7
- package/lib/jsx/utils/bounds.js +18 -16
- package/lib/jsx/utils/children.js +2 -1
- package/lib/jsx/utils/clone.js +13 -2
- package/lib/jsx/utils/element.js +2 -1
- package/lib/options/parser.js +45 -46
- package/lib/renderer/composites/background.js +3 -2
- package/lib/renderer/composites/icon.js +14 -19
- package/lib/renderer/composites/illus.js +17 -22
- package/lib/renderer/composites/shape.js +4 -2
- package/lib/renderer/composites/svg.js +2 -1
- package/lib/renderer/composites/text.js +5 -3
- package/lib/renderer/fonts/loader.js +4 -3
- package/lib/renderer/fonts/registry.js +1 -1
- package/lib/renderer/palettes/utils.js +3 -2
- package/lib/renderer/renderer.js +7 -5
- package/lib/renderer/stylize/gradient.js +3 -2
- package/lib/renderer/stylize/pattern.js +15 -8
- package/lib/renderer/stylize/rough.js +1 -1
- package/lib/resource/load-tracker.js +22 -10
- package/lib/resource/loader.js +80 -67
- package/lib/resource/loaders/image.js +71 -59
- package/lib/resource/loaders/remote.js +26 -15
- package/lib/resource/loaders/search.js +38 -25
- package/lib/resource/utils/parser.js +2 -1
- package/lib/runtime/Infographic.js +26 -13
- package/lib/runtime/utils.js +5 -8
- package/lib/ssr/renderer.js +42 -35
- package/lib/syntax/index.js +19 -6
- package/lib/syntax/mapper.js +2 -2
- package/lib/templates/built-in.js +91 -269
- package/lib/templates/chart-pie.d.ts +2 -0
- package/lib/templates/chart-pie.js +90 -0
- package/lib/templates/hierarchy-mindmap.js +1 -5
- package/lib/templates/hierarchy-tree.js +1 -5
- package/lib/templates/relation-dagre-flow.js +4 -28
- package/lib/themes/generator.js +8 -14
- package/lib/utils/fetch.js +48 -35
- package/lib/utils/icon.js +1 -4
- package/lib/utils/is-browser.js +2 -2
- package/lib/utils/measure-text.js +2 -1
- package/lib/utils/padding.js +1 -1
- package/lib/utils/recognizer.js +2 -1
- package/lib/utils/text.js +14 -3
- package/lib/utils/viewbox.d.ts +20 -0
- package/lib/utils/viewbox.js +12 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -2
- package/src/designs/structures/chart-pie.tsx +259 -26
- package/src/designs/utils/index.ts +1 -0
- package/src/designs/utils/normalize-percent.ts +33 -0
- package/src/editor/interactions/zoom-wheel.ts +64 -22
- package/src/editor/managers/state.ts +10 -5
- package/src/templates/built-in.ts +2 -81
- package/src/templates/chart-pie.ts +89 -0
- package/src/utils/viewbox.ts +23 -0
- package/src/version.ts +1 -1
|
@@ -10,6 +10,7 @@ import { registerItem } from './registry.js';
|
|
|
10
10
|
* 支持渐变背景、斜纹和底部阴影效果
|
|
11
11
|
*/
|
|
12
12
|
export const LetterCard = (props) => {
|
|
13
|
+
var _a, _b;
|
|
13
14
|
const [{ datum, indexes, width = 280, height = 160, showStripe = true, showGradient = true, showBottomShade = true, themeColors, }, restProps,] = getItemProps(props, [
|
|
14
15
|
'width',
|
|
15
16
|
'height',
|
|
@@ -17,8 +18,8 @@ export const LetterCard = (props) => {
|
|
|
17
18
|
'showGradient',
|
|
18
19
|
'showBottomShade',
|
|
19
20
|
]);
|
|
20
|
-
const displayLetter = datum.label
|
|
21
|
-
const displayTitle = datum.label
|
|
21
|
+
const displayLetter = (_a = datum.label) === null || _a === void 0 ? void 0 : _a[0].toUpperCase();
|
|
22
|
+
const displayTitle = (_b = datum.label) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
22
23
|
const baseColor = themeColors.colorPrimary;
|
|
23
24
|
const base = tinycolor(baseColor);
|
|
24
25
|
const stripeWidth = 4;
|
|
@@ -45,7 +46,7 @@ export const LetterCard = (props) => {
|
|
|
45
46
|
const textTotalHeight = letterHeight + textGap + titleHeight;
|
|
46
47
|
const letterY = (height - textTotalHeight) / 2;
|
|
47
48
|
const titleY = letterY + letterHeight + textGap;
|
|
48
|
-
return (_jsxs(Group, {
|
|
49
|
+
return (_jsxs(Group, Object.assign({}, restProps, { width: width, height: height, children: [_jsxs(Defs, { children: [showGradient && (_jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [_jsx("stop", { offset: "0%", stopColor: gradStart }), _jsx("stop", { offset: "100%", stopColor: gradEnd })] })), showStripe && (_jsxs("pattern", { id: patternId, patternUnits: "userSpaceOnUse", width: tile, height: tile, patternTransform: `rotate(${rotationDeg})`, children: [_jsx("rect", { x: "0", y: "0", width: tile, height: tile, fill: lightStripe }), _jsx("rect", { x: "0", y: "0", width: stripeWidth, height: tile, fill: darkStripe })] })), showBottomShade && (_jsxs("linearGradient", { id: shadeId, x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [_jsx("stop", { offset: "0%", stopColor: "rgba(0,0,0,0)" }), _jsx("stop", { offset: "100%", stopColor: "rgba(0,0,0,0.16)" })] }))] }), _jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: showGradient ? `url(#${gradientId})` : baseColor, rx: 0, ry: 0, "data-element-type": "shape" }), showStripe && (_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: `url(#${patternId})`, rx: 0, ry: 0 })), showBottomShade && (_jsx(Rect, { x: 0, y: height - bottomShadeHeight, width: width, height: bottomShadeHeight, fill: `url(#${shadeId})`, rx: 0, ry: 0 })), displayLetter && (_jsx(ItemLabel, { indexes: indexes, x: 0, y: letterY, width: width, fontSize: letterFontSize, fontWeight: "bold", fill: "#FFFFFF", alignHorizontal: "center", alignVertical: "top", lineHeight: 1, children: displayLetter })), _jsx(ItemLabel, { indexes: indexes, x: 0, y: titleY, width: width, fontSize: titleFontSize, fontWeight: "bold", fill: "#FFFFFF", alignHorizontal: "center", alignVertical: "middle", lineHeight: 1, children: displayTitle })] })));
|
|
49
50
|
};
|
|
50
51
|
registerItem('letter-card', {
|
|
51
52
|
component: LetterCard,
|
|
@@ -4,6 +4,7 @@ import { ItemLabel } from '../components/index.js';
|
|
|
4
4
|
import { getItemProps } from '../utils/index.js';
|
|
5
5
|
import { registerItem } from './registry.js';
|
|
6
6
|
export const LinedText = (props) => {
|
|
7
|
+
var _a, _b, _c;
|
|
7
8
|
const [{ datum, indexes, width, themeColors, positionH = 'normal', positionV = 'center', formatter = (text) => text || '', usePaletteColor = false, showUnderline = false, underlineGap = 6, underlineExtend = 8, underlineThickness = 2, }, restProps,] = getItemProps(props, [
|
|
8
9
|
'width',
|
|
9
10
|
'formatter',
|
|
@@ -13,21 +14,21 @@ export const LinedText = (props) => {
|
|
|
13
14
|
'underlineExtend',
|
|
14
15
|
'underlineThickness',
|
|
15
16
|
]);
|
|
16
|
-
const content = formatter(datum.label
|
|
17
|
+
const content = formatter((_b = (_a = datum.label) !== null && _a !== void 0 ? _a : datum.desc) !== null && _b !== void 0 ? _b : '');
|
|
17
18
|
const alignH = positionH === 'flipped'
|
|
18
19
|
? 'right'
|
|
19
20
|
: positionH === 'center'
|
|
20
21
|
? 'center'
|
|
21
22
|
: 'left';
|
|
22
23
|
const measuredLabel = getElementBounds(_jsx(ItemLabel, { indexes: indexes, width: width, children: content }));
|
|
23
|
-
const contentWidth = width
|
|
24
|
+
const contentWidth = width !== null && width !== void 0 ? width : measuredLabel.width;
|
|
24
25
|
const labelHeight = measuredLabel.height;
|
|
25
26
|
const underlineWidth = showUnderline ? contentWidth + underlineExtend * 2 : 0;
|
|
26
27
|
const totalHeight = labelHeight + (showUnderline ? underlineGap + underlineThickness : 0);
|
|
27
28
|
const finalWidth = showUnderline
|
|
28
29
|
? Math.max(contentWidth, underlineWidth)
|
|
29
30
|
: contentWidth;
|
|
30
|
-
const finalHeight = restProps.height
|
|
31
|
+
const finalHeight = (_c = restProps.height) !== null && _c !== void 0 ? _c : totalHeight;
|
|
31
32
|
const offsetY = positionV === 'middle'
|
|
32
33
|
? (finalHeight - totalHeight) / 2
|
|
33
34
|
: positionV === 'flipped'
|
|
@@ -45,11 +46,11 @@ export const LinedText = (props) => {
|
|
|
45
46
|
? (finalWidth - underlineWidth) / 2
|
|
46
47
|
: 0;
|
|
47
48
|
const underlineY = finalHeight;
|
|
48
|
-
return (_jsxs(Group, {
|
|
49
|
+
return (_jsxs(Group, Object.assign({}, restProps, { width: finalWidth, height: finalHeight, children: [_jsx(ItemLabel, { indexes: indexes, x: labelX, y: labelY, width: contentWidth, height: labelHeight, alignHorizontal: alignH, alignVertical: positionV === 'flipped'
|
|
49
50
|
? 'bottom'
|
|
50
51
|
: positionV === 'center'
|
|
51
52
|
? 'middle'
|
|
52
|
-
: 'top', fill: usePaletteColor ? themeColors.colorPrimary : themeColors.colorText, children: content }), showUnderline && (_jsx(Path, { d: `M 0 ${underlineThickness / 2} L ${underlineWidth} ${underlineThickness / 2}`, x: underlineX, y: underlineY - underlineThickness / 2, width: underlineWidth, height: underlineThickness, stroke: themeColors.colorPrimary, strokeWidth: underlineThickness, fill: "none", strokeLinecap: "round", "data-element-type": "shape" }))] }));
|
|
53
|
+
: 'top', fill: usePaletteColor ? themeColors.colorPrimary : themeColors.colorText, children: content }), showUnderline && (_jsx(Path, { d: `M 0 ${underlineThickness / 2} L ${underlineWidth} ${underlineThickness / 2}`, x: underlineX, y: underlineY - underlineThickness / 2, width: underlineWidth, height: underlineThickness, stroke: themeColors.colorPrimary, strokeWidth: underlineThickness, fill: "none", strokeLinecap: "round", "data-element-type": "shape" }))] })));
|
|
53
54
|
};
|
|
54
55
|
registerItem('lined-text', {
|
|
55
56
|
component: LinedText,
|
|
@@ -30,11 +30,11 @@ export const PillBadge = (props) => {
|
|
|
30
30
|
const contentWidth = componentWidth;
|
|
31
31
|
const dropShadowId = `drop-shadow-${themeColors.colorPrimary}`;
|
|
32
32
|
const linearGradientId = `linear-gradient-white-top-bottom`;
|
|
33
|
-
return (_jsxs(Group, {
|
|
33
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsxs(Defs, { children: [_jsx(DropShadow, { id: dropShadowId, color: themeColors.colorPrimary }), _jsx(LinearGradient, { id: linearGradientId, startColor: "#fff", stopColor: "#ffffff33", direction: "top-bottom" })] }), _jsx(Rect, { x: pillX, y: pillY, width: pillWidth, height: pillHeight, fill: themeColors.colorPrimaryBg, stroke: themeColors.colorPrimary, rx: pillHeight / 2, ry: pillHeight / 2, filter: `url(#${dropShadowId})`, "data-element-type": "shape" }), _jsx(Rect, { x: pillX, y: pillY, width: pillWidth, height: pillHeight, fill: `url(#${linearGradientId})`, opacity: themeColors.isDarkMode ? 0.4 : 0.7, rx: pillHeight / 2, ry: pillHeight / 2 }), _jsx(ItemLabel, { indexes: indexes, x: pillX, y: pillY, width: pillWidth, height: pillHeight, alignHorizontal: "center", alignVertical: "middle", fontSize: 14, fontWeight: "500", fill: themeColors.colorText, children: datum.label }), datum.desc && (_jsx(ItemDesc, { indexes: indexes, x: contentX, y: contentY, width: contentWidth, alignHorizontal: positionH === 'center'
|
|
34
34
|
? 'center'
|
|
35
35
|
: positionH === 'flipped'
|
|
36
36
|
? 'right'
|
|
37
|
-
: 'left', fontSize: 12, fill: themeColors.colorTextSecondary, lineNumber: 2, wordWrap: true, children: datum.desc }))] }));
|
|
37
|
+
: 'left', fontSize: 12, fill: themeColors.colorTextSecondary, lineNumber: 2, wordWrap: true, children: datum.desc }))] })));
|
|
38
38
|
};
|
|
39
39
|
registerItem('pill-badge', {
|
|
40
40
|
component: PillBadge,
|
|
@@ -3,6 +3,7 @@ import { ItemLabel } from '../components/index.js';
|
|
|
3
3
|
import { getItemProps } from '../utils/index.js';
|
|
4
4
|
import { registerItem } from './registry.js';
|
|
5
5
|
export const LabelText = (props) => {
|
|
6
|
+
var _a;
|
|
6
7
|
const [{ indexes, datum, width = 120, themeColors, positionH = 'normal', positionV = 'center', formatter = (text) => text || '', usePaletteColor = false, lineNumber = 1, }, restProps,] = getItemProps(props, [
|
|
7
8
|
'width',
|
|
8
9
|
'formatter',
|
|
@@ -11,9 +12,8 @@ export const LabelText = (props) => {
|
|
|
11
12
|
]);
|
|
12
13
|
const fontSize = 14;
|
|
13
14
|
const lineHeight = 1.4;
|
|
14
|
-
const height = restProps.height
|
|
15
|
-
|
|
16
|
-
return (_jsx(ItemLabel, { ...restProps, indexes: indexes, width: width, height: height, lineHeight: lineHeight, fill: usePaletteColor ? themeColors.colorPrimary : themeColors.colorText, fontSize: fontSize, fontWeight: "regular", alignHorizontal: positionH === 'flipped'
|
|
15
|
+
const height = (_a = restProps.height) !== null && _a !== void 0 ? _a : Math.ceil(lineNumber * lineHeight * fontSize);
|
|
16
|
+
return (_jsx(ItemLabel, Object.assign({}, restProps, { indexes: indexes, width: width, height: height, lineHeight: lineHeight, fill: usePaletteColor ? themeColors.colorPrimary : themeColors.colorText, fontSize: fontSize, fontWeight: "regular", alignHorizontal: positionH === 'flipped'
|
|
17
17
|
? 'right'
|
|
18
18
|
: positionH === 'center'
|
|
19
19
|
? 'center'
|
|
@@ -21,7 +21,7 @@ export const LabelText = (props) => {
|
|
|
21
21
|
? 'bottom'
|
|
22
22
|
: positionV === 'center'
|
|
23
23
|
? 'middle'
|
|
24
|
-
: 'top', children: formatter(datum.label || datum.desc) }));
|
|
24
|
+
: 'top', children: formatter(datum.label || datum.desc) })));
|
|
25
25
|
};
|
|
26
26
|
registerItem('plain-text', {
|
|
27
27
|
component: LabelText,
|
|
@@ -15,8 +15,8 @@ export const ProgressCard = (props) => {
|
|
|
15
15
|
'borderRadius',
|
|
16
16
|
]);
|
|
17
17
|
const value = datum.value;
|
|
18
|
-
const displayValue = value
|
|
19
|
-
const maxValue = Math.max(...data.items.map((item) => item.value
|
|
18
|
+
const displayValue = value !== null && value !== void 0 ? value : 0;
|
|
19
|
+
const maxValue = Math.max(...data.items.map((item) => { var _a; return (_a = item.value) !== null && _a !== void 0 ? _a : 0; }), 100);
|
|
20
20
|
const progressWidth = width - 2 * gap;
|
|
21
21
|
// 计算进度条的填充宽度
|
|
22
22
|
const progressScale = scaleLinear()
|
|
@@ -37,9 +37,9 @@ export const ProgressCard = (props) => {
|
|
|
37
37
|
const textY = iconY;
|
|
38
38
|
const progressY = height - gap - progressHeight;
|
|
39
39
|
const hasValue = value !== undefined;
|
|
40
|
-
return (_jsxs(Group, {
|
|
40
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsxs(Defs, { children: [_jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [_jsx("stop", { offset: "0%", stopColor: themeColors.colorPrimary }), _jsx("stop", { offset: "100%", stopColor: tinycolor
|
|
41
41
|
.mix(themeColors.colorPrimary, '#fff', 20)
|
|
42
|
-
.toHexString() })] }), _jsxs("linearGradient", { id: progressBgId, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [_jsx("stop", { offset: "0%", stopColor: themeColors.colorPrimaryBg }), _jsx("stop", { offset: "100%", stopColor: themeColors.colorBg })] })] }), _jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorBgElevated, stroke: themeColors.colorPrimaryBg, strokeWidth: 1, rx: borderRadius, ry: borderRadius, "data-element-type": "shape" }), _jsx(ItemIcon, { indexes: indexes, x: iconX, y: iconY, size: iconSize, fill: themeColors.colorPrimary }), _jsx(ItemLabel, { indexes: indexes, x: textStartX, y: textY, width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", fontSize: 16, fontWeight: "medium", fill: themeColors.colorText, children: datum.label }), hasValue && (_jsx(ItemValue, { indexes: indexes, x: textStartX, y: textY + labelBounds.height, width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", lineHeight: 1, fontSize: 24, fontWeight: "bold", fill: themeColors.colorPrimary, value: displayValue, formatter: valueFormatter })), _jsx(ItemDesc, { indexes: indexes, x: textStartX, y: textY + labelBounds.height + (hasValue ? 27 : 4), width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: hasValue ? 2 : 3, wordWrap: true, children: datum.desc }), _jsx(Rect, { x: gap, y: progressY, width: progressWidth, height: progressHeight, fill: `url(#${progressBgId})`, rx: progressHeight / 2, ry: progressHeight / 2, "data-element-type": "shape" }), _jsx(Rect, { x: gap, y: progressY, width: progressFillWidth, height: progressHeight, fill: `url(#${gradientId})`, rx: progressHeight / 2, ry: progressHeight / 2, "data-element-type": "shape" })] }));
|
|
42
|
+
.toHexString() })] }), _jsxs("linearGradient", { id: progressBgId, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [_jsx("stop", { offset: "0%", stopColor: themeColors.colorPrimaryBg }), _jsx("stop", { offset: "100%", stopColor: themeColors.colorBg })] })] }), _jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorBgElevated, stroke: themeColors.colorPrimaryBg, strokeWidth: 1, rx: borderRadius, ry: borderRadius, "data-element-type": "shape" }), _jsx(ItemIcon, { indexes: indexes, x: iconX, y: iconY, size: iconSize, fill: themeColors.colorPrimary }), _jsx(ItemLabel, { indexes: indexes, x: textStartX, y: textY, width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", fontSize: 16, fontWeight: "medium", fill: themeColors.colorText, children: datum.label }), hasValue && (_jsx(ItemValue, { indexes: indexes, x: textStartX, y: textY + labelBounds.height, width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", lineHeight: 1, fontSize: 24, fontWeight: "bold", fill: themeColors.colorPrimary, value: displayValue, formatter: valueFormatter })), _jsx(ItemDesc, { indexes: indexes, x: textStartX, y: textY + labelBounds.height + (hasValue ? 27 : 4), width: textWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "top", fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: hasValue ? 2 : 3, wordWrap: true, children: datum.desc }), _jsx(Rect, { x: gap, y: progressY, width: progressWidth, height: progressHeight, fill: `url(#${progressBgId})`, rx: progressHeight / 2, ry: progressHeight / 2, "data-element-type": "shape" }), _jsx(Rect, { x: gap, y: progressY, width: progressFillWidth, height: progressHeight, fill: `url(#${gradientId})`, rx: progressHeight / 2, ry: progressHeight / 2, "data-element-type": "shape" })] })));
|
|
43
43
|
};
|
|
44
44
|
registerItem('progress-card', {
|
|
45
45
|
component: ProgressCard,
|
|
@@ -106,7 +106,7 @@ export const QuarterCircular = (props) => {
|
|
|
106
106
|
: `M ${circleX} ${circleY} L ${circleX} ${circleY - circleRadius} A ${circleRadius} ${circleRadius} 0 0 0 ${circleX - circleRadius} ${circleY} Z`;
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
return (_jsxs(Group, {
|
|
109
|
+
return (_jsxs(Group, Object.assign({}, restProps, { width: width, height: height, children: [_jsxs(ShapesGroup, { children: [_jsx(Path, { d: `M ${decorationCoords.diagonalStartX} ${decorationCoords.diagonalStartY} L ${decorationCoords.diagonalEndX} ${decorationCoords.diagonalEndY}`, stroke: themeColors.colorPrimary, strokeWidth: LINE_WIDTH, fill: "none" }), _jsx(Path, { d: `M ${decorationCoords.topLineStartX} ${decorationCoords.topLineY} L ${decorationCoords.topLineEndX} ${decorationCoords.topLineY}`, stroke: themeColors.colorPrimary, strokeWidth: LINE_WIDTH, fill: "none" }), _jsx(Ellipse, { x: decorationCoords.diagonalStartX - DOT_RADIUS, y: decorationCoords.diagonalStartY - DOT_RADIUS, width: DOT_RADIUS * 2, height: DOT_RADIUS * 2, fill: themeColors.colorPrimary }), _jsx(Ellipse, { x: decorationCoords.topLineEndX - DOT_RADIUS, y: decorationCoords.topLineY - DOT_RADIUS, width: DOT_RADIUS * 2, height: DOT_RADIUS * 2, fill: themeColors.colorPrimary })] }), _jsxs(Group, { children: [_jsx(Text, { x: contentCoords.valueX, y: CARD_CONTENT_Y, fontSize: VALUE_SIZE, fontWeight: "bold", fill: themeColors.colorPrimary, children: indexStr }), _jsx(Path, { d: getQuarterCirclePath(), fill: themeColors.colorPrimary, "data-element-type": "shape" }), datum.icon && (_jsx(ItemIcon, { indexes: indexes, x: contentCoords.iconX, y: iconY, size: iconSize, fill: themeColors.colorWhite })), datum.label && (_jsx(ItemLabel, { indexes: indexes, x: contentCoords.contentX, y: LABEL_Y, width: contentCoords.contentWidth, fontWeight: "bold", fill: themeColors.colorText, alignHorizontal: isFlipped ? 'right' : 'left', children: datum.label })), datum.desc && (_jsx(ItemDesc, { indexes: indexes, x: contentCoords.contentX, y: descY, width: contentCoords.contentWidth, fill: themeColors.colorTextSecondary, alignHorizontal: isFlipped ? 'right' : 'left', children: datum.desc }))] })] })));
|
|
110
110
|
};
|
|
111
111
|
registerItem('quarter-circular', {
|
|
112
112
|
component: QuarterCircular,
|
|
@@ -108,7 +108,7 @@ export const QuarterSimpleCard = (props) => {
|
|
|
108
108
|
Z
|
|
109
109
|
`;
|
|
110
110
|
}
|
|
111
|
-
return (_jsxs(Group, {
|
|
111
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsx(Path, { d: cardPath, x: 0, y: 0, width: width, height: height, fill: themeColors.colorPrimary, "data-element-type": "shape" }), _jsx(ItemIcon, { indexes: indexes, x: iconX, y: iconY, size: iconSize, fill: themeColors.colorBg }), _jsx(ItemLabel, { indexes: indexes, x: labelX, y: labelY, width: contentWidth, fontSize: 14, fontWeight: "bold", fill: themeColors.colorBg, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', children: datum.label }), datum.desc && (_jsx(ItemDesc, { indexes: indexes, x: descX, y: descY, width: contentWidth, fontSize: 11, wordWrap: true, fill: themeColors.colorBg, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', children: datum.desc }))] })));
|
|
112
112
|
};
|
|
113
113
|
registerItem('quarter-simple-card', {
|
|
114
114
|
component: QuarterSimpleCard,
|
|
@@ -13,9 +13,9 @@ export const RibbonCard = (props) => {
|
|
|
13
13
|
'ribbonHeight',
|
|
14
14
|
]);
|
|
15
15
|
const gradientId = `${themeColors.colorPrimary}-ribbon`;
|
|
16
|
-
return (_jsxs(Group, {
|
|
16
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsx(Defs, { children: _jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [_jsx("stop", { offset: "0%", stopColor: themeColors.colorPrimary }), _jsx("stop", { offset: "100%", stopColor: tinycolor(themeColors.colorPrimary)
|
|
17
17
|
.darken(15)
|
|
18
|
-
.toHexString() })] }) }), _jsxs(ShapesGroup, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorBgElevated, stroke: themeColors.colorPrimaryBg, strokeWidth: 1, rx: 8, ry: 8 }), _jsx(Rect, { x: 0, y: 0, width: width, height: ribbonHeight, fill: `url(#${gradientId})`, rx: 8, ry: 8 }), _jsx(Rect, { x: 0, y: 8, width: width, height: ribbonHeight - 8, fill: `url(#${gradientId})` }), _jsx(Path, { x: width - 20, y: ribbonHeight, width: 20, height: 8, fill: tinycolor(themeColors.colorPrimary).darken(25).toHexString(), d: "M0,0 L20,0 L15,8 L5,8 Z" })] }), _jsx(ItemIcon, { indexes: indexes, x: gap, y: ribbonHeight + gap, size: iconSize, fill: themeColors.colorPrimary }), _jsx(ItemLabel, { indexes: indexes, x: iconSize + 2 * gap, y: ribbonHeight + gap, width: width - iconSize - 3 * gap, height: iconSize, alignHorizontal: "left", alignVertical: "middle", lineHeight: 1, fontWeight: "bold", fill: themeColors.colorText, children: datum.label }), _jsx(ItemDesc, { indexes: indexes, x: gap, y: ribbonHeight + iconSize + gap + 5, width: width - 2 * gap, alignHorizontal: "left", fill: themeColors.colorTextSecondary, lineNumber: 3, wordWrap: true, children: datum.desc }), _jsx(ItemIcon, { indexes: indexes, x: width - gap - 8, y: gap / 2, size: 16, fill: themeColors.colorWhite })] }));
|
|
18
|
+
.toHexString() })] }) }), _jsxs(ShapesGroup, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorBgElevated, stroke: themeColors.colorPrimaryBg, strokeWidth: 1, rx: 8, ry: 8 }), _jsx(Rect, { x: 0, y: 0, width: width, height: ribbonHeight, fill: `url(#${gradientId})`, rx: 8, ry: 8 }), _jsx(Rect, { x: 0, y: 8, width: width, height: ribbonHeight - 8, fill: `url(#${gradientId})` }), _jsx(Path, { x: width - 20, y: ribbonHeight, width: 20, height: 8, fill: tinycolor(themeColors.colorPrimary).darken(25).toHexString(), d: "M0,0 L20,0 L15,8 L5,8 Z" })] }), _jsx(ItemIcon, { indexes: indexes, x: gap, y: ribbonHeight + gap, size: iconSize, fill: themeColors.colorPrimary }), _jsx(ItemLabel, { indexes: indexes, x: iconSize + 2 * gap, y: ribbonHeight + gap, width: width - iconSize - 3 * gap, height: iconSize, alignHorizontal: "left", alignVertical: "middle", lineHeight: 1, fontWeight: "bold", fill: themeColors.colorText, children: datum.label }), _jsx(ItemDesc, { indexes: indexes, x: gap, y: ribbonHeight + iconSize + gap + 5, width: width - 2 * gap, alignHorizontal: "left", fill: themeColors.colorTextSecondary, lineNumber: 3, wordWrap: true, children: datum.desc }), _jsx(ItemIcon, { indexes: indexes, x: width - gap - 8, y: gap / 2, size: 16, fill: themeColors.colorWhite })] })));
|
|
19
19
|
};
|
|
20
20
|
registerItem('ribbon-card', {
|
|
21
21
|
component: RibbonCard,
|
|
@@ -11,11 +11,11 @@ export const RoundedRectNode = (props) => {
|
|
|
11
11
|
const textY = padding;
|
|
12
12
|
const textWidth = width - borderRadius * 2;
|
|
13
13
|
const textHeight = height - padding * 2;
|
|
14
|
-
return (_jsxs(Group, {
|
|
14
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsx(Rect, { "data-element-type": "shape", width: width, height: height, rx: borderRadius, ry: borderRadius, fill: themeColors.colorPrimaryBg, stroke: themeColors.colorPrimary, strokeWidth: 1, opacity: 0.8 }), _jsx(ItemLabel, { indexes: indexes, x: textX, y: textY, width: textWidth, height: textHeight, alignHorizontal: positionH === 'flipped'
|
|
15
15
|
? 'right'
|
|
16
16
|
: positionH === 'center'
|
|
17
17
|
? 'center'
|
|
18
|
-
: 'left', alignVertical: "middle", fontSize: 14, fontWeight: "500", fill: themeColors.colorText, children: datum.label })] }));
|
|
18
|
+
: 'left', alignVertical: "middle", fontSize: 14, fontWeight: "500", fill: themeColors.colorText, children: datum.label })] })));
|
|
19
19
|
};
|
|
20
20
|
registerItem('rounded-rect-node', {
|
|
21
21
|
component: RoundedRectNode,
|
|
@@ -6,7 +6,7 @@ export const SimpleCircleNode = (props) => {
|
|
|
6
6
|
const [{ width = 24, height = width, strokeWidth = 2, themeColors, datum }, restProps,] = getItemProps(props, ['width', 'height']);
|
|
7
7
|
const size = Math.min(width, height) - strokeWidth;
|
|
8
8
|
const offset = strokeWidth / 2;
|
|
9
|
-
return (_jsxs(Group, {
|
|
9
|
+
return (_jsxs(Group, Object.assign({}, restProps, { width: width, height: height, children: [_jsx(Rect, { width: width, height: height, fill: "none", visibility: "hidden" }), _jsx(Ellipse, { x: offset, y: offset, width: size, height: size, fill: themeColors.colorPrimary, stroke: themeColors.isDarkMode ? '#FFF' : '#000', strokeWidth: strokeWidth, "data-element-type": "shape", children: _jsx("title", { children: datum.label || datum.desc }) })] })));
|
|
10
10
|
};
|
|
11
11
|
registerItem('simple-circle-node', {
|
|
12
12
|
component: SimpleCircleNode,
|
|
@@ -17,11 +17,11 @@ export const SimpleHorizontalArrow = (props) => {
|
|
|
17
17
|
const descBounds = getElementBounds(desc);
|
|
18
18
|
const textHeight = labelBounds.height + descBounds.height;
|
|
19
19
|
const totalHeight = textHeight + labelGap + arrowHeight + labelGap + textHeight;
|
|
20
|
-
return (_jsx(Group, { width: width, height: totalHeight,
|
|
20
|
+
return (_jsx(Group, Object.assign({ width: width, height: totalHeight }, restProps, { children: _jsxs(FlexLayout, { flexDirection: "column", alignItems: "center", children: [isVNormal ? (_jsxs(_Fragment, { children: [desc, label, _jsx(Gap, { height: labelGap })] })) : (_jsx(_Fragment, { children: _jsx(Gap, { height: textHeight + labelGap }) })), _jsxs(AlignLayout, { horizontal: "center", vertical: "middle", children: [_jsx(HorizontalArrow, { width: width, height: arrowHeight, fill: themeColors.colorPrimary }), _jsx(Text, { width: width, height: arrowHeight, alignHorizontal: "center", alignVertical: "middle", fill: themeColors.colorWhite, fontWeight: "bold", fontSize: 16, children: datum.time
|
|
21
21
|
? datum.time
|
|
22
22
|
: String(indexes[0] + 1)
|
|
23
23
|
.padStart(2, '0')
|
|
24
|
-
.slice(-2) })] }), !isVNormal ? (_jsxs(_Fragment, { children: [_jsx(Gap, { height: labelGap }), label, desc] })) : (_jsx(_Fragment, { children: _jsx(Gap, { height: textHeight + labelGap }) }))] }) }));
|
|
24
|
+
.slice(-2) })] }), !isVNormal ? (_jsxs(_Fragment, { children: [_jsx(Gap, { height: labelGap }), label, desc] })) : (_jsx(_Fragment, { children: _jsx(Gap, { height: textHeight + labelGap }) }))] }) })));
|
|
25
25
|
};
|
|
26
26
|
const HorizontalArrow = (props) => {
|
|
27
27
|
const { x = 0, y = 0, width = 100, height = 40, fill = '#FF356A', size = 10, } = props;
|
|
@@ -12,7 +12,7 @@ export const SimpleIllusItem = (props) => {
|
|
|
12
12
|
: themeColors.colorText;
|
|
13
13
|
const labelContent = (_jsx(ItemLabel, { indexes: indexes, width: width, alignHorizontal: "center", alignVertical: "middle", fill: labelColor, children: label }));
|
|
14
14
|
const labelBounds = getElementBounds(labelContent);
|
|
15
|
-
return (_jsxs(FlexLayout, {
|
|
15
|
+
return (_jsxs(FlexLayout, Object.assign({}, restProps, { width: width, height: illusSize + gap + labelBounds.height + gap + 48, flexDirection: "column", alignItems: "center", justifyContent: "center", gap: gap, children: [_jsx(Illus, { indexes: indexes, width: illusSize, height: illusSize }), labelContent, _jsx(ItemDesc, { indexes: indexes, width: width, alignHorizontal: "center", alignVertical: "top", fill: themeColors.colorTextSecondary, lineNumber: 3, children: desc })] })));
|
|
16
16
|
};
|
|
17
17
|
registerItem('simple-illus', {
|
|
18
18
|
component: SimpleIllusItem,
|
|
@@ -49,7 +49,7 @@ export const SimpleItem = (props) => {
|
|
|
49
49
|
? height - labelBounds.height - (descHeight || 0) - gap
|
|
50
50
|
: 0
|
|
51
51
|
: 0;
|
|
52
|
-
return (_jsxs(Group, {
|
|
52
|
+
return (_jsxs(Group, Object.assign({}, restProps, { children: [_jsx(ItemLabel, { indexes: indexes, width: width, y: labelY, alignHorizontal: textAlign, alignVertical: "middle", fill: labelColor, children: label }), _jsx(ItemDesc, { indexes: indexes, width: width, height: descHeight, y: labelY + labelBounds.height + gap, alignHorizontal: textAlign, alignVertical: getDescVerticalAlign(positionV, false), lineNumber: descLineNumber, fill: themeColors.colorTextSecondary, children: desc })] })));
|
|
53
53
|
}
|
|
54
54
|
if (positionH === 'center') {
|
|
55
55
|
// 计算 desc 的可用高度和行数
|
|
@@ -70,7 +70,7 @@ export const SimpleItem = (props) => {
|
|
|
70
70
|
? height - contentHeight - iconHeight - gap
|
|
71
71
|
: 0
|
|
72
72
|
: 0;
|
|
73
|
-
return (_jsx(FlexLayout, {
|
|
73
|
+
return (_jsx(FlexLayout, Object.assign({}, restProps, { flexDirection: "column", gap: gap, alignItems: "center", children: positionV === 'flipped' ? (_jsxs(_Fragment, { children: [_jsxs(Group, { children: [_jsx(ItemLabel, { indexes: indexes, width: width, y: labelY, alignHorizontal: "center", alignVertical: "middle", fill: labelColor, children: label }), _jsx(ItemDesc, { indexes: indexes, width: width, height: descHeight, y: labelY + labelBounds.height + gap, alignHorizontal: "center", alignVertical: "bottom", lineNumber: descLineNumber, fill: themeColors.colorTextSecondary, children: desc })] }), iconContent] })) : (_jsxs(_Fragment, { children: [iconContent, _jsxs(Group, { children: [_jsx(ItemLabel, { indexes: indexes, width: width, y: labelY, alignHorizontal: "center", alignVertical: "middle", fill: labelColor, children: label }), _jsx(ItemDesc, { indexes: indexes, width: width, height: descHeight, y: labelY + labelBounds.height + gap, alignHorizontal: "center", alignVertical: "top", lineNumber: descLineNumber, fill: themeColors.colorTextSecondary, children: desc })] })] })) })));
|
|
74
74
|
}
|
|
75
75
|
const iconBounds = getElementBounds(iconContent);
|
|
76
76
|
const textWidth = Math.max(width - iconBounds.width - gap, 0);
|
|
@@ -90,7 +90,7 @@ export const SimpleItem = (props) => {
|
|
|
90
90
|
? height - labelBounds.height - (descHeight || 0) - gap
|
|
91
91
|
: 0
|
|
92
92
|
: 0;
|
|
93
|
-
return (_jsx(FlexLayout, {
|
|
93
|
+
return (_jsx(FlexLayout, Object.assign({}, restProps, { flexDirection: "row", gap: gap, alignItems: getIconVerticalAlign(positionV), children: positionH === 'flipped' ? (_jsxs(_Fragment, { children: [_jsxs(Group, { children: [_jsx(ItemLabel, { indexes: indexes, width: textWidth, y: labelY, alignHorizontal: "right", alignVertical: "middle", fill: labelColor, children: label }), _jsx(ItemDesc, { indexes: indexes, width: textWidth, height: descHeight, y: labelY + labelBounds.height + gap, alignHorizontal: "right", alignVertical: getDescVerticalAlign(positionV, true), lineNumber: descLineNumber, fill: themeColors.colorTextSecondary, children: desc })] }), iconContent] })) : (_jsxs(_Fragment, { children: [iconContent, _jsxs(Group, { children: [_jsx(ItemLabel, { indexes: indexes, width: textWidth, y: labelY, alignHorizontal: "left", alignVertical: "middle", fill: labelColor, children: label }), _jsx(ItemDesc, { indexes: indexes, width: textWidth, height: descHeight, y: labelY + labelBounds.height + gap, alignHorizontal: "left", alignVertical: getDescVerticalAlign(positionV, true), lineNumber: descLineNumber, fill: themeColors.colorTextSecondary, children: desc })] })] })) })));
|
|
94
94
|
function getDescVerticalAlign(positionV, hasIcon) {
|
|
95
95
|
return 'top';
|
|
96
96
|
// if (positionV === 'normal') return 'top';
|
|
@@ -15,9 +15,9 @@ export const SimpleVerticalArrow = (props) => {
|
|
|
15
15
|
const arrowWidth = 30;
|
|
16
16
|
const textWidth = 120;
|
|
17
17
|
const totalWidth = textWidth + labelGap + arrowWidth + labelGap + textWidth;
|
|
18
|
-
return (_jsx(Group, { width: totalWidth, height: height,
|
|
18
|
+
return (_jsx(Group, Object.assign({ width: totalWidth, height: height }, restProps, { children: _jsxs(FlexLayout, { flexDirection: "row", alignItems: "center", children: [isNormal ? (_jsxs(_Fragment, { children: [_jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-end", children: [label, desc] }), _jsx(Gap, { width: labelGap })] })) : (_jsx(_Fragment, { children: _jsx(Gap, { width: textWidth + labelGap }) })), _jsxs(AlignLayout, { horizontal: "center", vertical: "middle", children: [_jsx(VerticalArrow, { width: arrowWidth, height: height, fill: themeColors.colorPrimary }), _jsx(Text, { width: arrowWidth, height: height, alignHorizontal: "center", alignVertical: "middle", fill: themeColors.colorWhite, fontWeight: "bold", fontSize: 16, children: String(indexes[0] + 1)
|
|
19
19
|
.padStart(2, '0')
|
|
20
|
-
.slice(-2) })] }), !isNormal ? (_jsxs(_Fragment, { children: [_jsx(Gap, { width: labelGap }), _jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-start", children: [label, desc] })] })) : (_jsx(_Fragment, { children: _jsx(Gap, { width: textWidth + labelGap }) }))] }) }));
|
|
20
|
+
.slice(-2) })] }), !isNormal ? (_jsxs(_Fragment, { children: [_jsx(Gap, { width: labelGap }), _jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-start", children: [label, desc] })] })) : (_jsx(_Fragment, { children: _jsx(Gap, { width: textWidth + labelGap }) }))] }) })));
|
|
21
21
|
};
|
|
22
22
|
const VerticalArrow = (props) => {
|
|
23
23
|
const { x = 0, y = 0, width = 30, height = 100, fill = '#FF356A', size = 10, } = props;
|
|
@@ -36,7 +36,7 @@ export const UnderlineText = (props) => {
|
|
|
36
36
|
// 描述文本位置
|
|
37
37
|
const descX = 0; // 使用 alignHorizontal 控制对齐
|
|
38
38
|
const descY = underlineY + underlineHeight + gap * 2;
|
|
39
|
-
return (_jsxs(Group, { width: width, height: contentHeight,
|
|
39
|
+
return (_jsxs(Group, Object.assign({ width: width, height: contentHeight }, restProps, { children: [datum.label && (_jsx(ItemLabel, { indexes: indexes, x: titleX, y: titleY, width: width, alignHorizontal: alignHorizontal, fill: themeColors.colorPrimary, fontSize: 18, fontWeight: "bold", children: datum.label })), datum.label && (_jsx(Rect, { x: underlineX, y: underlineY, width: underlineWidth, height: underlineHeight, fill: themeColors.colorPrimary, "data-element-type": "shape" })), datum.desc && (_jsx(ItemDesc, { indexes: indexes, width: width, x: descX, y: descY, alignHorizontal: alignHorizontal, wordWrap: true, fill: themeColors.colorText, children: datum.desc }))] })));
|
|
40
40
|
};
|
|
41
41
|
registerItem('underline-text', {
|
|
42
42
|
component: UnderlineText,
|
|
@@ -28,9 +28,9 @@ export const VerticalIconArrow = (props) => {
|
|
|
28
28
|
const totalWidth = Math.max(labelBounds.width + dotLineGap + dotLineBounds.width, iconGap + iconBounds.width) *
|
|
29
29
|
2 +
|
|
30
30
|
arrowWidth;
|
|
31
|
-
return (_jsx(Group, { width: totalWidth, height: height,
|
|
31
|
+
return (_jsx(Group, Object.assign({ width: totalWidth, height: height }, restProps, { children: _jsxs(FlexLayout, { flexDirection: "row", alignItems: "center", children: [isNormal ? (_jsxs(_Fragment, { children: [_jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-end", children: [label, desc] }), _jsx(Gap, { width: dotLineGap }), dotLine] })) : (_jsxs(_Fragment, { children: [_jsx(Gap, { width: fixedGap }), icon, _jsx(Gap, { width: iconGap })] })), _jsxs(AlignLayout, { horizontal: "center", vertical: "middle", children: [_jsx(VerticalArrow, { width: arrowWidth, height: height, fill: themeColors.colorPrimary }), _jsx(Text, { width: arrowWidth, height: height, alignHorizontal: "center", alignVertical: "middle", fill: themeColors.colorWhite, fontWeight: "bold", fontSize: 16, children: String(indexes[0] + 1)
|
|
32
32
|
.padStart(2, '0')
|
|
33
|
-
.slice(-2) })] }), !isNormal ? (_jsxs(_Fragment, { children: [dotLine, _jsx(Gap, { width: dotLineGap }), _jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-start", children: [label, desc] })] })) : (_jsxs(_Fragment, { children: [_jsx(Gap, { width: iconGap }), icon] }))] }) }));
|
|
33
|
+
.slice(-2) })] }), !isNormal ? (_jsxs(_Fragment, { children: [dotLine, _jsx(Gap, { width: dotLineGap }), _jsxs(FlexLayout, { flexDirection: "column", alignItems: "flex-start", children: [label, desc] })] })) : (_jsxs(_Fragment, { children: [_jsx(Gap, { width: iconGap }), icon] }))] }) })));
|
|
34
34
|
};
|
|
35
35
|
const VerticalArrow = (props) => {
|
|
36
36
|
const { x = 0, y = 0, width = 30, height = 100, fill = '#FF356A', size = 10, } = props;
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "../../jsx-runtime.js";
|
|
2
13
|
import { cloneElement, createLayout, getElementBounds, getElementsBounds, Group, } from '../../jsx/index.js';
|
|
3
|
-
export const AlignLayout = createLayout((children,
|
|
14
|
+
export const AlignLayout = createLayout((children, _a) => {
|
|
15
|
+
var _b, _c, _d, _e;
|
|
16
|
+
var { horizontal, vertical } = _a, props = __rest(_a, ["horizontal", "vertical"]);
|
|
4
17
|
if (!children || children.length === 0) {
|
|
5
|
-
return _jsx(Group, {
|
|
18
|
+
return _jsx(Group, Object.assign({}, props));
|
|
6
19
|
}
|
|
7
20
|
const childBounds = children.map((child) => getElementBounds(child));
|
|
8
21
|
const childrenBounds = getElementsBounds(children);
|
|
9
22
|
// 容器尺寸和位置
|
|
10
|
-
const containerX = props.x
|
|
11
|
-
const containerY = props.y
|
|
12
|
-
const containerWidth = props.width
|
|
13
|
-
const containerHeight = props.height
|
|
23
|
+
const containerX = (_b = props.x) !== null && _b !== void 0 ? _b : childrenBounds.x;
|
|
24
|
+
const containerY = (_c = props.y) !== null && _c !== void 0 ? _c : childrenBounds.y;
|
|
25
|
+
const containerWidth = (_d = props.width) !== null && _d !== void 0 ? _d : childrenBounds.width;
|
|
26
|
+
const containerHeight = (_e = props.height) !== null && _e !== void 0 ? _e : childrenBounds.height;
|
|
14
27
|
// 对齐子元素(使用相对于容器的坐标)
|
|
15
28
|
const positionedChildren = children.map((child, index) => {
|
|
16
29
|
const bounds = childBounds[index];
|
|
17
|
-
const childProps = {
|
|
30
|
+
const childProps = Object.assign({}, child.props);
|
|
18
31
|
// 水平对齐(相对于容器左边界)
|
|
19
32
|
if (horizontal !== undefined) {
|
|
20
33
|
switch (horizontal) {
|
|
@@ -53,12 +66,6 @@ export const AlignLayout = createLayout((children, { horizontal, vertical, ...pr
|
|
|
53
66
|
}
|
|
54
67
|
return cloneElement(child, childProps);
|
|
55
68
|
});
|
|
56
|
-
const containerProps = {
|
|
57
|
-
|
|
58
|
-
x: containerX,
|
|
59
|
-
y: containerY,
|
|
60
|
-
width: containerWidth,
|
|
61
|
-
height: containerHeight,
|
|
62
|
-
};
|
|
63
|
-
return _jsx(Group, { ...containerProps, children: positionedChildren });
|
|
69
|
+
const containerProps = Object.assign(Object.assign({}, props), { x: containerX, y: containerY, width: containerWidth, height: containerHeight });
|
|
70
|
+
return _jsx(Group, Object.assign({}, containerProps, { children: positionedChildren }));
|
|
64
71
|
});
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "../../jsx-runtime.js";
|
|
2
13
|
import { cloneElement, createLayout, getElementBounds, getElementsBounds, Group, } from '../../jsx/index.js';
|
|
3
|
-
export const FlexLayout = createLayout((children,
|
|
14
|
+
export const FlexLayout = createLayout((children, _a) => {
|
|
15
|
+
var _b, _c, _d, _e, _f, _g;
|
|
16
|
+
var { flexDirection = 'row', justifyContent = 'flex-start', alignItems = 'flex-start', alignContent = 'flex-start', flexWrap = 'nowrap', gap = 0 } = _a, props = __rest(_a, ["flexDirection", "justifyContent", "alignItems", "alignContent", "flexWrap", "gap"]);
|
|
4
17
|
if (!children || children.length === 0) {
|
|
5
|
-
return _jsx(Group, {
|
|
18
|
+
return _jsx(Group, Object.assign({}, props));
|
|
6
19
|
}
|
|
7
20
|
const isRow = flexDirection === 'row' || flexDirection === 'row-reverse';
|
|
8
21
|
const isReverse = flexDirection === 'row-reverse' || flexDirection === 'column-reverse';
|
|
9
22
|
const childBounds = children.map((child) => getElementBounds(child));
|
|
10
23
|
const childrenBounds = getElementsBounds(children);
|
|
11
|
-
const containerWidth = props.width
|
|
12
|
-
const containerHeight = props.height
|
|
24
|
+
const containerWidth = (_b = props.width) !== null && _b !== void 0 ? _b : childrenBounds.width;
|
|
25
|
+
const containerHeight = (_c = props.height) !== null && _c !== void 0 ? _c : childrenBounds.height;
|
|
13
26
|
const hasContainerSize = props.width !== undefined && props.height !== undefined;
|
|
14
27
|
const lines = [];
|
|
15
28
|
if (flexWrap === 'wrap' && hasContainerSize) {
|
|
@@ -139,7 +152,7 @@ export const FlexLayout = createLayout((children, { flexDirection = 'row', justi
|
|
|
139
152
|
const lineEndIndex = lineStartIndex + line.children.length;
|
|
140
153
|
for (let i = lineStartIndex; i < lineEndIndex; i++) {
|
|
141
154
|
const child = layoutChildren[i];
|
|
142
|
-
const newProps = {
|
|
155
|
+
const newProps = Object.assign({}, child.props);
|
|
143
156
|
if (isRow) {
|
|
144
157
|
newProps.y = (newProps.y || 0) + currentOffset;
|
|
145
158
|
}
|
|
@@ -162,7 +175,7 @@ export const FlexLayout = createLayout((children, { flexDirection = 'row', justi
|
|
|
162
175
|
}
|
|
163
176
|
if (crossOffset !== 0 && alignContent !== 'space-between') {
|
|
164
177
|
layoutChildren.forEach((child, index) => {
|
|
165
|
-
const newProps = {
|
|
178
|
+
const newProps = Object.assign({}, child.props);
|
|
166
179
|
if (isRow) {
|
|
167
180
|
newProps.y = (newProps.y || 0) + crossOffset;
|
|
168
181
|
}
|
|
@@ -180,7 +193,7 @@ export const FlexLayout = createLayout((children, { flexDirection = 'row', justi
|
|
|
180
193
|
layoutChildren.forEach((child, index) => {
|
|
181
194
|
const bounds = childBounds[index];
|
|
182
195
|
const centerOffset = (maxHeight - bounds.height) / 2;
|
|
183
|
-
const newProps = {
|
|
196
|
+
const newProps = Object.assign({}, child.props);
|
|
184
197
|
newProps.y = (newProps.y || 0) + centerOffset;
|
|
185
198
|
layoutChildren[index] = cloneElement(child, newProps);
|
|
186
199
|
});
|
|
@@ -190,7 +203,7 @@ export const FlexLayout = createLayout((children, { flexDirection = 'row', justi
|
|
|
190
203
|
layoutChildren.forEach((child, index) => {
|
|
191
204
|
const bounds = childBounds[index];
|
|
192
205
|
const centerOffset = (maxWidth - bounds.width) / 2;
|
|
193
|
-
const newProps = {
|
|
206
|
+
const newProps = Object.assign({}, child.props);
|
|
194
207
|
newProps.x = (newProps.x || 0) + centerOffset;
|
|
195
208
|
layoutChildren[index] = cloneElement(child, newProps);
|
|
196
209
|
});
|
|
@@ -198,12 +211,6 @@ export const FlexLayout = createLayout((children, { flexDirection = 'row', justi
|
|
|
198
211
|
}
|
|
199
212
|
}
|
|
200
213
|
const finalBounds = getElementsBounds(layoutChildren);
|
|
201
|
-
const containerProps = {
|
|
202
|
-
|
|
203
|
-
x: props.x ?? childrenBounds.x,
|
|
204
|
-
y: props.y ?? childrenBounds.y,
|
|
205
|
-
width: props.width ?? finalBounds.width,
|
|
206
|
-
height: props.height ?? finalBounds.height,
|
|
207
|
-
};
|
|
208
|
-
return _jsx(Group, { ...containerProps, children: layoutChildren });
|
|
214
|
+
const containerProps = Object.assign(Object.assign({}, props), { x: (_d = props.x) !== null && _d !== void 0 ? _d : childrenBounds.x, y: (_e = props.y) !== null && _e !== void 0 ? _e : childrenBounds.y, width: (_f = props.width) !== null && _f !== void 0 ? _f : finalBounds.width, height: (_g = props.height) !== null && _g !== void 0 ? _g : finalBounds.height });
|
|
215
|
+
return _jsx(Group, Object.assign({}, containerProps, { children: layoutChildren }));
|
|
209
216
|
});
|
|
@@ -7,22 +7,23 @@ import { FlexLayout } from '../layouts/index.js';
|
|
|
7
7
|
import { getColorPrimary, getPaletteColor, getThemeColors } from '../utils/index.js';
|
|
8
8
|
import { registerStructure } from './registry.js';
|
|
9
9
|
export const ChartBar = (props) => {
|
|
10
|
+
var _a, _b, _c;
|
|
10
11
|
const { Title, Item, data, width, gap, barGap, barHeight = 28, barAreaWidth, labelGap = 16, padding = 24, showValue = true, options, valueFormatter = (value) => value.toString(), } = props;
|
|
11
|
-
const resolvedBarAreaWidth = barAreaWidth
|
|
12
|
+
const resolvedBarAreaWidth = (_a = barAreaWidth !== null && barAreaWidth !== void 0 ? barAreaWidth : width) !== null && _a !== void 0 ? _a : 480;
|
|
12
13
|
const { title, desc, items = [], xTitle, yTitle } = data;
|
|
13
14
|
const titleContent = Title ? _jsx(Title, { title: title, desc: desc }) : null;
|
|
14
15
|
if (items.length === 0) {
|
|
15
16
|
return (_jsx(FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", children: titleContent }));
|
|
16
17
|
}
|
|
17
18
|
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = parsePadding(padding);
|
|
18
|
-
const sampleDatum = items[0]
|
|
19
|
+
const sampleDatum = (_b = items[0]) !== null && _b !== void 0 ? _b : { label: '', value: 0 };
|
|
19
20
|
const itemBounds = getElementBounds(_jsx(Item, { indexes: [0], datum: sampleDatum, data: data }));
|
|
20
21
|
const labelWidth = itemBounds.width || 140;
|
|
21
22
|
const labelHeight = itemBounds.height || barHeight;
|
|
22
23
|
const rowHeight = Math.max(barHeight, labelHeight);
|
|
23
24
|
const gapByHeight = Math.max(12, rowHeight * 0.35);
|
|
24
|
-
const resolvedGap = barGap
|
|
25
|
-
const values = items.map((item) => item.value
|
|
25
|
+
const resolvedGap = (_c = barGap !== null && barGap !== void 0 ? barGap : gap) !== null && _c !== void 0 ? _c : gapByHeight;
|
|
26
|
+
const values = items.map((item) => { var _a; return (_a = item.value) !== null && _a !== void 0 ? _a : 0; });
|
|
26
27
|
const maxValue = Math.max(...values, 0);
|
|
27
28
|
const minValue = Math.min(...values, 0);
|
|
28
29
|
const domainMin = minValue < 0 ? minValue * 1.1 : 0;
|
|
@@ -58,8 +59,9 @@ export const ChartBar = (props) => {
|
|
|
58
59
|
const axisY = yStart + chartHeight + axisGap;
|
|
59
60
|
const formatTick = (value) => Number.isInteger(value) ? value.toString() : value.toFixed(1);
|
|
60
61
|
items.forEach((item, index) => {
|
|
62
|
+
var _a;
|
|
61
63
|
const indexes = [index];
|
|
62
|
-
const value = item.value
|
|
64
|
+
const value = (_a = item.value) !== null && _a !== void 0 ? _a : 0;
|
|
63
65
|
const rowY = yStart + index * (rowHeight + resolvedGap);
|
|
64
66
|
const barY = rowY + (rowHeight - barHeight) / 2;
|
|
65
67
|
const barX = value >= 0 ? barStartX + zeroX : barStartX + scale(value);
|
|
@@ -15,7 +15,7 @@ export const ChartColumn = (props) => {
|
|
|
15
15
|
return (_jsx(FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", children: titleContent }));
|
|
16
16
|
}
|
|
17
17
|
const themeColors = getThemeColors(options.themeConfig);
|
|
18
|
-
const values = items.map((item) => item.value
|
|
18
|
+
const values = items.map((item) => { var _a; return (_a = item.value) !== null && _a !== void 0 ? _a : 0; });
|
|
19
19
|
const sortedValues = [...values, 0].sort((a, b) => a - b);
|
|
20
20
|
const hasNegative = sortedValues[0] < 0;
|
|
21
21
|
const chartWidth = items.length * columnWidth + (items.length - 1) * columnGap;
|
|
@@ -36,8 +36,9 @@ export const ChartColumn = (props) => {
|
|
|
36
36
|
const itemElements = [];
|
|
37
37
|
const gradientDefs = [];
|
|
38
38
|
items.forEach((item, index) => {
|
|
39
|
+
var _a;
|
|
39
40
|
const indexes = [index];
|
|
40
|
-
const value = item.value
|
|
41
|
+
const value = (_a = item.value) !== null && _a !== void 0 ? _a : 0;
|
|
41
42
|
const columnX = paddingLeft + index * (columnWidth + columnGap);
|
|
42
43
|
const columnY = value >= 0 ? yScale(value) : zeroY;
|
|
43
44
|
const columnHeight = Math.abs(yScale(value) - zeroY);
|
|
@@ -21,7 +21,7 @@ export const ChartLine = (props) => {
|
|
|
21
21
|
positionH: 'center',
|
|
22
22
|
positionV: 'normal',
|
|
23
23
|
};
|
|
24
|
-
const sampleBounds = getElementBounds(_jsx(Item, {
|
|
24
|
+
const sampleBounds = getElementBounds(_jsx(Item, Object.assign({}, itemProps)));
|
|
25
25
|
const labelWidth = sampleBounds.width;
|
|
26
26
|
const labelHeight = sampleBounds.height;
|
|
27
27
|
const xTickSpace = Math.max(28, labelHeight + 14);
|
|
@@ -41,7 +41,7 @@ export const ChartLine = (props) => {
|
|
|
41
41
|
const chartOriginY = paddingTop + yTitleSpace;
|
|
42
42
|
const totalWidth = chartOriginX + derivedChartWidth + paddingRight;
|
|
43
43
|
const totalHeight = chartOriginY + height + xTickSpace + xTitleSpace + paddingBottom;
|
|
44
|
-
const values = items.map((item) => item.value
|
|
44
|
+
const values = items.map((item) => { var _a; return (_a = item.value) !== null && _a !== void 0 ? _a : 0; });
|
|
45
45
|
const maxValue = Math.max(...values, 0);
|
|
46
46
|
const minValue = Math.min(...values, 0);
|
|
47
47
|
const domainPadding = Math.max(Math.abs(maxValue), Math.abs(minValue)) * 0.1;
|
|
@@ -98,10 +98,11 @@ export const ChartLine = (props) => {
|
|
|
98
98
|
return segments.join(' ');
|
|
99
99
|
};
|
|
100
100
|
items.forEach((item, index) => {
|
|
101
|
+
var _a;
|
|
101
102
|
const x = chartOriginX + index * spacing + labelWidth / 2;
|
|
102
|
-
const y = chartOriginY + scaleY(item.value
|
|
103
|
+
const y = chartOriginY + scaleY((_a = item.value) !== null && _a !== void 0 ? _a : 0);
|
|
103
104
|
pointPositions.push({ x, y, datum: item });
|
|
104
|
-
xLabels.push(_jsx(Item, {
|
|
105
|
+
xLabels.push(_jsx(Item, Object.assign({}, itemProps, { indexes: [index], datum: item, x: x - labelWidth / 2, y: chartOriginY + height + 4 })));
|
|
105
106
|
const stopColor = getPaletteColor(options, [index]) || themeColors.colorPrimary;
|
|
106
107
|
colorStopsData.push({ x, color: stopColor });
|
|
107
108
|
});
|
|
@@ -142,10 +143,11 @@ export const ChartLine = (props) => {
|
|
|
142
143
|
].join(' ');
|
|
143
144
|
lineElements.push(_jsx(Path, { d: areaPath, width: derivedChartWidth, height: height, fill: `url(#${gradientAreaId})`, stroke: "none", "data-element-type": "shape" }));
|
|
144
145
|
pointPositions.forEach((pos, index) => {
|
|
146
|
+
var _a;
|
|
145
147
|
const paletteColor = getPaletteColor(options, [index]) || themeColors.colorPrimary;
|
|
146
148
|
pointElements.push(_jsx(Ellipse, { x: pos.x - 6, y: pos.y - 6, width: 12, height: 12, fill: paletteColor, "data-element-type": "shape" }));
|
|
147
149
|
if (showValue) {
|
|
148
|
-
valueElements.push(_jsx(Text, { x: pos.x, y: pos.y - 12, alignHorizontal: "center", alignVertical: "bottom", fontSize: 12, fontWeight: "bold", fill: paletteColor, children: valueFormatter(pos.datum.value
|
|
150
|
+
valueElements.push(_jsx(Text, { x: pos.x, y: pos.y - 12, alignHorizontal: "center", alignVertical: "bottom", fontSize: 12, fontWeight: "bold", fill: paletteColor, children: valueFormatter((_a = pos.datum.value) !== null && _a !== void 0 ? _a : 0, pos.datum) }));
|
|
149
151
|
}
|
|
150
152
|
});
|
|
151
153
|
axisElements.push(_jsx(Path, { d: `M ${chartOriginX} ${chartOriginY + axisBaseY} L ${chartOriginX + derivedChartWidth} ${chartOriginY + axisBaseY}`, width: derivedChartWidth, height: 1, stroke: axisColor, strokeWidth: 1, "data-element-type": "shape" }));
|