@orbcharts/plugins-basic 3.0.0-beta.3 → 3.0.0-beta.4
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/LICENSE +200 -200
 - package/lib/core-types.ts +7 -7
 - package/lib/core.ts +6 -6
 - package/lib/plugins-basic-types.ts +6 -6
 - package/package.json +44 -44
 - package/src/base/BaseBarStack.ts +780 -780
 - package/src/base/BaseBars.ts +765 -765
 - package/src/base/BaseBarsTriangle.ts +674 -674
 - package/src/base/BaseDots.ts +515 -515
 - package/src/base/BaseGroupAxis.ts +679 -679
 - package/src/base/BaseLegend.ts +680 -680
 - package/src/base/BaseLineAreas.ts +629 -629
 - package/src/base/BaseLines.ts +706 -706
 - package/src/base/BaseTooltip.ts +385 -385
 - package/src/base/BaseValueAxis.ts +580 -580
 - package/src/base/types.ts +2 -2
 - package/src/const.ts +30 -30
 - package/src/grid/defaults.ts +244 -244
 - package/src/grid/gridObservables.ts +545 -545
 - package/src/grid/index.ts +16 -16
 - package/src/grid/plugins/BarStack.ts +64 -64
 - package/src/grid/plugins/Bars.ts +69 -69
 - package/src/grid/plugins/BarsPN.ts +66 -66
 - package/src/grid/plugins/BarsTriangle.ts +73 -73
 - package/src/grid/plugins/Dots.ts +68 -68
 - package/src/grid/plugins/GridLegend.ts +107 -107
 - package/src/grid/plugins/GridTooltip.ts +66 -66
 - package/src/grid/plugins/GridZoom.ts +218 -218
 - package/src/grid/plugins/GroupAux.ts +1098 -1098
 - package/src/grid/plugins/GroupAxis.ts +97 -97
 - package/src/grid/plugins/LineAreas.ts +65 -65
 - package/src/grid/plugins/Lines.ts +59 -59
 - package/src/grid/plugins/ValueAxis.ts +93 -93
 - package/src/grid/plugins/ValueStackAxis.ts +95 -95
 - package/src/index.ts +9 -9
 - package/src/multiGrid/defaults.ts +224 -224
 - package/src/multiGrid/index.ts +14 -14
 - package/src/multiGrid/multiGridObservables.ts +49 -49
 - package/src/multiGrid/plugins/MultiBarStack.ts +106 -106
 - package/src/multiGrid/plugins/MultiBars.ts +108 -108
 - package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
 - package/src/multiGrid/plugins/MultiDots.ts +102 -102
 - package/src/multiGrid/plugins/MultiGridLegend.ts +159 -159
 - package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
 - package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
 - package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
 - package/src/multiGrid/plugins/MultiLines.ts +101 -101
 - package/src/multiGrid/plugins/MultiValueAxis.ts +133 -133
 - package/src/multiGrid/plugins/MultiValueStackAxis.ts +133 -133
 - package/src/multiGrid/plugins/OverlappingValueAxes.ts +299 -299
 - package/src/multiGrid/plugins/OverlappingValueStackAxes.ts +298 -298
 - package/src/noneData/defaults.ts +102 -102
 - package/src/noneData/index.ts +3 -3
 - package/src/noneData/plugins/Container.ts +27 -27
 - package/src/noneData/plugins/Tooltip.ts +373 -373
 - package/src/series/defaults.ts +206 -206
 - package/src/series/index.ts +9 -9
 - package/src/series/plugins/Bubbles.ts +603 -603
 - package/src/series/plugins/Pie.ts +623 -623
 - package/src/series/plugins/PieEventTexts.ts +283 -283
 - package/src/series/plugins/PieLabels.ts +640 -640
 - package/src/series/plugins/Rose.ts +516 -516
 - package/src/series/plugins/RoseLabels.ts +600 -600
 - package/src/series/plugins/SeriesLegend.ts +107 -107
 - package/src/series/plugins/SeriesTooltip.ts +66 -66
 - package/src/series/seriesObservables.ts +145 -145
 - package/src/series/seriesUtils.ts +51 -51
 - package/src/tree/defaults.ts +78 -78
 - package/src/tree/index.ts +4 -4
 - package/src/tree/plugins/TreeLegend.ts +107 -107
 - package/src/tree/plugins/TreeMap.ts +333 -333
 - package/src/tree/plugins/TreeTooltip.ts +66 -66
 - package/src/utils/commonUtils.ts +21 -21
 - package/src/utils/d3Graphics.ts +174 -174
 - package/src/utils/d3Utils.ts +73 -73
 - package/src/utils/observables.ts +14 -14
 - package/src/utils/orbchartsUtils.ts +100 -100
 - package/tsconfig.base.json +13 -13
 - package/tsconfig.json +2 -2
 - package/vite.config.js +22 -22
 
    
        package/src/series/defaults.ts
    CHANGED
    
    | 
         @@ -1,207 +1,207 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '../../lib/core-types'
         
     | 
