@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
 
| 
         @@ -1,283 +1,283 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import * as d3 from 'd3'
         
     | 
| 
       2 
     | 
    
         
            -
            import {
         
     | 
| 
       3 
     | 
    
         
            -
              combineLatest,
         
     | 
| 
       4 
     | 
    
         
            -
              switchMap,
         
     | 
| 
       5 
     | 
    
         
            -
              first,
         
     | 
| 
       6 
     | 
    
         
            -
              takeUntil,
         
     | 
| 
       7 
     | 
    
         
            -
              map,
         
     | 
| 
       8 
     | 
    
         
            -
              distinctUntilChanged,
         
     | 
| 
       9 
     | 
    
         
            -
              Observable,
         
     | 
| 
       10 
     | 
    
         
            -
              Subject } from 'rxjs'
         
     | 
| 
       11 
     | 
    
         
            -
            import type { DefinePluginConfig } from '../../../lib/core-types'
         
     | 
| 
       12 
     | 
    
         
            -
            import type { Subscription } from 'rxjs'
         
     | 
| 
       13 
     | 
    
         
            -
            import {
         
     | 
| 
       14 
     | 
    
         
            -
              defineSeriesPlugin} from '../../../lib/core'
         
     | 
| 
       15 
     | 
    
         
            -
            import type {
         
     | 
| 
       16 
     | 
    
         
            -
              ComputedDatumSeries,
         
     | 
| 
       17 
     | 
    
         
            -
              ChartParams,
         
     | 
| 
       18 
     | 
    
         
            -
              SeriesContainerPosition,
         
     | 
| 
       19 
     | 
    
         
            -
              EventName,
         
     | 
| 
       20 
     | 
    
         
            -
              EventSeries } from '../../../lib/core-types'
         
     | 
| 
       21 
     | 
    
         
            -
            import type { PieEventTextsParams } from '../../../lib/plugins-basic-types'
         
     | 
| 
       22 
     | 
    
         
            -
            import { DEFAULT_PIE_EVENT_TEXTS_PARAMS } from '../defaults'
         
     | 
| 
       23 
     | 
    
         
            -
            import { getD3TransitionEase } from '../../utils/d3Utils'
         
     | 
| 
       24 
     | 
    
         
            -
            import { getClassName } from '../../utils/orbchartsUtils'
         
     | 
| 
       25 
     | 
    
         
            -
            import { seriesCenterSelectionObservable } from '../seriesObservables'
         
     | 
| 
       26 
     | 
    
         
            -
            import { LAYER_INDEX_OF_LABEL } from '../../const'
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            type TextDatum = {
         
     | 
| 
       29 
     | 
    
         
            -
              text: string
         
     | 
| 
       30 
     | 
    
         
            -
              attr: { [key:string]: any }
         
     | 
| 
       31 
     | 
    
         
            -
              style: { [key:string]: any }
         
     | 
| 
       32 
     | 
    
         
            -
            }
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            const pluginName = 'PieEventTexts'
         
     | 
