@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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chartPieTemplates = void 0;
|
|
4
|
+
exports.chartPieTemplates = {
|
|
5
|
+
'chart-pie-plain-text': {
|
|
6
|
+
design: {
|
|
7
|
+
title: 'default',
|
|
8
|
+
structure: {
|
|
9
|
+
type: 'chart-pie',
|
|
10
|
+
},
|
|
11
|
+
items: [
|
|
12
|
+
{
|
|
13
|
+
type: 'plain-text',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
'chart-pie-compact-card': {
|
|
19
|
+
design: {
|
|
20
|
+
title: 'default',
|
|
21
|
+
structure: {
|
|
22
|
+
type: 'chart-pie',
|
|
23
|
+
avoidLabelOverlap: true,
|
|
24
|
+
},
|
|
25
|
+
items: [
|
|
26
|
+
{
|
|
27
|
+
type: 'compact-card',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'chart-pie-pill-badge': {
|
|
33
|
+
design: {
|
|
34
|
+
title: 'default',
|
|
35
|
+
structure: {
|
|
36
|
+
type: 'chart-pie',
|
|
37
|
+
avoidLabelOverlap: true,
|
|
38
|
+
},
|
|
39
|
+
items: [
|
|
40
|
+
{
|
|
41
|
+
type: 'pill-badge',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
'chart-pie-donut-plain-text': {
|
|
47
|
+
design: {
|
|
48
|
+
title: 'default',
|
|
49
|
+
structure: {
|
|
50
|
+
type: 'chart-pie',
|
|
51
|
+
innerRadius: 90,
|
|
52
|
+
},
|
|
53
|
+
items: [
|
|
54
|
+
{
|
|
55
|
+
type: 'plain-text',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
'chart-pie-donut-compact-card': {
|
|
61
|
+
design: {
|
|
62
|
+
title: 'default',
|
|
63
|
+
structure: {
|
|
64
|
+
type: 'chart-pie',
|
|
65
|
+
innerRadius: 90,
|
|
66
|
+
avoidLabelOverlap: true,
|
|
67
|
+
},
|
|
68
|
+
items: [
|
|
69
|
+
{
|
|
70
|
+
type: 'compact-card',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
'chart-pie-donut-pill-badge': {
|
|
76
|
+
design: {
|
|
77
|
+
title: 'default',
|
|
78
|
+
structure: {
|
|
79
|
+
type: 'chart-pie',
|
|
80
|
+
innerRadius: 90,
|
|
81
|
+
avoidLabelOverlap: true,
|
|
82
|
+
},
|
|
83
|
+
items: [
|
|
84
|
+
{
|
|
85
|
+
type: 'pill-badge',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -36,11 +36,7 @@ const ROUNDED_RECT_NODE = {
|
|
|
36
36
|
const COMPACT_CARD = {
|
|
37
37
|
type: 'compact-card',
|
|
38
38
|
};
|
|
39
|
-
const createStructure = (gradient, edgeAlign) => ({
|
|
40
|
-
type: 'hierarchy-mindmap',
|
|
41
|
-
...(edgeAlign !== undefined ? { edgeAlign } : {}),
|
|
42
|
-
...gradient,
|
|
43
|
-
});
|
|
39
|
+
const createStructure = (gradient, edgeAlign) => (Object.assign(Object.assign({ type: 'hierarchy-mindmap' }, (edgeAlign !== undefined ? { edgeAlign } : {})), gradient));
|
|
44
40
|
const createTemplate = (key, gradient, item, edgeAlign) => [
|
|
45
41
|
key,
|
|
46
42
|
{
|
|
@@ -67,11 +67,7 @@ for (const item of items) {
|
|
|
67
67
|
const templateName = createTemplateName(key, name, item);
|
|
68
68
|
exports.hierarchyTreeTemplates[templateName] = {
|
|
69
69
|
design: {
|
|
70
|
-
structure: {
|
|
71
|
-
type: 'hierarchy-tree',
|
|
72
|
-
...(orientation ? { orientation } : {}),
|
|
73
|
-
...structureProps,
|
|
74
|
-
},
|
|
70
|
+
structure: Object.assign(Object.assign({ type: 'hierarchy-tree' }, (orientation ? { orientation } : {})), structureProps),
|
|
75
71
|
item: {
|
|
76
72
|
type: item,
|
|
77
73
|
},
|
|
@@ -23,34 +23,10 @@ const baseStructureAttrs = {
|
|
|
23
23
|
colorMode: 'node',
|
|
24
24
|
};
|
|
25
25
|
const structures = {
|
|
26
|
-
tb: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
lr: {
|
|
32
|
-
...baseStructureAttrs,
|
|
33
|
-
rankdir: 'LR',
|
|
34
|
-
edgeRouting: 'orth',
|
|
35
|
-
},
|
|
36
|
-
'tb-animated': {
|
|
37
|
-
...baseStructureAttrs,
|
|
38
|
-
rankdir: 'TB',
|
|
39
|
-
edgeCornerRadius: 12,
|
|
40
|
-
edgeRouting: 'orth',
|
|
41
|
-
edgeAnimation: 'ant-line',
|
|
42
|
-
edgeDashPattern: '8,4',
|
|
43
|
-
edgeAnimationSpeed: 1,
|
|
44
|
-
},
|
|
45
|
-
'lr-animated': {
|
|
46
|
-
...baseStructureAttrs,
|
|
47
|
-
rankdir: 'LR',
|
|
48
|
-
edgeCornerRadius: 12,
|
|
49
|
-
edgeRouting: 'orth',
|
|
50
|
-
edgeAnimation: 'ant-line',
|
|
51
|
-
edgeDashPattern: '8,4',
|
|
52
|
-
edgeAnimationSpeed: 1,
|
|
53
|
-
},
|
|
26
|
+
tb: Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'TB', edgeRouting: 'orth' }),
|
|
27
|
+
lr: Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'LR', edgeRouting: 'orth' }),
|
|
28
|
+
'tb-animated': Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'TB', edgeCornerRadius: 12, edgeRouting: 'orth', edgeAnimation: 'ant-line', edgeDashPattern: '8,4', edgeAnimationSpeed: 1 }),
|
|
29
|
+
'lr-animated': Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'LR', edgeCornerRadius: 12, edgeRouting: 'orth', edgeAnimation: 'ant-line', edgeDashPattern: '8,4', edgeAnimationSpeed: 1 }),
|
|
54
30
|
};
|
|
55
31
|
exports.relationDagreFlowTemplates = {};
|
|
56
32
|
const omit = ['lr-capsule', 'tb-capsule'];
|
package/lib/themes/generator.js
CHANGED
|
@@ -15,7 +15,7 @@ const generateThemeColors = ({ colorPrimary, colorBg = '#ffffff', isDarkMode = f
|
|
|
15
15
|
};
|
|
16
16
|
exports.generateThemeColors = generateThemeColors;
|
|
17
17
|
const generatePrimaryBg = (primaryColor, isDarkMode) => {
|
|
18
|
-
return ((0, culori_1.formatHex8)({
|
|
18
|
+
return ((0, culori_1.formatHex8)(Object.assign(Object.assign({}, primaryColor), { alpha: isDarkMode ? 0.2 : 0.1 })) || '#ffffff');
|
|
19
19
|
};
|
|
20
20
|
const generateTextColor = (bgColor, isDarkMode) => {
|
|
21
21
|
if (isDarkMode) {
|
|
@@ -27,7 +27,7 @@ const generateTextColor = (bgColor, isDarkMode) => {
|
|
|
27
27
|
};
|
|
28
28
|
const generateSecondaryTextColor = (colorText) => {
|
|
29
29
|
const parsed = (0, culori_1.oklch)((0, culori_1.parse)(colorText));
|
|
30
|
-
const lighter = {
|
|
30
|
+
const lighter = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.2) });
|
|
31
31
|
return (0, culori_1.formatHex)(lighter);
|
|
32
32
|
};
|
|
33
33
|
const generatePrimaryTextColor = (colorPrimaryBg, isDarkMode) => {
|
|
@@ -50,7 +50,7 @@ const generatePrimaryTextColor = (colorPrimaryBg, isDarkMode) => {
|
|
|
50
50
|
const generateElevatedBg = (bgColor, isDarkMode) => {
|
|
51
51
|
const parsed = (0, culori_1.oklch)(bgColor);
|
|
52
52
|
if (isDarkMode) {
|
|
53
|
-
const lightened = {
|
|
53
|
+
const lightened = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.1) });
|
|
54
54
|
return safeFormatHex(lightened, '#1f1f1f');
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -58,7 +58,7 @@ const generateElevatedBg = (bgColor, isDarkMode) => {
|
|
|
58
58
|
return '#ffffff';
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
const lightened = {
|
|
61
|
+
const lightened = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.05) });
|
|
62
62
|
return safeFormatHex(lightened, '#ffffff');
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -71,16 +71,10 @@ const createBaseTheme = ({ primaryColor, bgColor, }) => ({
|
|
|
71
71
|
const addDerivedColors = (baseTheme, { primaryColor, bgColor, isDarkMode, }) => {
|
|
72
72
|
const textColor = generateTextColor(bgColor, isDarkMode);
|
|
73
73
|
const colorPrimaryBg = generatePrimaryBg(primaryColor, isDarkMode);
|
|
74
|
-
return {
|
|
75
|
-
|
|
76
|
-
isDarkMode,
|
|
77
|
-
colorPrimaryBg,
|
|
78
|
-
colorText: textColor,
|
|
79
|
-
colorTextSecondary: generateSecondaryTextColor(textColor),
|
|
80
|
-
colorPrimaryText: generatePrimaryTextColor(colorPrimaryBg, isDarkMode),
|
|
81
|
-
colorBgElevated: generateElevatedBg(bgColor, isDarkMode),
|
|
82
|
-
};
|
|
74
|
+
return Object.assign(Object.assign({}, baseTheme), { isDarkMode,
|
|
75
|
+
colorPrimaryBg, colorText: textColor, colorTextSecondary: generateSecondaryTextColor(textColor), colorPrimaryText: generatePrimaryTextColor(colorPrimaryBg, isDarkMode), colorBgElevated: generateElevatedBg(bgColor, isDarkMode) });
|
|
83
76
|
};
|
|
84
77
|
function safeFormatHex(color, fallback = '#000000') {
|
|
85
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
return (_a = (0, culori_1.formatHex)(color)) !== null && _a !== void 0 ? _a : fallback;
|
|
86
80
|
}
|
package/lib/utils/fetch.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -27,41 +36,45 @@ function buildCacheKey(request) {
|
|
|
27
36
|
function buildResponse(entry) {
|
|
28
37
|
return new Response(entry.body.slice(0), entry.init);
|
|
29
38
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
function fetchAndCache(request, key) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const response = yield nativeFetch(request);
|
|
43
|
+
const body = yield response.arrayBuffer();
|
|
44
|
+
const entry = {
|
|
45
|
+
body,
|
|
46
|
+
init: {
|
|
47
|
+
status: response.status,
|
|
48
|
+
statusText: response.statusText,
|
|
49
|
+
headers: Array.from(response.headers.entries()),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
if (response.ok) {
|
|
53
|
+
responseCache.set(key, entry);
|
|
54
|
+
}
|
|
55
|
+
return entry;
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
pendingRequests.delete(key);
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
pendingRequests.delete(key);
|
|
49
|
-
}
|
|
60
|
+
});
|
|
50
61
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
function fetchWithCache(input, init) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const request = new Request(input, init);
|
|
65
|
+
if (request.method !== 'GET') {
|
|
66
|
+
return nativeFetch(request);
|
|
67
|
+
}
|
|
68
|
+
const key = buildCacheKey(request);
|
|
69
|
+
if (responseCache.has(key)) {
|
|
70
|
+
return buildResponse(responseCache.get(key));
|
|
71
|
+
}
|
|
72
|
+
let pending = pendingRequests.get(key);
|
|
73
|
+
if (!pending) {
|
|
74
|
+
pending = fetchAndCache(request, key);
|
|
75
|
+
pendingRequests.set(key, pending);
|
|
76
|
+
}
|
|
77
|
+
const entry = yield pending;
|
|
78
|
+
return buildResponse(entry);
|
|
79
|
+
});
|
|
67
80
|
}
|
package/lib/utils/icon.js
CHANGED
|
@@ -13,10 +13,7 @@ function getIconResourceConfig(icon) {
|
|
|
13
13
|
return ICON_RESOURCE_CACHE.get(icon) || null;
|
|
14
14
|
}
|
|
15
15
|
function createIconElement(value, attrs = {}) {
|
|
16
|
-
const icon = (0, svg_1.createElement)('use', {
|
|
17
|
-
...attrs,
|
|
18
|
-
href: (0, resource_1.getResourceHref)(value),
|
|
19
|
-
});
|
|
16
|
+
const icon = (0, svg_1.createElement)('use', Object.assign(Object.assign({}, attrs), { href: (0, resource_1.getResourceHref)(value) }));
|
|
20
17
|
applyIconColor(icon);
|
|
21
18
|
ICON_RESOURCE_CACHE.set(icon, value);
|
|
22
19
|
return icon;
|
package/lib/utils/is-browser.js
CHANGED
|
@@ -36,7 +36,7 @@ function isBrowser() {
|
|
|
36
36
|
rect.left !== 0 &&
|
|
37
37
|
rect.top !== 0;
|
|
38
38
|
}
|
|
39
|
-
catch {
|
|
39
|
+
catch (_a) {
|
|
40
40
|
hasRealLayout = false;
|
|
41
41
|
}
|
|
42
42
|
if (!hasRealLayout) {
|
|
@@ -58,7 +58,7 @@ function isBrowser() {
|
|
|
58
58
|
metrics.width > 0 &&
|
|
59
59
|
metrics.width < 1000;
|
|
60
60
|
}
|
|
61
|
-
catch {
|
|
61
|
+
catch (_b) {
|
|
62
62
|
hasRealCanvas = false;
|
|
63
63
|
}
|
|
64
64
|
if (hasRealCanvas)
|
|
@@ -86,6 +86,7 @@ function measureTextInBrowser(content, { fontFamily, fontSize, fontWeight, lineH
|
|
|
86
86
|
return { width: rect.width, height: rect.height };
|
|
87
87
|
}
|
|
88
88
|
function measureText(text = '', attrs) {
|
|
89
|
+
var _a;
|
|
89
90
|
if (attrs.width && attrs.height) {
|
|
90
91
|
return { width: attrs.width, height: attrs.height };
|
|
91
92
|
}
|
|
@@ -102,7 +103,7 @@ function measureText(text = '', attrs) {
|
|
|
102
103
|
};
|
|
103
104
|
const fallback = () => (0, measury_1.measureText)(content, options);
|
|
104
105
|
const metrics = (0, is_browser_1.isBrowser)()
|
|
105
|
-
? (measureTextInBrowser(content, options)
|
|
106
|
+
? ((_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback())
|
|
106
107
|
: fallback();
|
|
107
108
|
// 额外添加 1% 宽高
|
|
108
109
|
return {
|
package/lib/utils/padding.js
CHANGED
package/lib/utils/recognizer.js
CHANGED
|
@@ -12,7 +12,8 @@ const constants_1 = require("../constants");
|
|
|
12
12
|
const element_1 = require("./element");
|
|
13
13
|
const text_1 = require("./text");
|
|
14
14
|
const is = (element, role) => {
|
|
15
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = element === null || element === void 0 ? void 0 : element.dataset) === null || _a === void 0 ? void 0 : _a.elementType) === role;
|
|
16
17
|
};
|
|
17
18
|
const isTagName = (element, tagName) => {
|
|
18
19
|
return element.tagName.toLowerCase() === tagName.toLowerCase();
|
package/lib/utils/text.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.getTextEntity = getTextEntity;
|
|
4
15
|
exports.createTextElement = createTextElement;
|
|
@@ -39,7 +50,7 @@ function updateTextElement(text, props) {
|
|
|
39
50
|
if (entity) {
|
|
40
51
|
Object.assign(entity.style, getTextStyle(attributes));
|
|
41
52
|
if (!width || !height) {
|
|
42
|
-
const content = textContent
|
|
53
|
+
const content = textContent !== null && textContent !== void 0 ? textContent : getTextContent(text);
|
|
43
54
|
const { fontFamily, fontSize, fontWeight, lineHeight } = entity.style;
|
|
44
55
|
const fSize = fontSize ? parseFloat(String(fontSize)) : 12;
|
|
45
56
|
const rect = (0, measure_text_1.measureText)(content, {
|
|
@@ -116,7 +127,7 @@ function getTextStyle(attributes) {
|
|
|
116
127
|
['data-vertical-align']: verticalAlign, // omit
|
|
117
128
|
['font-size']: fontSize, ['letter-spacing']: letterSpacing, ['line-height']: lineHeight, fill, ['stroke-width']: strokeWidth, ['text-anchor']: textAnchor, // omit
|
|
118
129
|
['dominant-baseline']: dominantBaseline, // omit
|
|
119
|
-
['font-family']: fontFamily,
|
|
130
|
+
['font-family']: fontFamily } = attributes, restAttrs = __rest(attributes, ["x", "y", "width", "height", 'data-horizontal-align', 'data-vertical-align', 'font-size', 'letter-spacing', 'line-height', "fill", 'stroke-width', 'text-anchor', 'dominant-baseline', 'font-family']);
|
|
120
131
|
const style = {
|
|
121
132
|
overflow: 'visible',
|
|
122
133
|
// userSelect: 'none',
|
|
@@ -153,7 +164,7 @@ function setTextContent(text, content) {
|
|
|
153
164
|
try {
|
|
154
165
|
entity.innerText = content;
|
|
155
166
|
}
|
|
156
|
-
catch {
|
|
167
|
+
catch (_a) {
|
|
157
168
|
entity.textContent = content;
|
|
158
169
|
}
|
|
159
170
|
}
|
package/lib/utils/viewbox.d.ts
CHANGED
|
@@ -4,3 +4,23 @@ export declare function getViewBox(svg: SVGSVGElement): {
|
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
};
|
|
7
|
+
export declare function calculateZoomedViewBox(current: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}, factor: number, pivot: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function viewBoxToString(box: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}): string;
|
package/lib/utils/viewbox.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getViewBox = getViewBox;
|
|
4
|
+
exports.calculateZoomedViewBox = calculateZoomedViewBox;
|
|
5
|
+
exports.viewBoxToString = viewBoxToString;
|
|
4
6
|
function getViewBox(svg) {
|
|
5
7
|
const viewBox = svg.getAttribute('viewBox');
|
|
6
8
|
if (viewBox) {
|
|
@@ -13,3 +15,13 @@ function getViewBox(svg) {
|
|
|
13
15
|
const height = Number(heightStr) || 0;
|
|
14
16
|
return { x: 0, y: 0, width, height };
|
|
15
17
|
}
|
|
18
|
+
function calculateZoomedViewBox(current, factor, pivot) {
|
|
19
|
+
const newWidth = current.width * factor;
|
|
20
|
+
const newHeight = current.height * factor;
|
|
21
|
+
const newX = pivot.x - (pivot.x - current.x) * factor;
|
|
22
|
+
const newY = pivot.y - (pivot.y - current.y) * factor;
|
|
23
|
+
return { x: newX, y: newY, width: newWidth, height: newHeight };
|
|
24
|
+
}
|
|
25
|
+
function viewBoxToString(box) {
|
|
26
|
+
return `${box.x} ${box.y} ${box.width} ${box.height}`;
|
|
27
|
+
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.
|
|
1
|
+
export declare const VERSION = "0.2.13";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/infographic",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "An Infographic Generation and Rendering Framework, bring words to life!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -126,7 +126,6 @@
|
|
|
126
126
|
"@types/node": "^24.3.1",
|
|
127
127
|
"@types/tinycolor2": "^1.4.6",
|
|
128
128
|
"@vitest/coverage-v8": "^3.2.4",
|
|
129
|
-
"any-skills": "^0.1.1",
|
|
130
129
|
"csstype": "^3.2.2",
|
|
131
130
|
"eslint": "^9.35.0",
|
|
132
131
|
"globals": "^16.4.0",
|