| 
       2 
     | 
    
         
            -
            import type {
         
     | 
| 
       3 
     | 
    
         
            -
              BubblesParams,
         
     | 
| 
       4 
     | 
    
         
            -
              PieParams,
         
     | 
| 
       5 
     | 
    
         
            -
              PieEventTextsParams,
         
     | 
| 
       6 
     | 
    
         
            -
              PieLabelsParams,
         
     | 
| 
       7 
     | 
    
         
            -
              RoseParams,
         
     | 
| 
       8 
     | 
    
         
            -
              RoseLabelsParams,
         
     | 
| 
       9 
     | 
    
         
            -
              SeriesLegendParams,
         
     | 
| 
       10 
     | 
    
         
            -
              SeriesTooltipParams
         
     | 
| 
       11 
     | 
    
         
            -
            } from '../../lib/plugins-basic-types'
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              
         
     | 
| 
       14 
     | 
    
         
            -
            export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
         
     | 
| 
       15 
     | 
    
         
            -
              force: {
         
     | 
| 
       16 
     | 
    
         
            -
                strength: 0.08, // 泡泡引力
         
     | 
| 
       17 
     | 
    
         
            -
                velocityDecay: 0.3, // 衰減數
         
     | 
| 
       18 
     | 
    
         
            -
                collisionSpacing: 2 // 泡泡間距
         
     | 
| 
       19 
     | 
    
         
            -
              },
         
     | 
| 
       20 
     | 
    
         
            -
              bubbleText: {
         
     | 
| 
       21 
     | 
    
         
            -
                fillRate: 0.6,
         
     | 
| 
       22 
     | 
    
         
            -
                lineHeight: 12,
         
     | 
| 
       23 
     | 
    
         
            -
                lineLengthMin: 4
         
     | 
| 
       24 
     | 
    
         
            -
              },
         
     | 
| 
       25 
     | 
    
         
            -
              // highlightRIncrease: 0,
         
     | 
| 
       26 
     | 
    
         
            -
              arcScaleType: 'area'
         
     | 
| 
       27 
     | 
    
         
            -
            }
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            export const DEFAULT_PIE_PARAMS: PieParams = {
         
     | 
| 
       30 
     | 
    
         
            -
              // padding: {
         
     | 
| 
       31 
     | 
    
         
            -
              //   top: 50,
         
     | 
| 
       32 
     | 
    
         
            -
              //   right: 70,
         
     | 
| 
       33 
     | 
    
         
            -
              //   bottom: 50,
         
     | 
| 
       34 
     | 
    
         
            -
              //   left: 70
         
     | 
| 
       35 
     | 
    
         
            -
              // },
         
     | 
| 
       36 
     | 
    
         
            -
              outerRadius: 0.85,
         
     | 
| 
       37 
     | 
    
         
            -
              innerRadius: 0,
         
     | 
| 
       38 
     | 
    
         
            -
              outerRadiusWhileHighlight: 0.9,
         
     | 
| 
       39 
     | 
    
         
            -
              // label?: LabelStyle
         
     | 
| 
       40 
     | 
    
         
            -
              // enterDuration: 800,
         
     | 
| 
       41 
     | 
    
         
            -
              startAngle: 0,
         
     | 
| 
       42 
     | 
    
         
            -
              endAngle: Math.PI * 2,
         
     | 
| 
       43 
     | 
    
         
            -
              padAngle: 0,
         
     | 
| 
       44 
     | 
    
         
            -
              strokeColorType: 'background',
         
     | 
| 
       45 
     | 
    
         
            -
              strokeWidth: 1,
         
     | 
| 
       46 
     | 
    
         
            -
              // padRadius: 100,
         
     | 
| 
       47 
     | 
    
         
            -
              cornerRadius: 0,
         
     | 
| 
       48 
     | 
    
         
            -
              // highlightTarget: 'datum',
         
     | 
| 
       49 
     | 
    
         
            -
              // highlightId: null,
         
     | 
| 
       50 
     | 
    
         
            -
              // highlightLabel: null,
         
     | 
| 
       51 
     | 
    
         
            -
            }
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
            export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
         
     | 
| 
       54 
     | 
    
         
            -
              eventFn: (eventData: EventSeries, eventName: EventName, t: number) => {
         
     | 
| 
       55 
     | 
    
         
            -
                if (eventName === 'mouseover' || eventName === 'mousemove') {
         
     | 
| 
       56 
     | 
    
         
            -
                  return [String(eventData.datum!.value)]
         
     | 
| 
       57 
     | 
    
         
            -
                }
         
     | 
| 
       58 
     | 
    
         
            -
                return [
         
     | 
| 
       59 
     | 
    
         
            -
                  String(
         
     | 
| 
       60 
     | 
    
         
            -
                    Math.round(
         
     | 
| 
       61 
     | 
    
         
            -
                      eventData.data.reduce((acc, seriesData) => {
         
     | 
| 
       62 
     | 
    
         
            -
                        return acc + seriesData.reduce((_acc, data) => {
         
     | 
| 
       63 
     | 
    
         
            -
                          return _acc + (data.value ?? 0)
         
     | 
| 
       64 
     | 
    
         
            -
                        }, 0)
         
     | 
| 
       65 
     | 
    
         
            -
                      }, 0) * t
         
     | 
| 
       66 
     | 
    
         
            -
                    )
         
     | 
| 
       67 
     | 
    
         
            -
                  )
         
     | 
| 
       68 
     | 
    
         
            -
                ]
         
     | 
| 
       69 
     | 
    
         
            -
              },
         
     | 