| 
       35 
     | 
    
         
            -
            const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
            const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_EVENT_TEXTS_PARAMS> = {
         
     | 
| 
       38 
     | 
    
         
            -
              name: pluginName,
         
     | 
| 
       39 
     | 
    
         
            -
              defaultParams: DEFAULT_PIE_EVENT_TEXTS_PARAMS,
         
     | 
| 
       40 
     | 
    
         
            -
              layerIndex: LAYER_INDEX_OF_LABEL,
         
     | 
| 
       41 
     | 
    
         
            -
              validator: (params, { validateColumns }) => {
         
     | 
| 
       42 
     | 
    
         
            -
                const result = validateColumns(params, {
         
     | 
| 
       43 
     | 
    
         
            -
                  eventFn: {
         
     | 
| 
       44 
     | 
    
         
            -
                    toBeTypes: ['Function'],
         
     | 
| 
       45 
     | 
    
         
            -
                  },
         
     | 
| 
       46 
     | 
    
         
            -
                  textAttrs: {
         
     | 
| 
       47 
     | 
    
         
            -
                    toBeTypes: ['object[]'],
         
     | 
| 
       48 
     | 
    
         
            -
                  },
         
     | 
| 
       49 
     | 
    
         
            -
                  textStyles: {
         
     | 
| 
       50 
     | 
    
         
            -
                    toBeTypes: ['object[]'],
         
     | 
| 
       51 
     | 
    
         
            -
                  }
         
     | 
| 
       52 
     | 
    
         
            -
                })
         
     | 
| 
       53 
     | 
    
         
            -
                return result
         
     | 
| 
       54 
     | 
    
         
            -
              }
         
     | 
| 
       55 
     | 
    
         
            -
            }
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
            function renderText (
         
     | 
| 
       58 
     | 
    
         
            -
              selection: d3.Selection<SVGGElement, unknown, any, any>,
         
     | 
| 
       59 
     | 
    
         
            -
              data: Array<TextDatum>
         
     | 
| 
       60 
     | 
    
         
            -
            ): d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> {
         
     | 
| 
       61 
     | 
    
         
            -
              const textUpdate = selection
         
     | 
| 
       62 
     | 
    
         
            -
                .selectAll<SVGTextElement, TextDatum>(`text.${textClassName}`)
         
     | 
| 
       63 
     | 
    
         
            -
                .data(data)
         
     | 
| 
       64 
     | 
    
         
            -
              const textEnter = textUpdate.enter()
         
     | 
| 
       65 
     | 
    
         
            -
                .append('text')
         
     | 
| 
       66 
     | 
    
         
            -
                .classed(textClassName, true)
         
     | 
| 
       67 
     | 
    
         
            -
              const text = textUpdate.merge(textEnter)
         
     | 
| 
       68 
     | 
    
         
            -
              text
         
     | 
| 
       69 
     | 
    
         
            -
                .each((d, i, g) => {
         
     | 
| 
       70 
     | 
    
         
            -
                  const t = d3.select(g[i])
         
     | 
| 
       71 
     | 
    
         
            -
                    .text(d.text)
         
     | 
| 
       72 
     | 
    
         
            -
                  Object.keys(d.attr)
         
     | 
| 
       73 
     | 
    
         
            -
                    .forEach(key => {
         
     | 
| 
       74 
     | 
    
         
            -
                      t.attr(key, d.attr[key])
         
     | 
| 
       75 
     | 
    
         
            -
                    })
         
     | 
| 
       76 
     | 
    
         
            -
                  Object.keys(d.style)
         
     | 
| 
       77 
     | 
    
         
            -
                    .forEach(key => {
         
     | 
| 
       78 
     | 
    
         
            -
                      t.style(key, d.style[key])
         
     | 
| 
       79 
     | 
    
         
            -
                    })
         
     | 
| 
       80 
     | 
    
         
            -
                })
         
     | 
| 
       81 
     | 
    
         
            -
                
         
     | 
| 
       82 
     | 
    
         
            -
              textUpdate.exit().remove()
         
     | 
| 
       83 
     | 
    
         
            -
              
         
     | 
| 
       84 
     | 
    
         
            -
              return text
         
     | 
| 
       85 
     | 
    
         
            -
            }
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
            function makeTextData ({ eventData, eventName, t, eventFn, textAttrs, textStyles }: {
         
     | 
| 
       88 
     | 
    
         
            -
              eventData: EventSeries,
         
     | 
| 
       89 
     | 
    
         
            -
              eventName: EventName,
         
     | 
| 
       90 
     | 
    
         
            -
              t: number,
         
     | 
| 
       91 
     | 
    
         
            -
              eventFn: (d: EventSeries, eventName: EventName, t: number) => string[]
         
     | 
| 
       92 
     | 
    
         
            -
              textAttrs: Array<{ [key:string]: string | number }>
         
     | 
| 
       93 
     | 
    
         
            -
              textStyles: Array<{ [key:string]: string | number }>
         
     | 
| 
       94 
     | 
    
         
            -
            }): TextDatum[] {
         
     | 
| 
       95 
     | 
    
         
            -
              const callbackText = eventFn(eventData, eventName, t)
         
     | 
| 
       96 
     | 
    
         
            -
              return callbackText.map((d, i) => {
         
     | 
| 
       97 
     | 
    
         
            -
                return {
         
     | 
| 
       98 
     | 
    
         
            -
                  text: d,
         
     | 
| 
       99 
     | 
    
         
            -
                  attr: textAttrs[i],
         
     | 
| 
       100 
     | 
    
         
            -
                  style: textStyles[i]
         
     | 
| 
       101 
     | 
    
         
            -
                }
         
     | 
| 
       102 
     | 
    
         
            -
              })
         
     | 
| 
       103 
     | 
    
         
            -
            }
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
            function createEachPieEventTexts (pluginName: string, context: {
         
     | 
| 
       106 
     | 
    
         
            -
              containerSelection: d3.Selection<SVGGElement, any, any, unknown>
         
     | 
| 
       107 
     | 
    
         
            -
              computedData$: Observable<ComputedDatumSeries[][]>
         
     | 
| 
       108 
     | 
    
         
            -
              containerComputedLayoutData$: Observable<ComputedDatumSeries[]>
         
     | 
| 
       109 
     | 
    
         
            -
              SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
         
     | 
| 
       110 
     | 
    
         
            -
              fullParams$: Observable<PieEventTextsParams>
         
     | 
| 
       111 
     | 
    
         
            -
              fullChartParams$: Observable<ChartParams>
         
     | 
| 
       112 
     | 
    
         
            -
              seriesHighlight$: Observable<ComputedDatumSeries[]>
         
     | 
| 
       113 
     | 
    
         
            -
              seriesContainerPosition$: Observable<SeriesContainerPosition>
         
     | 
| 
       114 
     | 
    
         
            -
              event$: Subject<EventSeries>
         
     | 
| 
       115 
     | 
    
         
            -
            }) {
         
     | 
| 
       116 
     | 
    
         
            -
              const destroy$ = new Subject()
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
              // const graphicSelection: d3.Selection<SVGGElement, any, any, any> = selection.append('g')
         
     | 
| 
       119 
     | 
    
         
            -
              let centerTextSelection: d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> | undefined
         
     | 
| 
       120 
     | 
    
         
            -
              let storeEventSubscription: Subscription | undefined
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
              // context.layout$
         
     | 
| 
       123 
     | 
    
         
            -
              //   .pipe(
         
     | 
| 
       124 
     | 
    
         
            -
              //     first()
         
     | 
| 
       125 
     | 
    
         
            -
              //   )
         
     | 
| 
       126 
     | 
    
         
            -
              //   .subscribe(size => {
         
     | 
| 
       127 
     | 
    
         
            -
              //     selection
         
     | 
| 
       128 
     | 
    
         
            -
              //       .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
         
     | 
| 
       129 
     | 
    
         
            -
              //     context.layout$
         
     | 
| 
       130 
     | 
    
         
            -
              //       .pipe(
         
     | 
| 
       131 
     | 
    
         
            -
              //         takeUntil(destroy$)
         
     | 
| 
       132 
     | 
    
         
            -
              //       )
         
     | 
| 
       133 
     | 
    
         
            -
              //       .subscribe(size => {
         
     | 
| 
       134 
     | 
    
         
            -
              //         selection
         
     | 
| 
       135 
     | 
    
         
            -
              //           .transition()
         
     | 
| 
       136 
     | 
    
         
            -
              //           .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
         
     | 
| 
       137 
     | 
    
         
            -
              //       })
         
     | 
| 
       138 
     | 
    
         
            -
              //   })
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
              const highlightTarget$ = context.fullChartParams$.pipe(
         
     | 
| 
       141 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       142 
     | 
    
         
            -
                map(d => d.highlightTarget),
         
     | 
| 
       143 
     | 
    
         
            -
                distinctUntilChanged()
         
     | 
| 
       144 
     | 
    
         
            -
              )
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
              combineLatest({
         
     | 
| 
       147 
     | 
    
         
            -
                computedData: context.computedData$,
         
     | 
| 
       148 
     | 
    
         
            -
                fullParams: context.fullParams$,
         
     | 
| 
       149 
     | 
    
         
            -
                fullChartParams: context.fullChartParams$,
         
     | 
| 
       150 
     | 
    
         
            -
                highlightTarget: highlightTarget$,
         
     | 
| 
       151 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       152 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       153 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       154 
     | 
    
         
            -
              ).subscribe(data => {
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
                context.containerSelection
         
     | 
| 
       157 
     | 
    
         
            -
                  .transition('move')
         
     | 
| 
       158 
     | 
    
         
            -
                  .duration(data.fullChartParams.transitionDuration!)
         
     | 
| 
       159 
     | 
    
         
            -
                  // .ease(getD3TransitionEase(data.fullChartParams.transitionEase!))
         
     | 
| 
       160 
     | 
    
         
            -
                  .tween('move', (event, datum) => {
         
     | 
| 
       161 
     | 
    
         
            -
                    return (t) => {
         
     | 
| 
       162 
     | 
    
         
            -
                      const renderData = makeTextData({
         
     | 
| 
       163 
     | 
    
         
            -
                        eventData: {
         
     | 
| 
       164 
     | 
    
         
            -
                          type: 'series',
         
     | 
| 
       165 
     | 
    
         
            -
                          pluginName,
         
     | 
| 
       166 
     | 
    
         
            -
                          eventName: 'transitionMove',
         
     | 
| 
       167 
     | 
    
         
            -
                          event,
         
     | 
| 
       168 
     | 
    
         
            -
                          highlightTarget: data.highlightTarget,
         
     | 
| 
       169 
     | 
    
         
            -
                          data: data.computedData,
         
     | 
| 
       170 
     | 
    
         
            -
                          series: [],
         
     | 
| 
       171 
     | 
    
         
            -
                          seriesIndex: -1,
         
     | 
| 
       172 
     | 
    
         
            -
                          seriesLabel: '',
         
     | 
| 
       173 
     | 
    
         
            -
                          datum: null
         
     | 
| 
       174 
     | 
    
         
            -
                        },
         
     | 
| 
       175 
     | 
    
         
            -
                        eventName: 'transitionMove',
         
     | 
| 
       176 
     | 
    
         
            -
                        t,
         
     | 
| 
       177 
     | 
    
         
            -
                        eventFn: data.fullParams.eventFn!,
         
     | 
| 
       178 
     | 
    
         
            -
                        textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
       179 
     | 
    
         
            -
                        textStyles: data.fullParams.textStyles!
         
     | 
| 
       180 
     | 
    
         
            -
                      })
         
     | 
| 
       181 
     | 
    
         
            -
                      centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
       182 
     | 
    
         
            -
                    }
         
     | 
| 
       183 
     | 
    
         
            -
                  })
         
     | 
| 
       184 
     | 
    
         
            -
                  .on('end', (event, datum) => {
         
     | 
| 
       185 
     | 
    
         
            -
                    const renderData = makeTextData({
         
     | 
| 
       186 
     | 
    
         
            -
                      eventData: {
         
     | 
| 
       187 
     | 
    
         
            -
                        type: 'series',
         
     | 
| 
       188 
     | 
    
         
            -
                        pluginName,
         
     | 
| 
       189 
     | 
    
         
            -
                        eventName: 'transitionEnd',
         
     | 
| 
       190 
     | 
    
         
            -
                        event,
         
     | 
| 
       191 
     | 
    
         
            -
                        highlightTarget: data.highlightTarget,
         
     | 
| 
       192 
     | 
    
         
            -
                        data: data.computedData,
         
     | 
| 
       193 
     | 
    
         
            -
                        series: [],
         
     | 
| 
       194 
     | 
    
         
            -
                        seriesIndex: -1,
         
     | 
| 
       195 
     | 
    
         
            -
                        seriesLabel: '',
         
     | 
| 
       196 
     | 
    
         
            -
                        datum: null
         
     | 
| 
       197 
     | 
    
         
            -
                      },
         
     | 
| 
       198 
     | 
    
         
            -
                      eventName: 'transitionMove',
         
     | 
| 
       199 
     | 
    
         
            -
                      t: 1,
         
     | 
| 
       200 
     | 
    
         
            -
                      eventFn: data.fullParams.eventFn!,
         
     | 
| 
       201 
     | 
    
         
            -
                      textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
       202 
     | 
    
         
            -
                      textStyles: data.fullParams.textStyles!
         
     | 
| 
       203 
     | 
    
         
            -
                    })
         
     | 
| 
       204 
     | 
    
         
            -
                    centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                    if (storeEventSubscription) {
         
     | 
| 
       207 
     | 
    
         
            -
                      storeEventSubscription.unsubscribe()
         
     | 
| 
       208 
     | 
    
         
            -
                    }
         
     | 
| 
       209 
     | 
    
         
            -
                    storeEventSubscription = context.event$
         
     | 
| 
       210 
     | 
    
         
            -
                      .subscribe(eventData => {
         
     | 
| 
       211 
     | 
    
         
            -
                        const renderData = makeTextData({
         
     | 
| 
       212 
     | 
    
         
            -
                          eventData,
         
     | 
| 
       213 
     | 
    
         
            -
                          eventName: eventData.eventName,
         
     | 
| 
       214 
     | 
    
         
            -
                          t: 1,
         
     | 
| 
       215 
     | 
    
         
            -
                          eventFn: data.fullParams.eventFn!,
         
     | 
| 
       216 
     | 
    
         
            -
                          textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
       217 
     | 
    
         
            -
                          textStyles: data.fullParams.textStyles!
         
     | 
| 
       218 
     | 
    
         
            -
                        })
         
     | 
| 
       219 
     | 
    
         
            -
                        centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
       220 
     | 
    
         
            -
                      })
         
     | 
| 
       221 
     | 
    
         
            -
                  })
         
     | 
| 
       222 
     | 
    
         
            -
              })
         
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
              return () => {
         
     | 
| 
       225 
     | 
    
         
            -
                destroy$.next(undefined)
         
     | 
| 
       226 
     | 
    
         
            -
              }
         
     | 
| 
       227 
     | 
    
         
            -
            }
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
            export const PieEventTexts = defineSeriesPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
         
     | 
| 
       230 
     | 
    
         
            -
              const destroy$ = new Subject()
         
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
       232 
     | 
    
         
            -
              const { seriesCenterSelection$ } = seriesCenterSelectionObservable({
         
     | 
| 
       233 
     | 
    
         
            -
                selection: selection,
         
     | 
| 
       234 
     | 
    
         
            -
                pluginName,
         
     | 
| 
       235 
     | 
    
         
            -
                separateSeries$: observer.separateSeries$,
         
     | 
| 
       236 
     | 
    
         
            -
                seriesLabels$: observer.seriesLabels$,
         
     | 
| 
       237 
     | 
    
         
            -
                seriesContainerPosition$: observer.seriesContainerPosition$
         
     | 
| 
       238 
     | 
    
         
            -
              })
         
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
              const unsubscribeFnArr: (() => void)[] = []
         
     | 
| 
       241 
     | 
    
         
            -
             
     | 
| 
       242 
     | 
    
         
            -
              seriesCenterSelection$
         
     | 
| 
       243 
     | 
    
         
            -
                .pipe(
         
     | 
| 
       244 
     | 
    
         
            -
                  takeUntil(destroy$)
         
     | 
| 
       245 
     | 
    
         
            -
                )
         
     | 
| 
       246 
     | 
    
         
            -
                .subscribe(seriesCenterSelection => {
         
     | 
| 
       247 
     | 
    
         
            -
                  // 每次重新計算時,清除之前的訂閱
         
     | 
| 
       248 
     | 
    
         
            -
                  unsubscribeFnArr.forEach(fn => fn())
         
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
                  seriesCenterSelection.each((d, containerIndex, g) => { 
         
     | 
| 
       251 
     | 
    
         
            -
                    
         
     | 
| 
       252 
     | 
    
         
            -
                    const containerSelection = d3.select(g[containerIndex])
         
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
                    const containerComputedLayoutData$ = observer.computedLayoutData$.pipe(
         
     | 
| 
       255 
     | 
    
         
            -
                      takeUntil(destroy$),
         
     | 
| 
       256 
     | 
    
         
            -
                      map(data => data[containerIndex] ?? data[0])
         
     | 
| 
       257 
     | 
    
         
            -
                    )
         
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
                    const containerPosition$ = observer.seriesContainerPosition$.pipe(
         
     | 
| 
       260 
     | 
    
         
            -
                      takeUntil(destroy$),
         
     | 
| 
       261 
     | 
    
         
            -
                      map(data => data[containerIndex] ?? data[0])
         
     | 
| 
       262 
     | 
    
         
            -
                    )
         
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
                    unsubscribeFnArr[containerIndex] = createEachPieEventTexts(pluginName, {
         
     | 
| 
       265 
     | 
    
         
            -
                      containerSelection: containerSelection,
         
     | 
| 
       266 
     | 
    
         
            -
                      computedData$: observer.computedData$,
         
     | 
| 
       267 
     | 
    
         
            -
                      containerComputedLayoutData$: containerComputedLayoutData$,
         
     | 
| 
       268 
     | 
    
         
            -
                      SeriesDataMap$: observer.SeriesDataMap$,
         
     | 
| 
       269 
     | 
    
         
            -
                      fullParams$: observer.fullParams$,
         
     | 
| 
       270 
     | 
    
         
            -
                      fullChartParams$: observer.fullChartParams$,
         
     | 
| 
       271 
     | 
    
         
            -
                      seriesHighlight$: observer.seriesHighlight$,
         
     | 
| 
       272 
     | 
    
         
            -
                      seriesContainerPosition$: containerPosition$,
         
     | 
| 
       273 
     | 
    
         
            -
                      event$: subject.event$,
         
     | 
| 
       274 
     | 
    
         
            -
                    })
         
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
                  })
         
     | 
| 
       277 
     | 
    
         
            -
                })
         
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
              return () => {
         
     | 
| 
       280 
     | 
    
         
            -
                destroy$.next(undefined)
         
     | 
| 
       281 
     | 
    
         
            -
                unsubscribeFnArr.forEach(fn => fn())
         
     | 
| 
       282 
     | 
    
         
            -
              }
         
     | 
| 
       283 
     | 
    
         
            -
            })
         
     | 
| 
      
 1 
     | 
    
         
            +
            import * as d3 from 'd3'
         
     | 
| 
      
 2 
     | 
    
         
            +
            import {
         
     | 
| 
      
 3 
     | 
    
         
            +
              combineLatest,
         
     | 
| 
      
 4 
     | 
    
         
            +
              switchMap,
         
     | 
| 
      
 5 
     | 
    
         
            +
              first,
         
     | 
| 
      
 6 
     | 
    
         
            +
              takeUntil,
         
     | 
| 
      
 7 
     | 
    
         
            +
              map,
         
     | 
| 
      
 8 
     | 
    
         
            +
              distinctUntilChanged,
         
     | 
| 
      
 9 
     | 
    
         
            +
              Observable,
         
     | 
| 
      
 10 
     | 
    
         
            +
              Subject } from 'rxjs'
         
     | 
| 
      
 11 
     | 
    
         
            +
            import type { DefinePluginConfig } from '../../../lib/core-types'
         
     | 
| 
      
 12 
     | 
    
         
            +
            import type { Subscription } from 'rxjs'
         
     | 
| 
      
 13 
     | 
    
         
            +
            import {
         
     | 
| 
      
 14 
     | 
    
         
            +
              defineSeriesPlugin} from '../../../lib/core'
         
     | 