| 
       70 
     | 
    
         
            -
              textAttrs: [
         
     | 
| 
       71 
     | 
    
         
            -
                {
         
     | 
| 
       72 
     | 
    
         
            -
                  "transform": "translate(0, 0)"
         
     | 
| 
       73 
     | 
    
         
            -
                }
         
     | 
| 
       74 
     | 
    
         
            -
              ],
         
     | 
| 
       75 
     | 
    
         
            -
              textStyles: [
         
     | 
| 
       76 
     | 
    
         
            -
                {
         
     | 
| 
       77 
     | 
    
         
            -
                  "font-weight": "bold",
         
     | 
| 
       78 
     | 
    
         
            -
                  "text-anchor": "middle",
         
     | 
| 
       79 
     | 
    
         
            -
                  "pointer-events": "none",
         
     | 
| 
       80 
     | 
    
         
            -
                  "dominant-baseline": "middle",
         
     | 
| 
       81 
     | 
    
         
            -
                  "font-size": 64,
         
     | 
| 
       82 
     | 
    
         
            -
                  "fill": "#000"
         
     | 
| 
       83 
     | 
    
         
            -
                }
         
     | 
| 
       84 
     | 
    
         
            -
              ]
         
     | 
| 
       85 
     | 
    
         
            -
            }
         
     | 
| 
       86 
     | 
    
         
            -
            DEFAULT_PIE_EVENT_TEXTS_PARAMS.eventFn.toString = () => `(eventData: EventSeries, eventName: EventName, t: number) => {
         
     | 
| 
       87 
     | 
    
         
            -
              if (eventName === 'mouseover' || eventName === 'mousemove') {
         
     | 
| 
       88 
     | 
    
         
            -
                return [String(eventData.datum!.value)]
         
     | 
| 
       89 
     | 
    
         
            -
              }
         
     | 
| 
       90 
     | 
    
         
            -
              return [
         
     | 
| 
       91 
     | 
    
         
            -
                String(
         
     | 
| 
       92 
     | 
    
         
            -
                  Math.round(
         
     | 
| 
       93 
     | 
    
         
            -
                    eventData.data.reduce((acc, seriesData) => {
         
     | 
| 
       94 
     | 
    
         
            -
                      return acc + seriesData.reduce((_acc, data) => {
         
     | 
| 
       95 
     | 
    
         
            -
                        return _acc + (data.value ?? 0)
         
     | 
| 
       96 
     | 
    
         
            -
                      }, 0)
         
     | 
| 
       97 
     | 
    
         
            -
                    }, 0) * t
         
     | 
| 
       98 
     | 
    
         
            -
                  )
         
     | 
| 
       99 
     | 
    
         
            -
                )
         
     | 
| 
       100 
     | 
    
         
            -
              ]
         
     | 
| 
       101 
     | 
    
         
            -
            }`
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
            export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
         
     | 
| 
       104 
     | 
    
         
            -
              // solidColor: undefined,
         
     | 
| 
       105 
     | 
    
         
            -
              // colors: DEFAULT_COLORS,
         
     | 
| 
       106 
     | 
    
         
            -
              outerRadius: 0.85,
         
     | 
| 
       107 
     | 
    
         
            -
              outerRadiusWhileHighlight: 0.9,
         
     | 
| 
       108 
     | 
    
         
            -
              // innerRadius: 0,
         
     | 
| 
       109 
     | 
    
         
            -
              // enterDuration: 800,
         
     | 
| 
       110 
     | 
    
         
            -
              startAngle: 0,
         
     | 
| 
       111 
     | 
    
         
            -
              endAngle: Math.PI * 2,
         
     | 
| 
       112 
     | 
    
         
            -
              labelCentroid: 2.1,
         
     | 
| 
       113 
     | 
    
         
            -
              // fontSize: 12,
         
     | 
| 
       114 
     | 
    
         
            -
              labelColorType: 'primary',
         
     | 
| 
       115 
     | 
    
         
            -
              labelFn: d => String(d.label),
         
     | 
| 
       116 
     | 
    
         
            -
            }
         
     | 
| 
       117 
     | 
    
         
            -
            DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
            export const DEFAULT_ROSE_PARAMS: RoseParams = {
         
     | 
| 
       120 
     | 
    
         
            -
              outerRadius: 0.85,
         
     | 
| 
       121 
     | 
    
         
            -
              padAngle: 0,
         
     | 
| 
       122 
     | 
    
         
            -
              strokeColorType: 'background',
         
     | 
| 
       123 
     | 
    
         
            -
              strokeWidth: 0,
         
     | 
| 
       124 
     | 
    
         
            -
              cornerRadius: 0,
         
     | 
| 
       125 
     | 
    
         
            -
              arcScaleType: 'area',
         
     | 
| 
       126 
     | 
    
         
            -
              angleIncreaseWhileHighlight: 0.05
         
     | 
| 
       127 
     | 
    
         
            -
            }
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
            export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
         
     | 
| 
       130 
     | 
    
         
            -
              outerRadius: 0.85,
         
     | 
| 
       131 
     | 
    
         
            -
              labelCentroid: 2.1,
         
     | 
| 
       132 
     | 
    
         
            -
              labelFn: d => String(d.label),
         
     | 
| 
       133 
     | 
    
         
            -
              labelColorType: 'primary',
         
     | 