| 
      
 15 
     | 
    
         
            +
            import type {
         
     | 
| 
      
 16 
     | 
    
         
            +
              ComputedDatumSeries,
         
     | 
| 
      
 17 
     | 
    
         
            +
              ChartParams,
         
     | 
| 
      
 18 
     | 
    
         
            +
              SeriesContainerPosition,
         
     | 
| 
      
 19 
     | 
    
         
            +
              EventName,
         
     | 
| 
      
 20 
     | 
    
         
            +
              EventSeries } from '../../../lib/core-types'
         
     | 
| 
      
 21 
     | 
    
         
            +
            import type { PieEventTextsParams } from '../../../lib/plugins-basic-types'
         
     | 
| 
      
 22 
     | 
    
         
            +
            import { DEFAULT_PIE_EVENT_TEXTS_PARAMS } from '../defaults'
         
     | 
| 
      
 23 
     | 
    
         
            +
            import { getD3TransitionEase } from '../../utils/d3Utils'
         
     | 
| 
      
 24 
     | 
    
         
            +
            import { getClassName } from '../../utils/orbchartsUtils'
         
     | 
| 
      
 25 
     | 
    
         
            +
            import { seriesCenterSelectionObservable } from '../seriesObservables'
         
     | 
| 
      
 26 
     | 
    
         
            +
            import { LAYER_INDEX_OF_LABEL } from '../../const'
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            type TextDatum = {
         
     | 
| 
      
 29 
     | 
    
         
            +
              text: string
         
     | 
| 
      
 30 
     | 
    
         
            +
              attr: { [key:string]: any }
         
     | 
| 
      
 31 
     | 
    
         
            +
              style: { [key:string]: any }
         
     | 
| 
      
 32 
     | 
    
         
            +
            }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            const pluginName = 'PieEventTexts'
         
     | 