| 
       134 
     | 
    
         
            -
              arcScaleType: 'area'
         
     | 
| 
       135 
     | 
    
         
            -
            }
         
     | 
| 
       136 
     | 
    
         
            -
            DEFAULT_ROSE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
            export const DEFAULT_SERIES_LEGEND_PARAMS: SeriesLegendParams = {
         
     | 
| 
       139 
     | 
    
         
            -
              // position: 'right',
         
     | 
| 
       140 
     | 
    
         
            -
              // justify: 'end',
         
     | 
| 
       141 
     | 
    
         
            -
              placement: 'right-end',
         
     | 
| 
       142 
     | 
    
         
            -
              padding: 28,
         
     | 
| 
       143 
     | 
    
         
            -
              // offset: [0, 0],
         
     | 
| 
       144 
     | 
    
         
            -
              backgroundFill: 'none',
         
     | 
| 
       145 
     | 
    
         
            -
              backgroundStroke: 'none',
         
     | 
| 
       146 
     | 
    
         
            -
              gap: 10,
         
     | 
| 
       147 
     | 
    
         
            -
              listRectWidth: 14,
         
     | 
| 
       148 
     | 
    
         
            -
              listRectHeight: 14,
         
     | 
| 
       149 
     | 
    
         
            -
              listRectRadius: 0,
         
     | 
| 
       150 
     | 
    
         
            -
              // highlightEvent: false
         
     | 
| 
       151 
     | 
    
         
            -
              textColorType: 'primary'
         
     | 
| 
       152 
     | 
    
         
            -
            }
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
            export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
         
     | 
| 
       155 
     | 
    
         
            -
              backgroundColorType: 'background',
         
     | 
| 
       156 
     | 
    
         
            -
              strokeColorType: 'primary',
         
     | 
| 
       157 
     | 
    
         
            -
              backgroundOpacity: 0.8,
         
     | 
| 
       158 
     | 
    
         
            -
              textColorType: 'primary',
         
     | 
| 
       159 
     | 
    
         
            -
              offset: [20, 5],
         
     | 
| 
       160 
     | 
    
         
            -
              padding: 10,
         
     | 
| 
       161 
     | 
    
         
            -
              renderFn: (eventData, { styles, utils }) => {
         
     | 
| 
       162 
     | 
    
         
            -
                const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
       163 
     | 
    
         
            -
                const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
       164 
     | 
    
         
            -
                const bulletWidth = styles.textSizePx * 0.7
         
     | 
| 
       165 
     | 
    
         
            -
                const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
         
     | 
| 
       166 
     | 
    
         
            -
                const seriesSvg = hasSeriesLabel
         
     | 
| 
       167 
     | 
    
         
            -
                  ? `<rect width="${bulletWidth}" height="${bulletWidth}" x="${offset}" y="${offset - 1}" rx="${bulletWidth / 2}" fill="${eventData.datum.color}"></rect>
         
     | 
| 
       168 
     | 
    
         
            -
              <text x="${styles.textSizePx * 1.5}" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
         
     | 
| 
       169 
     | 
    
         
            -
                <tspan>${eventData.seriesLabel}</tspan>
         
     | 
| 
       170 
     | 
    
         
            -
              </text>`
         
     | 
| 
       171 
     | 
    
         
            -
                  : ''
         
     | 
| 
       172 
     | 
    
         
            -
                const datumLabelSvg = hasDatumLabel
         
     | 
| 
       173 
     | 
    
         
            -
                  ? `<tspan>${eventData.datum.label}</tspan>  `
         
     | 
| 
       174 
     | 
    
         
            -
                  : ''
         
     | 
| 
       175 
     | 
    
         
            -
                const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
         
     | 
| 
       176 
     | 
    
         
            -
                ${datumLabelSvg}<tspan font-weight="bold">${eventData.datum.value}</tspan>
         
     | 
| 
       177 
     | 
    
         
            -
              </text>`
         
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
                return `${seriesSvg}
         
     | 
| 
       180 
     | 
    
         
            -
              <g ${hasSeriesLabel ? `transform="translate(0, ${styles.textSizePx * 2})"` : ''}>
         
     | 
| 
       181 
     | 
    
         
            -
                ${datumSvg}
         
     | 
| 
       182 
     | 
    
         
            -
              </g>`
         
     | 
| 
       183 
     | 
    
         
            -
              },
         
     | 
| 
       184 
     | 
    
         
            -
            }
         
     | 
| 
       185 
     | 
    
         
            -
            DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
         
     | 
| 
       186 
     | 
    
         
            -
                const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
       187 
     | 
    
         
            -
                const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
       188 
     | 
    
         
            -
                const bulletWidth = styles.textSizePx * 0.7
         
     | 
| 
       189 
     | 
    
         
            -
                const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
         
     | 
| 
       190 
     | 
    
         
            -
                const seriesSvg = hasSeriesLabel
         
     | 
| 
       191 
     | 
    
         
            -
                  ? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
         
     | 
| 
       192 
     | 
    
         
            -
              <text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
         
     | 
| 
       193 
     | 
    
         
            -
                <tspan>\${eventData.seriesLabel}</tspan>
         
     | 
| 
       194 
     | 
    
         
            -
              </text>\`
         
     | 
| 
       195 
     | 
    
         
            -
                  : ''
         
     | 
| 
       196 
     | 
    
         
            -
                const datumLabelSvg = hasDatumLabel
         
     | 
| 
       197 
     | 
    
         
            -
                  ? \`<tspan>\${eventData.datum.label}</tspan>  \`
         
     | 
| 
       198 
     | 
    
         
            -
                  : ''
         
     | 
| 
       199 
     | 
    
         
            -
                const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
         
     | 
| 
       200 
     | 
    
         
            -
                \${datumLabelSvg}<tspan font-weight="bold">\${eventData.datum.value}</tspan>
         
     | 
| 
       201 
     | 
    
         
            -
              </text>\`
         
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                return \`\${seriesSvg}
         
     | 
| 
       204 
     | 
    
         
            -
              <g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
         
     | 
| 
       205 
     | 
    
         
            -
                \${datumSvg}
         
     | 
| 
       206 
     | 
    
         
            -
              </g>\`
         
     | 
| 
      
 1 
     | 
    
         
            +
            import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '../../lib/core-types'
         
     | 
| 
      
 2 
     | 
    
         
            +
            import type {
         
     | 
| 
      
 3 
     | 
    
         
            +
              BubblesParams,
         
     | 
| 
      
 4 
     | 
    
         
            +
              PieParams,
         
     | 
| 
      
 5 
     | 
    
         
            +
              PieEventTextsParams,
         
     | 
| 
      
 6 
     | 
    
         
            +
              PieLabelsParams,
         
     | 
| 
      
 7 
     | 
    
         
            +
              RoseParams,
         
     | 
| 
      
 8 
     | 
    
         
            +
              RoseLabelsParams,
         
     | 
| 
      
 9 
     | 
    
         
            +
              SeriesLegendParams,
         
     | 
| 
      
 10 
     | 
    
         
            +
              SeriesTooltipParams
         
     | 
| 
      
 11 
     | 
    
         
            +
            } from '../../lib/plugins-basic-types'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
            export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
         
     | 
| 
      
 15 
     | 
    
         
            +
              force: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                strength: 0.08, // 泡泡引力
         
     | 
| 
      
 17 
     | 
    
         
            +
                velocityDecay: 0.3, // 衰減數
         
     | 
| 
      
 18 
     | 
    
         
            +
                collisionSpacing: 2 // 泡泡間距
         
     | 
| 
      
 19 
     | 
    
         
            +
              },
         
     | 
| 
      
 20 
     | 
    
         
            +
              bubbleText: {
         
     | 
| 
      
 21 
     | 
    
         
            +
                fillRate: 0.6,
         
     | 
| 
      
 22 
     | 
    
         
            +
                lineHeight: 12,
         
     | 
| 
      
 23 
     | 
    
         
            +
                lineLengthMin: 4
         
     | 
| 
      
 24 
     | 
    
         
            +
              },
         
     | 
| 
      
 25 
     | 
    
         
            +
              // highlightRIncrease: 0,
         
     | 
| 
      
 26 
     | 
    
         
            +
              arcScaleType: 'area'
         
     | 
| 
      
 27 
     | 
    
         
            +
            }
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            export const DEFAULT_PIE_PARAMS: PieParams = {
         
     | 
| 
      
 30 
     | 
    
         
            +
              // padding: {
         
     | 
| 
      
 31 
     | 
    
         
            +
              //   top: 50,
         
     | 
| 
      
 32 
     | 
    
         
            +
              //   right: 70,
         
     | 
| 
      
 33 
     | 
    
         
            +
              //   bottom: 50,
         
     | 
| 
      
 34 
     | 
    
         
            +
              //   left: 70
         
     | 
| 
      
 35 
     | 
    
         
            +
              // },
         
     | 
| 
      
 36 
     | 
    
         
            +
              outerRadius: 0.85,
         
     | 
| 
      
 37 
     | 
    
         
            +
              innerRadius: 0,
         
     | 
| 
      
 38 
     | 
    
         
            +
              outerRadiusWhileHighlight: 0.9,
         
     | 
| 
      
 39 
     | 
    
         
            +
              // label?: LabelStyle
         
     | 
| 
      
 40 
     | 
    
         
            +
              // enterDuration: 800,
         
     | 
| 
      
 41 
     | 
    
         
            +
              startAngle: 0,
         
     | 
| 
      
 42 
     | 
    
         
            +
              endAngle: Math.PI * 2,
         
     | 
| 
      
 43 
     | 
    
         
            +
              padAngle: 0,
         
     | 
| 
      
 44 
     | 
    
         
            +
              strokeColorType: 'background',
         
     | 
| 
      
 45 
     | 
    
         
            +
              strokeWidth: 1,
         
     | 
| 
      
 46 
     | 
    
         
            +
              // padRadius: 100,
         
     | 
| 
      
 47 
     | 
    
         
            +
              cornerRadius: 0,
         
     | 
| 
      
 48 
     | 
    
         
            +
              // highlightTarget: 'datum',
         
     | 
| 
      
 49 
     | 
    
         
            +
              // highlightId: null,
         
     | 
| 
      
 50 
     | 
    
         
            +
              // highlightLabel: null,
         
     | 
| 
      
 51 
     | 
    
         
            +
            }
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
         
     | 
| 
      
 54 
     | 
    
         
            +
              eventFn: (eventData: EventSeries, eventName: EventName, t: number) => {
         
     | 
| 
      
 55 
     | 
    
         
            +
                if (eventName === 'mouseover' || eventName === 'mousemove') {
         
     | 
| 
      
 56 
     | 
    
         
            +
                  return [String(eventData.datum!.value)]
         
     | 
| 
      
 57 
     | 
    
         
            +
                }
         
     | 
| 
      
 58 
     | 
    
         
            +
                return [
         
     | 
| 
      
 59 
     | 
    
         
            +
                  String(
         
     | 
| 
      
 60 
     | 
    
         
            +
                    Math.round(
         
     | 
| 
      
 61 
     | 
    
         
            +
                      eventData.data.reduce((acc, seriesData) => {
         
     | 
| 
      
 62 
     | 
    
         
            +
                        return acc + seriesData.reduce((_acc, data) => {
         
     | 
| 
      
 63 
     | 
    
         
            +
                          return _acc + (data.value ?? 0)
         
     | 
| 
      
 64 
     | 
    
         
            +
                        }, 0)
         
     | 
| 
      
 65 
     | 
    
         
            +
                      }, 0) * t
         
     | 
| 
      
 66 
     | 
    
         
            +
                    )
         
     | 
| 
      
 67 
     | 
    
         
            +
                  )
         
     | 
| 
      
 68 
     | 
    
         
            +
                ]
         
     | 
| 
      
 69 
     | 
    
         
            +
              },
         
     | 
| 
      
 70 
     | 
    
         
            +
              textAttrs: [
         
     | 
| 
      
 71 
     | 
    
         
            +
                {
         
     | 
| 
      
 72 
     | 
    
         
            +
                  "transform": "translate(0, 0)"
         
     | 
| 
      
 73 
     | 
    
         
            +
                }
         
     | 
| 
      
 74 
     | 
    
         
            +
              ],
         
     | 
| 
      
 75 
     | 
    
         
            +
              textStyles: [
         
     | 
| 
      
 76 
     | 
    
         
            +
                {
         
     | 
| 
      
 77 
     | 
    
         
            +
                  "font-weight": "bold",
         
     | 
| 
      
 78 
     | 
    
         
            +
                  "text-anchor": "middle",
         
     | 
| 
      
 79 
     | 
    
         
            +
                  "pointer-events": "none",
         
     | 
| 
      
 80 
     | 
    
         
            +
                  "dominant-baseline": "middle",
         
     | 
| 
      
 81 
     | 
    
         
            +
                  "font-size": 64,
         
     | 
| 
      
 82 
     | 
    
         
            +
                  "fill": "#000"
         
     | 
| 
      
 83 
     | 
    
         
            +
                }
         
     | 
| 
      
 84 
     | 
    
         
            +
              ]
         
     | 
| 
      
 85 
     | 
    
         
            +
            }
         
     | 
| 
      
 86 
     | 
    
         
            +
            DEFAULT_PIE_EVENT_TEXTS_PARAMS.eventFn.toString = () => `(eventData: EventSeries, eventName: EventName, t: number) => {
         
     | 
| 
      
 87 
     | 
    
         
            +
              if (eventName === 'mouseover' || eventName === 'mousemove') {
         
     | 
| 
      
 88 
     | 
    
         
            +
                return [String(eventData.datum!.value)]
         
     | 
| 
      
 89 
     | 
    
         
            +
              }
         
     | 
| 
      
 90 
     | 
    
         
            +
              return [
         
     | 
| 
      
 91 
     | 
    
         
            +
                String(
         
     | 
| 
      
 92 
     | 
    
         
            +
                  Math.round(
         
     | 
| 
      
 93 
     | 
    
         
            +
                    eventData.data.reduce((acc, seriesData) => {
         
     | 
| 
      
 94 
     | 
    
         
            +
                      return acc + seriesData.reduce((_acc, data) => {
         
     | 
| 
      
 95 
     | 
    
         
            +
                        return _acc + (data.value ?? 0)
         
     | 
| 
      
 96 
     | 
    
         
            +
                      }, 0)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    }, 0) * t
         
     | 
| 
      
 98 
     | 
    
         
            +
                  )
         
     | 
| 
      
 99 
     | 
    
         
            +
                )
         
     | 
| 
      
 100 
     | 
    
         
            +
              ]
         
     | 
| 
      
 101 
     | 
    
         
            +
            }`
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
         
     | 
| 
      
 104 
     | 
    
         
            +
              // solidColor: undefined,
         
     | 
| 
      
 105 
     | 
    
         
            +
              // colors: DEFAULT_COLORS,
         
     | 
| 
      
 106 
     | 
    
         
            +
              outerRadius: 0.85,
         
     | 
| 
      
 107 
     | 
    
         
            +
              outerRadiusWhileHighlight: 0.9,
         
     | 
| 
      
 108 
     | 
    
         
            +
              // innerRadius: 0,
         
     | 
| 
      
 109 
     | 
    
         
            +
              // enterDuration: 800,
         
     | 
| 
      
 110 
     | 
    
         
            +
              startAngle: 0,
         
     | 
| 
      
 111 
     | 
    
         
            +
              endAngle: Math.PI * 2,
         
     | 
| 
      
 112 
     | 
    
         
            +
              labelCentroid: 2.1,
         
     | 
| 
      
 113 
     | 
    
         
            +
              // fontSize: 12,
         
     | 
| 
      
 114 
     | 
    
         
            +
              labelColorType: 'primary',
         
     | 
| 
      
 115 
     | 
    
         
            +
              labelFn: d => String(d.label),
         
     | 
| 
      
 116 
     | 
    
         
            +
            }
         
     | 
| 
      
 117 
     | 
    
         
            +
            DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            export const DEFAULT_ROSE_PARAMS: RoseParams = {
         
     | 
| 
      
 120 
     | 
    
         
            +
              outerRadius: 0.85,
         
     | 
| 
      
 121 
     | 
    
         
            +
              padAngle: 0,
         
     | 
| 
      
 122 
     | 
    
         
            +
              strokeColorType: 'background',
         
     | 
| 
      
 123 
     | 
    
         
            +
              strokeWidth: 0,
         
     | 
| 
      
 124 
     | 
    
         
            +
              cornerRadius: 0,
         
     | 
| 
      
 125 
     | 
    
         
            +
              arcScaleType: 'area',
         
     | 
| 
      
 126 
     | 
    
         
            +
              angleIncreaseWhileHighlight: 0.05
         
     | 
| 
      
 127 
     | 
    
         
            +
            }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
         
     | 
| 
      
 130 
     | 
    
         
            +
              outerRadius: 0.85,
         
     | 
| 
      
 131 
     | 
    
         
            +
              labelCentroid: 2.1,
         
     | 
| 
      
 132 
     | 
    
         
            +
              labelFn: d => String(d.label),
         
     | 
| 
      
 133 
     | 
    
         
            +
              labelColorType: 'primary',
         
     | 
| 
      
 134 
     | 
    
         
            +
              arcScaleType: 'area'
         
     | 
| 
      
 135 
     | 
    
         
            +
            }
         
     | 
| 
      
 136 
     | 
    
         
            +
            DEFAULT_ROSE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
            export const DEFAULT_SERIES_LEGEND_PARAMS: SeriesLegendParams = {
         
     | 
| 
      
 139 
     | 
    
         
            +
              // position: 'right',
         
     | 
| 
      
 140 
     | 
    
         
            +
              // justify: 'end',
         
     | 
| 
      
 141 
     | 
    
         
            +
              placement: 'right-end',
         
     | 
| 
      
 142 
     | 
    
         
            +
              padding: 28,
         
     | 
| 
      
 143 
     | 
    
         
            +
              // offset: [0, 0],
         
     | 
| 
      
 144 
     | 
    
         
            +
              backgroundFill: 'none',
         
     | 
| 
      
 145 
     | 
    
         
            +
              backgroundStroke: 'none',
         
     | 
| 
      
 146 
     | 
    
         
            +
              gap: 10,
         
     | 
| 
      
 147 
     | 
    
         
            +
              listRectWidth: 14,
         
     | 
| 
      
 148 
     | 
    
         
            +
              listRectHeight: 14,
         
     | 
| 
      
 149 
     | 
    
         
            +
              listRectRadius: 0,
         
     | 
| 
      
 150 
     | 
    
         
            +
              // highlightEvent: false
         
     | 
| 
      
 151 
     | 
    
         
            +
              textColorType: 'primary'
         
     | 
| 
      
 152 
     | 
    
         
            +
            }
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
            export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
         
     | 
| 
      
 155 
     | 
    
         
            +
              backgroundColorType: 'background',
         
     | 
| 
      
 156 
     | 
    
         
            +
              strokeColorType: 'primary',
         
     | 
| 
      
 157 
     | 
    
         
            +
              backgroundOpacity: 0.8,
         
     | 
| 
      
 158 
     | 
    
         
            +
              textColorType: 'primary',
         
     | 
| 
      
 159 
     | 
    
         
            +
              offset: [20, 5],
         
     | 
| 
      
 160 
     | 
    
         
            +
              padding: 10,
         
     | 
| 
      
 161 
     | 
    
         
            +
              renderFn: (eventData, { styles, utils }) => {
         
     | 
| 
      
 162 
     | 
    
         
            +
                const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
      
 163 
     | 
    
         
            +
                const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
      
 164 
     | 
    
         
            +
                const bulletWidth = styles.textSizePx * 0.7
         
     | 
| 
      
 165 
     | 
    
         
            +
                const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
         
     | 
| 
      
 166 
     | 
    
         
            +
                const seriesSvg = hasSeriesLabel
         
     | 
| 
      
 167 
     | 
    
         
            +
                  ? `<rect width="${bulletWidth}" height="${bulletWidth}" x="${offset}" y="${offset - 1}" rx="${bulletWidth / 2}" fill="${eventData.datum.color}"></rect>
         
     | 
| 
      
 168 
     | 
    
         
            +
              <text x="${styles.textSizePx * 1.5}" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
         
     | 
| 
      
 169 
     | 
    
         
            +
                <tspan>${eventData.seriesLabel}</tspan>
         
     | 
| 
      
 170 
     | 
    
         
            +
              </text>`
         
     | 
| 
      
 171 
     | 
    
         
            +
                  : ''
         
     | 
| 
      
 172 
     | 
    
         
            +
                const datumLabelSvg = hasDatumLabel
         
     | 
| 
      
 173 
     | 
    
         
            +
                  ? `<tspan>${eventData.datum.label}</tspan>  `
         
     | 
| 
      
 174 
     | 
    
         
            +
                  : ''
         
     | 
| 
      
 175 
     | 
    
         
            +
                const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
         
     | 
| 
      
 176 
     | 
    
         
            +
                ${datumLabelSvg}<tspan font-weight="bold">${eventData.datum.value}</tspan>
         
     | 
| 
      
 177 
     | 
    
         
            +
              </text>`
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                return `${seriesSvg}
         
     | 
| 
      
 180 
     | 
    
         
            +
              <g ${hasSeriesLabel ? `transform="translate(0, ${styles.textSizePx * 2})"` : ''}>
         
     | 
| 
      
 181 
     | 
    
         
            +
                ${datumSvg}
         
     | 
| 
      
 182 
     | 
    
         
            +
              </g>`
         
     | 
| 
      
 183 
     | 
    
         
            +
              },
         
     | 