| 
      
 35 
     | 
    
         
            +
            const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_EVENT_TEXTS_PARAMS> = {
         
     | 
| 
      
 38 
     | 
    
         
            +
              name: pluginName,
         
     | 
| 
      
 39 
     | 
    
         
            +
              defaultParams: DEFAULT_PIE_EVENT_TEXTS_PARAMS,
         
     | 
| 
      
 40 
     | 
    
         
            +
              layerIndex: LAYER_INDEX_OF_LABEL,
         
     | 
| 
      
 41 
     | 
    
         
            +
              validator: (params, { validateColumns }) => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                const result = validateColumns(params, {
         
     | 
| 
      
 43 
     | 
    
         
            +
                  eventFn: {
         
     | 
| 
      
 44 
     | 
    
         
            +
                    toBeTypes: ['Function'],
         
     | 
| 
      
 45 
     | 
    
         
            +
                  },
         
     | 
| 
      
 46 
     | 
    
         
            +
                  textAttrs: {
         
     | 
| 
      
 47 
     | 
    
         
            +
                    toBeTypes: ['object[]'],
         
     | 
| 
      
 48 
     | 
    
         
            +
                  },
         
     | 
| 
      
 49 
     | 
    
         
            +
                  textStyles: {
         
     | 
| 
      
 50 
     | 
    
         
            +
                    toBeTypes: ['object[]'],
         
     | 
| 
      
 51 
     | 
    
         
            +
                  }
         
     | 
| 
      
 52 
     | 
    
         
            +
                })
         
     | 
| 
      
 53 
     | 
    
         
            +
                return result
         
     | 
| 
      
 54 
     | 
    
         
            +
              }
         
     | 
| 
      
 55 
     | 
    
         
            +
            }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            function renderText (
         
     | 
| 
      
 58 
     | 
    
         
            +
              selection: d3.Selection<SVGGElement, unknown, any, any>,
         
     | 
| 
      
 59 
     | 
    
         
            +
              data: Array<TextDatum>
         
     | 
| 
      
 60 
     | 
    
         
            +
            ): d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> {
         
     | 
| 
      
 61 
     | 
    
         
            +
              const textUpdate = selection
         
     | 
| 
      
 62 
     | 
    
         
            +
                .selectAll<SVGTextElement, TextDatum>(`text.${textClassName}`)
         
     | 
| 
      
 63 
     | 
    
         
            +
                .data(data)
         
     | 
| 
      
 64 
     | 
    
         
            +
              const textEnter = textUpdate.enter()
         
     | 
| 
      
 65 
     | 
    
         
            +
                .append('text')
         
     | 
| 
      
 66 
     | 
    
         
            +
                .classed(textClassName, true)
         
     | 
| 
      
 67 
     | 
    
         
            +
              const text = textUpdate.merge(textEnter)
         
     | 
| 
      
 68 
     | 
    
         
            +
              text
         
     | 
| 
      
 69 
     | 
    
         
            +
                .each((d, i, g) => {
         
     | 
| 
      
 70 
     | 
    
         
            +
                  const t = d3.select(g[i])
         
     | 
| 
      
 71 
     | 
    
         
            +
                    .text(d.text)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  Object.keys(d.attr)
         
     | 
| 
      
 73 
     | 
    
         
            +
                    .forEach(key => {
         
     | 
| 
      
 74 
     | 
    
         
            +
                      t.attr(key, d.attr[key])
         
     | 
| 
      
 75 
     | 
    
         
            +
                    })
         
     | 
| 
      
 76 
     | 
    
         
            +
                  Object.keys(d.style)
         
     | 
| 
      
 77 
     | 
    
         
            +
                    .forEach(key => {
         
     | 
| 
      
 78 
     | 
    
         
            +
                      t.style(key, d.style[key])
         
     | 
| 
      
 79 
     | 
    
         
            +
                    })
         
     | 
| 
      
 80 
     | 
    
         
            +
                })
         
     | 
| 
      
 81 
     | 
    
         
            +
                
         
     | 
| 
      
 82 
     | 
    
         
            +
              textUpdate.exit().remove()
         
     | 
| 
      
 83 
     | 
    
         
            +
              
         
     | 
| 
      
 84 
     | 
    
         
            +
              return text
         
     | 
| 
      
 85 
     | 
    
         
            +
            }
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            function makeTextData ({ eventData, eventName, t, eventFn, textAttrs, textStyles }: {
         
     | 
| 
      
 88 
     | 
    
         
            +
              eventData: EventSeries,
         
     | 
| 
      
 89 
     | 
    
         
            +
              eventName: EventName,
         
     | 
| 
      
 90 
     | 
    
         
            +
              t: number,
         
     | 
| 
      
 91 
     | 
    
         
            +
              eventFn: (d: EventSeries, eventName: EventName, t: number) => string[]
         
     | 
| 
      
 92 
     | 
    
         
            +
              textAttrs: Array<{ [key:string]: string | number }>
         
     | 
| 
      
 93 
     | 
    
         
            +
              textStyles: Array<{ [key:string]: string | number }>
         
     | 
| 
      
 94 
     | 
    
         
            +
            }): TextDatum[] {
         
     | 
| 
      
 95 
     | 
    
         
            +
              const callbackText = eventFn(eventData, eventName, t)
         
     | 
| 
      
 96 
     | 
    
         
            +
              return callbackText.map((d, i) => {
         
     | 
| 
      
 97 
     | 
    
         
            +
                return {
         
     | 
| 
      
 98 
     | 
    
         
            +
                  text: d,
         
     | 
| 
      
 99 
     | 
    
         
            +
                  attr: textAttrs[i],
         
     | 
| 
      
 100 
     | 
    
         
            +
                  style: textStyles[i]
         
     | 
| 
      
 101 
     | 
    
         
            +
                }
         
     | 
| 
      
 102 
     | 
    
         
            +
              })
         
     | 
| 
      
 103 
     | 
    
         
            +
            }
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
            function createEachPieEventTexts (pluginName: string, context: {
         
     | 
| 
      
 106 
     | 
    
         
            +
              containerSelection: d3.Selection<SVGGElement, any, any, unknown>
         
     | 
| 
      
 107 
     | 
    
         
            +
              computedData$: Observable<ComputedDatumSeries[][]>
         
     | 
| 
      
 108 
     | 
    
         
            +
              containerComputedLayoutData$: Observable<ComputedDatumSeries[]>
         
     | 
| 
      
 109 
     | 
    
         
            +
              SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
         
     | 
| 
      
 110 
     | 
    
         
            +
              fullParams$: Observable<PieEventTextsParams>
         
     | 
| 
      
 111 
     | 
    
         
            +
              fullChartParams$: Observable<ChartParams>
         
     | 
| 
      
 112 
     | 
    
         
            +
              seriesHighlight$: Observable<ComputedDatumSeries[]>
         
     | 
| 
      
 113 
     | 
    
         
            +
              seriesContainerPosition$: Observable<SeriesContainerPosition>
         
     | 
| 
      
 114 
     | 
    
         
            +
              event$: Subject<EventSeries>
         
     | 
| 
      
 115 
     | 
    
         
            +
            }) {
         
     | 
| 
      
 116 
     | 
    
         
            +
              const destroy$ = new Subject()
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              // const graphicSelection: d3.Selection<SVGGElement, any, any, any> = selection.append('g')
         
     | 
| 
      
 119 
     | 
    
         
            +
              let centerTextSelection: d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> | undefined
         
     | 
| 
      
 120 
     | 
    
         
            +
              let storeEventSubscription: Subscription | undefined
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              // context.layout$
         
     | 
| 
      
 123 
     | 
    
         
            +
              //   .pipe(
         
     | 
| 
      
 124 
     | 
    
         
            +
              //     first()
         
     | 
| 
      
 125 
     | 
    
         
            +
              //   )
         
     | 
| 
      
 126 
     | 
    
         
            +
              //   .subscribe(size => {
         
     | 
| 
      
 127 
     | 
    
         
            +
              //     selection
         
     | 
| 
      
 128 
     | 
    
         
            +
              //       .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
         
     | 
| 
      
 129 
     | 
    
         
            +
              //     context.layout$
         
     | 
| 
      
 130 
     | 
    
         
            +
              //       .pipe(
         
     | 
| 
      
 131 
     | 
    
         
            +
              //         takeUntil(destroy$)
         
     | 
| 
      
 132 
     | 
    
         
            +
              //       )
         
     | 
| 
      
 133 
     | 
    
         
            +
              //       .subscribe(size => {
         
     | 
| 
      
 134 
     | 
    
         
            +
              //         selection
         
     | 
| 
      
 135 
     | 
    
         
            +
              //           .transition()
         
     | 
| 
      
 136 
     | 
    
         
            +
              //           .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
         
     | 
| 
      
 137 
     | 
    
         
            +
              //       })
         
     | 
| 
      
 138 
     | 
    
         
            +
              //   })
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              const highlightTarget$ = context.fullChartParams$.pipe(
         
     | 
| 
      
 141 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 142 
     | 
    
         
            +
                map(d => d.highlightTarget),
         
     | 
| 
      
 143 
     | 
    
         
            +
                distinctUntilChanged()
         
     | 
| 
      
 144 
     | 
    
         
            +
              )
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              combineLatest({
         
     | 
| 
      
 147 
     | 
    
         
            +
                computedData: context.computedData$,
         
     | 
| 
      
 148 
     | 
    
         
            +
                fullParams: context.fullParams$,
         
     | 
| 
      
 149 
     | 
    
         
            +
                fullChartParams: context.fullChartParams$,
         
     | 
| 
      
 150 
     | 
    
         
            +
                highlightTarget: highlightTarget$,
         
     | 
| 
      
 151 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 152 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 153 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 154 
     | 
    
         
            +
              ).subscribe(data => {
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                context.containerSelection
         
     | 
| 
      
 157 
     | 
    
         
            +
                  .transition('move')
         
     | 
| 
      
 158 
     | 
    
         
            +
                  .duration(data.fullChartParams.transitionDuration!)
         
     | 
| 
      
 159 
     | 
    
         
            +
                  // .ease(getD3TransitionEase(data.fullChartParams.transitionEase!))
         
     | 
| 
      
 160 
     | 
    
         
            +
                  .tween('move', (event, datum) => {
         
     | 
| 
      
 161 
     | 
    
         
            +
                    return (t) => {
         
     | 
| 
      
 162 
     | 
    
         
            +
                      const renderData = makeTextData({
         
     | 
| 
      
 163 
     | 
    
         
            +
                        eventData: {
         
     | 
| 
      
 164 
     | 
    
         
            +
                          type: 'series',
         
     | 
| 
      
 165 
     | 
    
         
            +
                          pluginName,
         
     | 
| 
      
 166 
     | 
    
         
            +
                          eventName: 'transitionMove',
         
     | 
| 
      
 167 
     | 
    
         
            +
                          event,
         
     | 
| 
      
 168 
     | 
    
         
            +
                          highlightTarget: data.highlightTarget,
         
     | 
| 
      
 169 
     | 
    
         
            +
                          data: data.computedData,
         
     | 
| 
      
 170 
     | 
    
         
            +
                          series: [],
         
     | 
| 
      
 171 
     | 
    
         
            +
                          seriesIndex: -1,
         
     | 
| 
      
 172 
     | 
    
         
            +
                          seriesLabel: '',
         
     | 
| 
      
 173 
     | 
    
         
            +
                          datum: null
         
     | 
| 
      
 174 
     | 
    
         
            +
                        },
         
     | 
| 
      
 175 
     | 
    
         
            +
                        eventName: 'transitionMove',
         
     | 
| 
      
 176 
     | 
    
         
            +
                        t,
         
     | 
| 
      
 177 
     | 
    
         
            +
                        eventFn: data.fullParams.eventFn!,
         
     | 
| 
      
 178 
     | 
    
         
            +
                        textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
      
 179 
     | 
    
         
            +
                        textStyles: data.fullParams.textStyles!
         
     | 
| 
      
 180 
     | 
    
         
            +
                      })
         
     | 
| 
      
 181 
     | 
    
         
            +
                      centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
      
 182 
     | 
    
         
            +
                    }
         
     | 
| 
      
 183 
     | 
    
         
            +
                  })
         
     | 
| 
      
 184 
     | 
    
         
            +
                  .on('end', (event, datum) => {
         
     | 
| 
      
 185 
     | 
    
         
            +
                    const renderData = makeTextData({
         
     | 
| 
      
 186 
     | 
    
         
            +
                      eventData: {
         
     | 
| 
      
 187 
     | 
    
         
            +
                        type: 'series',
         
     | 
| 
      
 188 
     | 
    
         
            +
                        pluginName,
         
     | 
| 
      
 189 
     | 
    
         
            +
                        eventName: 'transitionEnd',
         
     | 
| 
      
 190 
     | 
    
         
            +
                        event,
         
     | 
| 
      
 191 
     | 
    
         
            +
                        highlightTarget: data.highlightTarget,
         
     | 
| 
      
 192 
     | 
    
         
            +
                        data: data.computedData,
         
     | 
| 
      
 193 
     | 
    
         
            +
                        series: [],
         
     | 
| 
      
 194 
     | 
    
         
            +
                        seriesIndex: -1,
         
     | 
| 
      
 195 
     | 
    
         
            +
                        seriesLabel: '',
         
     | 
| 
      
 196 
     | 
    
         
            +
                        datum: null
         
     | 
| 
      
 197 
     | 
    
         
            +
                      },
         
     | 
| 
      
 198 
     | 
    
         
            +
                      eventName: 'transitionMove',
         
     | 
| 
      
 199 
     | 
    
         
            +
                      t: 1,
         
     | 
| 
      
 200 
     | 
    
         
            +
                      eventFn: data.fullParams.eventFn!,
         
     | 
| 
      
 201 
     | 
    
         
            +
                      textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
      
 202 
     | 
    
         
            +
                      textStyles: data.fullParams.textStyles!
         
     | 
| 
      
 203 
     | 
    
         
            +
                    })
         
     | 
| 
      
 204 
     | 
    
         
            +
                    centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                    if (storeEventSubscription) {
         
     | 
| 
      
 207 
     | 
    
         
            +
                      storeEventSubscription.unsubscribe()
         
     | 
| 
      
 208 
     | 
    
         
            +
                    }
         
     | 
| 
      
 209 
     | 
    
         
            +
                    storeEventSubscription = context.event$
         
     | 
| 
      
 210 
     | 
    
         
            +
                      .subscribe(eventData => {
         
     | 
| 
      
 211 
     | 
    
         
            +
                        const renderData = makeTextData({
         
     | 
| 
      
 212 
     | 
    
         
            +
                          eventData,
         
     | 
| 
      
 213 
     | 
    
         
            +
                          eventName: eventData.eventName,
         
     | 
| 
      
 214 
     | 
    
         
            +
                          t: 1,
         
     | 
| 
      
 215 
     | 
    
         
            +
                          eventFn: data.fullParams.eventFn!,
         
     | 
| 
      
 216 
     | 
    
         
            +
                          textAttrs: data.fullParams.textAttrs!,
         
     | 
| 
      
 217 
     | 
    
         
            +
                          textStyles: data.fullParams.textStyles!
         
     | 
| 
      
 218 
     | 
    
         
            +
                        })
         
     | 
| 
      
 219 
     | 
    
         
            +
                        centerTextSelection = renderText(context.containerSelection, renderData)
         
     | 
| 
      
 220 
     | 
    
         
            +
                      })
         
     | 
| 
      
 221 
     | 
    
         
            +
                  })
         
     | 
| 
      
 222 
     | 
    
         
            +
              })
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              return () => {
         
     | 
| 
      
 225 
     | 
    
         
            +
                destroy$.next(undefined)
         
     | 
| 
      
 226 
     | 
    
         
            +
              }
         
     | 
| 
      
 227 
     | 
    
         
            +
            }
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
            export const PieEventTexts = defineSeriesPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
         
     | 
| 
      
 230 
     | 
    
         
            +
              const destroy$ = new Subject()
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
              const { seriesCenterSelection$ } = seriesCenterSelectionObservable({
         
     | 
| 
      
 233 
     | 
    
         
            +
                selection: selection,
         
     | 
| 
      
 234 
     | 
    
         
            +
                pluginName,
         
     | 
| 
      
 235 
     | 
    
         
            +
                separateSeries$: observer.separateSeries$,
         
     | 
| 
      
 236 
     | 
    
         
            +
                seriesLabels$: observer.seriesLabels$,
         
     | 
| 
      
 237 
     | 
    
         
            +
                seriesContainerPosition$: observer.seriesContainerPosition$
         
     | 
| 
      
 238 
     | 
    
         
            +
              })
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
              const unsubscribeFnArr: (() => void)[] = []
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
              seriesCenterSelection$
         
     | 
| 
      
 243 
     | 
    
         
            +
                .pipe(
         
     | 
| 
      
 244 
     | 
    
         
            +
                  takeUntil(destroy$)
         
     | 
| 
      
 245 
     | 
    
         
            +
                )
         
     | 
| 
      
 246 
     | 
    
         
            +
                .subscribe(seriesCenterSelection => {
         
     | 
| 
      
 247 
     | 
    
         
            +
                  // 每次重新計算時,清除之前的訂閱
         
     | 
| 
      
 248 
     | 
    
         
            +
                  unsubscribeFnArr.forEach(fn => fn())
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                  seriesCenterSelection.each((d, containerIndex, g) => { 
         
     | 
| 
      
 251 
     | 
    
         
            +
                    
         
     | 
| 
      
 252 
     | 
    
         
            +
                    const containerSelection = d3.select(g[containerIndex])
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
                    const containerComputedLayoutData$ = observer.computedLayoutData$.pipe(
         
     | 
| 
      
 255 
     | 
    
         
            +
                      takeUntil(destroy$),
         
     | 
| 
      
 256 
     | 
    
         
            +
                      map(data => data[containerIndex] ?? data[0])
         
     | 
| 
      
 257 
     | 
    
         
            +
                    )
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                    const containerPosition$ = observer.seriesContainerPosition$.pipe(
         
     | 
| 
      
 260 
     | 
    
         
            +
                      takeUntil(destroy$),
         
     | 
| 
      
 261 
     | 
    
         
            +
                      map(data => data[containerIndex] ?? data[0])
         
     | 
| 
      
 262 
     | 
    
         
            +
                    )
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                    unsubscribeFnArr[containerIndex] = createEachPieEventTexts(pluginName, {
         
     | 
| 
      
 265 
     | 
    
         
            +
                      containerSelection: containerSelection,
         
     | 
| 
      
 266 
     | 
    
         
            +
                      computedData$: observer.computedData$,
         
     | 
| 
      
 267 
     | 
    
         
            +
                      containerComputedLayoutData$: containerComputedLayoutData$,
         
     | 
| 
      
 268 
     | 
    
         
            +
                      SeriesDataMap$: observer.SeriesDataMap$,
         
     | 
| 
      
 269 
     | 
    
         
            +
                      fullParams$: observer.fullParams$,
         
     | 
| 
      
 270 
     | 
    
         
            +
                      fullChartParams$: observer.fullChartParams$,
         
     | 
| 
      
 271 
     | 
    
         
            +
                      seriesHighlight$: observer.seriesHighlight$,
         
     | 
| 
      
 272 
     | 
    
         
            +
                      seriesContainerPosition$: containerPosition$,
         
     | 
| 
      
 273 
     | 
    
         
            +
                      event$: subject.event$,
         
     | 
| 
      
 274 
     | 
    
         
            +
                    })
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
                  })
         
     | 
| 
      
 277 
     | 
    
         
            +
                })
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
              return () => {
         
     | 
| 
      
 280 
     | 
    
         
            +
                destroy$.next(undefined)
         
     | 
| 
      
 281 
     | 
    
         
            +
                unsubscribeFnArr.forEach(fn => fn())
         
     | 
| 
      
 282 
     | 
    
         
            +
              }
         
     | 
| 
      
 283 
     | 
    
         
            +
            })
         
     |