| 
      
 184 
     | 
    
         
            +
            }
         
     | 
| 
      
 185 
     | 
    
         
            +
            DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
         
     | 
| 
      
 186 
     | 
    
         
            +
                const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
      
 187 
     | 
    
         
            +
                const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
         
     | 
| 
      
 188 
     | 
    
         
            +
                const bulletWidth = styles.textSizePx * 0.7
         
     | 
| 
      
 189 
     | 
    
         
            +
                const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
         
     | 
| 
      
 190 
     | 
    
         
            +
                const seriesSvg = hasSeriesLabel
         
     | 
| 
      
 191 
     | 
    
         
            +
                  ? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
         
     | 
| 
      
 192 
     | 
    
         
            +
              <text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
         
     | 
| 
      
 193 
     | 
    
         
            +
                <tspan>\${eventData.seriesLabel}</tspan>
         
     | 
| 
      
 194 
     | 
    
         
            +
              </text>\`
         
     | 
| 
      
 195 
     | 
    
         
            +
                  : ''
         
     | 
| 
      
 196 
     | 
    
         
            +
                const datumLabelSvg = hasDatumLabel
         
     | 
| 
      
 197 
     | 
    
         
            +
                  ? \`<tspan>\${eventData.datum.label}</tspan>  \`
         
     | 
| 
      
 198 
     | 
    
         
            +
                  : ''
         
     | 
| 
      
 199 
     | 
    
         
            +
                const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
         
     | 
| 
      
 200 
     | 
    
         
            +
                \${datumLabelSvg}<tspan font-weight="bold">\${eventData.datum.value}</tspan>
         
     | 
| 
      
 201 
     | 
    
         
            +
              </text>\`
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                return \`\${seriesSvg}
         
     | 
| 
      
 204 
     | 
    
         
            +
              <g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
         
     | 
| 
      
 205 
     | 
    
         
            +
                \${datumSvg}
         
     | 
| 
      
 206 
     | 
    
         
            +
              </g>\`
         
     | 
| 
       207 
207 
     | 
    
         
             
            }`
         
     | 
    
        package/src/series/index.ts
    CHANGED
    
    | 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            export * from './defaults'
         
     | 
| 
       2 
     | 
    
         
            -
            // export * from './types'
         
     | 
| 
       3 
     | 
    
         
            -
            export { Bubbles } from './plugins/Bubbles'
         
     | 
| 
       4 
     | 
    
         
            -
            export { Pie } from './plugins/Pie'
         
     | 
| 
       5 
     | 
    
         
            -
            export { PieEventTexts } from './plugins/PieEventTexts'
         
     | 
| 
       6 
     | 
    
         
            -
            export { PieLabels } from './plugins/PieLabels'
         
     | 
| 
       7 
     | 
    
         
            -
            export { Rose } from './plugins/Rose'
         
     | 
| 
       8 
     | 
    
         
            -
            export { RoseLabels } from './plugins/RoseLabels'
         
     | 
| 
       9 
     | 
    
         
            -
            export { SeriesLegend } from './plugins/SeriesLegend'
         
     | 
| 
      
 1 
     | 
    
         
            +
            export * from './defaults'
         
     | 
| 
      
 2 
     | 
    
         
            +
            // export * from './types'
         
     | 
| 
      
 3 
     | 
    
         
            +
            export { Bubbles } from './plugins/Bubbles'
         
     | 
| 
      
 4 
     | 
    
         
            +
            export { Pie } from './plugins/Pie'
         
     | 
| 
      
 5 
     | 
    
         
            +
            export { PieEventTexts } from './plugins/PieEventTexts'
         
     | 
| 
      
 6 
     | 
    
         
            +
            export { PieLabels } from './plugins/PieLabels'
         
     | 
| 
      
 7 
     | 
    
         
            +
            export { Rose } from './plugins/Rose'
         
     | 
| 
      
 8 
     | 
    
         
            +
            export { RoseLabels } from './plugins/RoseLabels'
         
     | 
| 
      
 9 
     | 
    
         
            +
            export { SeriesLegend } from './plugins/SeriesLegend'
         
     | 
| 
       10 
10 
     | 
    
         
             
            export { SeriesTooltip } from './plugins/SeriesTooltip'
         
     |