@orbcharts/plugins-basic 3.0.0-beta.1 → 3.0.0-beta.3
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/dist/orbcharts-plugins-basic.es.js +2863 -2860
 - package/dist/orbcharts-plugins-basic.umd.js +46 -46
 - 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 -382
 - 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,580 +1,580 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import * as d3 from 'd3'
         
     | 
| 
       2 
     | 
    
         
            -
            import {
         
     | 
| 
       3 
     | 
    
         
            -
              combineLatest,
         
     | 
| 
       4 
     | 
    
         
            -
              switchMap,
         
     | 
| 
       5 
     | 
    
         
            -
              distinctUntilChanged,
         
     | 
| 
       6 
     | 
    
         
            -
              first,
         
     | 
| 
       7 
     | 
    
         
            -
              map,
         
     | 
| 
       8 
     | 
    
         
            -
              takeUntil,
         
     | 
| 
       9 
     | 
    
         
            -
              Observable,
         
     | 
| 
       10 
     | 
    
         
            -
              Subject } from 'rxjs'
         
     | 
| 
       11 
     | 
    
         
            -
            import { createAxisLinearScale } from '../../lib/core'
         
     | 
| 
       12 
     | 
    
         
            -
            import type { BasePluginFn } from './types'
         
     | 
| 
       13 
     | 
    
         
            -
            import type {
         
     | 
| 
       14 
     | 
    
         
            -
              ComputedDataGrid,
         
     | 
| 
       15 
     | 
    
         
            -
              DataFormatterGrid,
         
     | 
| 
       16 
     | 
    
         
            -
              ChartParams,
         
     | 
| 
       17 
     | 
    
         
            -
              ComputedDatumGrid,
         
     | 
| 
       18 
     | 
    
         
            -
              GridContainerPosition,
         
     | 
| 
       19 
     | 
    
         
            -
              TransformData,
         
     | 
| 
       20 
     | 
    
         
            -
              EventGrid,
         
     | 
| 
       21 
     | 
    
         
            -
              ColorType
         
     | 
| 
       22 
     | 
    
         
            -
            } from '../../lib/core-types'
         
     | 
| 
       23 
     | 
    
         
            -
            import type { BaseValueAxisParams } from '../../lib/plugins-basic-types'
         
     | 
| 
       24 
     | 
    
         
            -
            import { parseTickFormatValue } from '../utils/d3Utils'
         
     | 
| 
       25 
     | 
    
         
            -
            import { getColor, getMinAndMaxValue, getClassName, getUniID } from '../utils/orbchartsUtils'
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            // export interface BaseValueAxisParams {
         
     | 
| 
       28 
     | 
    
         
            -
            //   labelOffset: [number, number]
         
     | 
| 
       29 
     | 
    
         
            -
            //   labelColorType: ColorType
         
     | 
| 
       30 
     | 
    
         
            -
            //   axisLineVisible: boolean
         
     | 
| 
       31 
     | 
    
         
            -
            //   axisLineColorType: ColorType
         
     | 
| 
       32 
     | 
    
         
            -
            //   ticks: number
         
     | 
| 
       33 
     | 
    
         
            -
            //   tickFormat: string | ((text: d3.NumberValue) => string)
         
     | 
| 
       34 
     | 
    
         
            -
            //   tickLineVisible: boolean
         
     | 
| 
       35 
     | 
    
         
            -
            //   tickPadding: number
         
     | 
| 
       36 
     | 
    
         
            -
            //   tickFullLine: boolean
         
     | 
| 
       37 
     | 
    
         
            -
            //   tickFullLineDasharray: string
         
     | 
| 
       38 
     | 
    
         
            -
            //   tickColorType: ColorType
         
     | 
| 
       39 
     | 
    
         
            -
            //   tickTextRotate: number
         
     | 
| 
       40 
     | 
    
         
            -
            //   tickTextColorType: ColorType
         
     | 
| 
       41 
     | 
    
         
            -
            // }
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            interface BaseLinesContext {
         
     | 
| 
       44 
     | 
    
         
            -
              selection: d3.Selection<any, unknown, any, unknown>
         
     | 
| 
       45 
     | 
    
         
            -
              computedData$: Observable<ComputedDataGrid>
         
     | 
| 
       46 
     | 
    
         
            -
              fullParams$: Observable<BaseValueAxisParams>
         
     | 
| 
       47 
     | 
    
         
            -
              fullDataFormatter$: Observable<DataFormatterGrid>
         
     | 
| 
       48 
     | 
    
         
            -
              fullChartParams$: Observable<ChartParams>
         
     | 
| 
       49 
     | 
    
         
            -
              gridAxesTransform$: Observable<TransformData>
         
     | 
| 
       50 
     | 
    
         
            -
              gridAxesReverseTransform$: Observable<TransformData>
         
     | 
| 
       51 
     | 
    
         
            -
              gridAxesSize$: Observable<{
         
     | 
| 
       52 
     | 
    
         
            -
                width: number;
         
     | 
| 
       53 
     | 
    
         
            -
                height: number;
         
     | 
| 
       54 
     | 
    
         
            -
              }>
         
     | 
| 
       55 
     | 
    
         
            -
              gridContainerPosition$: Observable<GridContainerPosition[]>
         
     | 
| 
       56 
     | 
    
         
            -
              isSeriesSeprate$: Observable<boolean>
         
     | 
| 
       57 
     | 
    
         
            -
            }
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            interface TextAlign {
         
     | 
| 
       60 
     | 
    
         
            -
              textAnchor: "start" | "middle" | "end"
         
     | 
| 
       61 
     | 
    
         
            -
              dominantBaseline: "middle" | "auto" | "hanging"
         
     | 
| 
       62 
     | 
    
         
            -
            }
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
            // const pluginName = 'ValueAxis'
         
     | 
| 
       65 
     | 
    
         
            -
            // const containerClassName = getClassName(pluginName, 'container')
         
     | 
| 
       66 
     | 
    
         
            -
            // const yAxisGClassName = getClassName(pluginName, 'yAxisG')
         
     | 
| 
       67 
     | 
    
         
            -
            // const yAxisClassName = getClassName(pluginName, 'yAxis')
         
     | 
| 
       68 
     | 
    
         
            -
            // const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
       69 
     | 
    
         
            -
            const defaultTickSize = 6
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
            function renderAxisLabel ({ selection, textClassName, fullParams, axisLabelAlign, gridAxesSize, fullDataFormatter, fullChartParams, textReverseTransform }: {
         
     | 
| 
       72 
     | 
    
         
            -
              selection: d3.Selection<SVGGElement, any, any, any>,
         
     | 
| 
       73 
     | 
    
         
            -
              textClassName: string
         
     | 
| 
       74 
     | 
    
         
            -
              fullParams: BaseValueAxisParams
         
     | 
| 
       75 
     | 
    
         
            -
              axisLabelAlign: TextAlign
         
     | 
| 
       76 
     | 
    
         
            -
              gridAxesSize: { width: number, height: number }
         
     | 
| 
       77 
     | 
    
         
            -
              fullDataFormatter: DataFormatterGrid,
         
     | 
| 
       78 
     | 
    
         
            -
              fullChartParams: ChartParams
         
     | 
| 
       79 
     | 
    
         
            -
              textReverseTransform: string,
         
     | 
| 
       80 
     | 
    
         
            -
            }) {
         
     | 
| 
       81 
     | 
    
         
            -
              const offsetX = fullParams.tickPadding - fullParams.labelOffset[0]
         
     | 
| 
       82 
     | 
    
         
            -
              const offsetY = fullParams.tickPadding + fullParams.labelOffset[1]
         
     | 
| 
       83 
     | 
    
         
            -
              let labelX = 0
         
     | 
| 
       84 
     | 
    
         
            -
              let labelY = 0
         
     | 
| 
       85 
     | 
    
         
            -
              if (fullDataFormatter.grid.groupAxis.position === 'bottom') {
         
     | 
| 
       86 
     | 
    
         
            -
                // labelY = - gridAxesSize.height - offsetY
         
     | 
| 
       87 
     | 
    
         
            -
                labelY = - offsetY
         
     | 
| 
       88 
     | 
    
         
            -
                if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
       89 
     | 
    
         
            -
                  labelX = - offsetX
         
     | 
| 
       90 
     | 
    
         
            -
                } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
       91 
     | 
    
         
            -
                  labelX = offsetX
         
     | 
| 
       92 
     | 
    
         
            -
                }
         
     | 
| 
       93 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.groupAxis.position === 'top') {
         
     | 
| 
       94 
     | 
    
         
            -
                // labelY = gridAxesSize.height + offsetY
         
     | 
| 
       95 
     | 
    
         
            -
                labelY = offsetY
         
     | 
| 
       96 
     | 
    
         
            -
                if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
       97 
     | 
    
         
            -
                  labelX = - offsetX
         
     | 
| 
       98 
     | 
    
         
            -
                } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
       99 
     | 
    
         
            -
                  labelX = offsetX
         
     | 
| 
       100 
     | 
    
         
            -
                }
         
     | 
| 
       101 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.groupAxis.position === 'left') {
         
     | 
| 
       102 
     | 
    
         
            -
                // labelX = gridAxesSize.width + offsetX
         
     | 
| 
       103 
     | 
    
         
            -
                labelX = offsetX
         
     | 
| 
       104 
     | 
    
         
            -
                if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
       105 
     | 
    
         
            -
                  labelY = offsetY
         
     | 
| 
       106 
     | 
    
         
            -
                } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
       107 
     | 
    
         
            -
                  labelY = - offsetY
         
     | 
| 
       108 
     | 
    
         
            -
                }
         
     | 
| 
       109 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.groupAxis.position === 'right') {
         
     | 
| 
       110 
     | 
    
         
            -
                labelX = - offsetX
         
     | 
| 
       111 
     | 
    
         
            -
                if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
       112 
     | 
    
         
            -
                  labelY = offsetY
         
     | 
| 
       113 
     | 
    
         
            -
                } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
       114 
     | 
    
         
            -
                  labelY = - offsetY
         
     | 
| 
       115 
     | 
    
         
            -
                }
         
     | 
| 
       116 
     | 
    
         
            -
              }
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
              const axisLabelSelection = selection
         
     | 
| 
       119 
     | 
    
         
            -
                .selectAll<SVGGElement, BaseValueAxisParams>(`g.${textClassName}`)
         
     | 
| 
       120 
     | 
    
         
            -
                .data([fullParams])
         
     | 
| 
       121 
     | 
    
         
            -
                .join('g')
         
     | 
| 
       122 
     | 
    
         
            -
                .classed(textClassName, true)
         
     | 
| 
       123 
     | 
    
         
            -
                .each((d, i, g) => {
         
     | 
| 
       124 
     | 
    
         
            -
                  const text = d3.select(g[i])
         
     | 
| 
       125 
     | 
    
         
            -
                    .selectAll<SVGTextElement, BaseValueAxisParams>(`text`)
         
     | 
| 
       126 
     | 
    
         
            -
                    .data([d])
         
     | 
| 
       127 
     | 
    
         
            -
                    .join(
         
     | 
| 
       128 
     | 
    
         
            -
                      enter => {
         
     | 
| 
       129 
     | 
    
         
            -
                        return enter
         
     | 
| 
       130 
     | 
    
         
            -
                          .append('text')
         
     | 
| 
       131 
     | 
    
         
            -
                          .style('font-weight', 'bold')
         
     | 
| 
       132 
     | 
    
         
            -
                      },
         
     | 
| 
       133 
     | 
    
         
            -
                      update => update,
         
     | 
| 
       134 
     | 
    
         
            -
                      exit => exit.remove()
         
     | 
| 
       135 
     | 
    
         
            -
                    )
         
     | 
| 
       136 
     | 
    
         
            -
                    .attr('text-anchor', axisLabelAlign.textAnchor)
         
     | 
| 
       137 
     | 
    
         
            -
                    .attr('dominant-baseline', axisLabelAlign.dominantBaseline)
         
     | 
| 
       138 
     | 
    
         
            -
                    .attr('font-size', fullChartParams.styles.textSize)
         
     | 
| 
       139 
     | 
    
         
            -
                    .style('fill', getColor(fullParams.labelColorType, fullChartParams))
         
     | 
| 
       140 
     | 
    
         
            -
                    .style('transform', textReverseTransform)
         
     | 
| 
       141 
     | 
    
         
            -
                    // 偏移使用 x, y 而非 transform 才不會受到外層 scale 變形影響
         
     | 
| 
       142 
     | 
    
         
            -
                    .attr('x', labelX)
         
     | 
| 
       143 
     | 
    
         
            -
                    .attr('y', labelY)
         
     | 
| 
       144 
     | 
    
         
            -
                    .text(d => fullDataFormatter.grid.valueAxis.label)
         
     | 
| 
       145 
     | 
    
         
            -
                })
         
     | 
| 
       146 
     | 
    
         
            -
                .attr('transform', d => `translate(0, ${gridAxesSize.height})`)
         
     | 
| 
       147 
     | 
    
         
            -
                // .attr('transform', d => `translate(${- fullParams.tickPadding + fullParams.labelOffset[0]}, ${gridAxesSize.height + fullParams.tickPadding + fullParams.labelOffset[1]})`)
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
            }
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
            function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gridAxesSize, fullDataFormatter, fullChartParams, valueScale, textReverseTransformWithRotate, minAndMax }: {
         
     | 
| 
       153 
     | 
    
         
            -
              selection: d3.Selection<SVGGElement, any, any, any>,
         
     | 
| 
       154 
     | 
    
         
            -
              yAxisClassName: string
         
     | 
| 
       155 
     | 
    
         
            -
              fullParams: BaseValueAxisParams
         
     | 
| 
       156 
     | 
    
         
            -
              tickTextAlign: TextAlign
         
     | 
| 
       157 
     | 
    
         
            -
              gridAxesSize: { width: number, height: number }
         
     | 
| 
       158 
     | 
    
         
            -
              fullDataFormatter: DataFormatterGrid,
         
     | 
| 
       159 
     | 
    
         
            -
              fullChartParams: ChartParams
         
     | 
| 
       160 
     | 
    
         
            -
              valueScale: d3.ScaleLinear<number, number>
         
     | 
| 
       161 
     | 
    
         
            -
              textReverseTransformWithRotate: string,
         
     | 
| 
       162 
     | 
    
         
            -
              minAndMax: [number, number]
         
     | 
| 
       163 
     | 
    
         
            -
            }) {
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
              const yAxisSelection = selection
         
     | 
| 
       166 
     | 
    
         
            -
                .selectAll<SVGGElement, BaseValueAxisParams>(`g.${yAxisClassName}`)
         
     | 
| 
       167 
     | 
    
         
            -
                .data([fullParams])
         
     | 
| 
       168 
     | 
    
         
            -
                .join('g')
         
     | 
| 
       169 
     | 
    
         
            -
                .classed(yAxisClassName, true)
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
              const valueLength = minAndMax[1] - minAndMax[0]
         
     | 
| 
       172 
     | 
    
         
            -
              
         
     | 
| 
       173 
     | 
    
         
            -
              // const _valueScale = d3.scaleLinear()
         
     | 
| 
       174 
     | 
    
         
            -
              //   .domain([0, 150])
         
     | 
| 
       175 
     | 
    
         
            -
              //   .range([416.5, 791.349])
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
              // 刻度文字偏移
         
     | 
| 
       178 
     | 
    
         
            -
              let tickPadding = 0
         
     | 
| 
       179 
     | 
    
         
            -
              let textY = 0
         
     | 
| 
       180 
     | 
    
         
            -
              if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
       181 
     | 
    
         
            -
                tickPadding = fullParams.tickPadding
         
     | 
| 
       182 
     | 
    
         
            -
                textY = 0
         
     | 
| 
       183 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
       184 
     | 
    
         
            -
                tickPadding = - fullParams.tickPadding
         
     | 
| 
       185 
     | 
    
         
            -
                textY = 0
         
     | 
| 
       186 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
       187 
     | 
    
         
            -
                tickPadding = 0
         
     | 
| 
       188 
     | 
    
         
            -
                textY = fullParams.tickPadding
         
     | 
| 
       189 
     | 
    
         
            -
              } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
       190 
     | 
    
         
            -
                tickPadding = 0
         
     | 
| 
       191 
     | 
    
         
            -
                textY = - fullParams.tickPadding
         
     | 
| 
       192 
     | 
    
         
            -
              }
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
              // 設定Y軸刻度
         
     | 
| 
       195 
     | 
    
         
            -
              const yAxis = d3.axisLeft(valueScale)
         
     | 
| 
       196 
     | 
    
         
            -
                .scale(valueScale)
         
     | 
| 
       197 
     | 
    
         
            -
                .ticks(valueLength > fullParams.ticks
         
     | 
| 
       198 
     | 
    
         
            -
                  ? fullParams.ticks
         
     | 
| 
       199 
     | 
    
         
            -
                  : ((minAndMax[0] === 0 && minAndMax[1] === 0)
         
     | 
| 
       200 
     | 
    
         
            -
                    ? 1
         
     | 
| 
       201 
     | 
    
         
            -
                    : Math.ceil(valueLength))) // 刻度分段數量
         
     | 
| 
       202 
     | 
    
         
            -
                .tickFormat(d => parseTickFormatValue(d, fullParams.tickFormat))
         
     | 
| 
       203 
     | 
    
         
            -
                .tickSize(fullParams.tickFullLine == true
         
     | 
| 
       204 
     | 
    
         
            -
                  ? -gridAxesSize.width
         
     | 
| 
       205 
     | 
    
         
            -
                  : defaultTickSize)
         
     | 
| 
       206 
     | 
    
         
            -
                .tickPadding(tickPadding)
         
     | 
| 
       207 
     | 
    
         
            -
              
         
     | 
| 
       208 
     | 
    
         
            -
              const yAxisEl = yAxisSelection
         
     | 
| 
       209 
     | 
    
         
            -
                .transition()
         
     | 
| 
       210 
     | 
    
         
            -
                .duration(100)
         
     | 
| 
       211 
     | 
    
         
            -
                .call(yAxis)
         
     | 
| 
       212 
     | 
    
         
            -
              
         
     | 
| 
       213 
     | 
    
         
            -
              yAxisEl.selectAll('line')
         
     | 
| 
       214 
     | 
    
         
            -
                .style('fill', 'none')
         
     | 
| 
       215 
     | 
    
         
            -
                .style('stroke', fullParams.tickLineVisible == true ? getColor(fullParams.tickColorType, fullChartParams) : 'none')
         
     | 
| 
       216 
     | 
    
         
            -
                .style('stroke-dasharray', fullParams.tickFullLineDasharray)
         
     | 
| 
       217 
     | 
    
         
            -
                .attr('pointer-events', 'none')
         
     | 
| 
       218 
     | 
    
         
            -
              
         
     | 
| 
       219 
     | 
    
         
            -
              yAxisEl.selectAll('path')
         
     | 
| 
       220 
     | 
    
         
            -
                .style('fill', 'none')
         
     | 
| 
       221 
     | 
    
         
            -
                // .style('stroke', this.fullParams.axisLineColor!)
         
     | 
| 
       222 
     | 
    
         
            -
                .style('stroke', fullParams.axisLineVisible == true ? getColor(fullParams.axisLineColorType, fullChartParams) : 'none')
         
     | 
| 
       223 
     | 
    
         
            -
                .style('shape-rendering', 'crispEdges')
         
     | 
| 
       224 
     | 
    
         
            -
              
         
     | 
| 
       225 
     | 
    
         
            -
              // const yText = yAxisEl.selectAll('text')
         
     | 
| 
       226 
     | 
    
         
            -
              const yText = yAxisSelection.selectAll('text')
         
     | 
| 
       227 
     | 
    
         
            -
                // .style('font-family', 'sans-serif')
         
     | 
| 
       228 
     | 
    
         
            -
                .attr('font-size', fullChartParams.styles.textSize)
         
     | 
| 
       229 
     | 
    
         
            -
                .style('color', getColor(fullParams.tickTextColorType, fullChartParams))
         
     | 
| 
       230 
     | 
    
         
            -
                .attr('text-anchor', tickTextAlign.textAnchor)
         
     | 
| 
       231 
     | 
    
         
            -
                .attr('dominant-baseline', tickTextAlign.dominantBaseline)
         
     | 
| 
       232 
     | 
    
         
            -
                // .attr('dy', 0)
         
     | 
| 
       233 
     | 
    
         
            -
                .attr('y', textY)
         
     | 
| 
       234 
     | 
    
         
            -
              yText.style('transform', textReverseTransformWithRotate)
         
     | 
| 
       235 
     | 
    
         
            -
              
         
     | 
| 
       236 
     | 
    
         
            -
              // 抵消掉預設的偏移
         
     | 
| 
       237 
     | 
    
         
            -
              if (fullDataFormatter.grid.valueAxis.position === 'bottom' || fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
       238 
     | 
    
         
            -
                yText.attr('dy', 0)
         
     | 
| 
       239 
     | 
    
         
            -
              }
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
              return yAxisSelection
         
     | 
| 
       242 
     | 
    
         
            -
            }
         
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
            export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName: string, {
         
     | 
| 
       247 
     | 
    
         
            -
              selection,
         
     | 
| 
       248 
     | 
    
         
            -
              computedData$,
         
     | 
| 
       249 
     | 
    
         
            -
              fullParams$,
         
     | 
| 
       250 
     | 
    
         
            -
              fullDataFormatter$,
         
     | 
| 
       251 
     | 
    
         
            -
              fullChartParams$,
         
     | 
| 
       252 
     | 
    
         
            -
              gridAxesTransform$,
         
     | 
| 
       253 
     | 
    
         
            -
              gridAxesReverseTransform$,
         
     | 
| 
       254 
     | 
    
         
            -
              gridAxesSize$,
         
     | 
| 
       255 
     | 
    
         
            -
              gridContainerPosition$,
         
     | 
| 
       256 
     | 
    
         
            -
              isSeriesSeprate$,
         
     | 
| 
       257 
     | 
    
         
            -
            }) => {
         
     | 
| 
       258 
     | 
    
         
            -
              
         
     | 
| 
       259 
     | 
    
         
            -
              const destroy$ = new Subject()
         
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
              const containerClassName = getClassName(pluginName, 'container')
         
     | 
| 
       262 
     | 
    
         
            -
              const yAxisGClassName = getClassName(pluginName, 'yAxisG')
         
     | 
| 
       263 
     | 
    
         
            -
              const yAxisClassName = getClassName(pluginName, 'yAxis')
         
     | 
| 
       264 
     | 
    
         
            -
              const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
              const containerSelection$ = combineLatest({
         
     | 
| 
       267 
     | 
    
         
            -
                computedData: computedData$.pipe(
         
     | 
| 
       268 
     | 
    
         
            -
                  distinctUntilChanged((a, b) => {
         
     | 
| 
       269 
     | 
    
         
            -
                    // 只有當series的數量改變時,才重新計算
         
     | 
| 
       270 
     | 
    
         
            -
                    return a.length === b.length
         
     | 
| 
       271 
     | 
    
         
            -
                  }),
         
     | 
| 
       272 
     | 
    
         
            -
                ),
         
     | 
| 
       273 
     | 
    
         
            -
                isSeriesSeprate: isSeriesSeprate$
         
     | 
| 
       274 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       275 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       276 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       277 
     | 
    
         
            -
                map(data => {
         
     | 
| 
       278 
     | 
    
         
            -
                  return data.isSeriesSeprate
         
     | 
| 
       279 
     | 
    
         
            -
                    // series分開的時候顯示各別axis
         
     | 
| 
       280 
     | 
    
         
            -
                    ? data.computedData
         
     | 
| 
       281 
     | 
    
         
            -
                    // series合併的時候只顯示第一個axis
         
     | 
| 
       282 
     | 
    
         
            -
                    : [data.computedData[0]]
         
     | 
| 
       283 
     | 
    
         
            -
                }),
         
     | 
| 
       284 
     | 
    
         
            -
                map((computedData, i) => {
         
     | 
| 
       285 
     | 
    
         
            -
                  return selection
         
     | 
| 
       286 
     | 
    
         
            -
                    .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${containerClassName}`)
         
     | 
| 
       287 
     | 
    
         
            -
                    .data(computedData, d => d[0] ? d[0].seriesIndex : i)
         
     | 
| 
       288 
     | 
    
         
            -
                    .join('g')
         
     | 
| 
       289 
     | 
    
         
            -
                    .classed(containerClassName, true)
         
     | 
| 
       290 
     | 
    
         
            -
                })
         
     | 
| 
       291 
     | 
    
         
            -
              )
         
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
       293 
     | 
    
         
            -
              const axisSelection$ = containerSelection$.pipe(
         
     | 
| 
       294 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       295 
     | 
    
         
            -
                map((containerSelection, i) => {
         
     | 
| 
       296 
     | 
    
         
            -
                  return containerSelection
         
     | 
| 
       297 
     | 
    
         
            -
                    .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${yAxisGClassName}`)
         
     | 
| 
       298 
     | 
    
         
            -
                    .data([yAxisGClassName])
         
     | 
| 
       299 
     | 
    
         
            -
                    .join('g')
         
     | 
| 
       300 
     | 
    
         
            -
                    .classed(yAxisGClassName, true)
         
     | 
| 
       301 
     | 
    
         
            -
                })
         
     | 
| 
       302 
     | 
    
         
            -
              )
         
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
       304 
     | 
    
         
            -
              combineLatest({
         
     | 
| 
       305 
     | 
    
         
            -
                containerSelection: containerSelection$,
         
     | 
| 
       306 
     | 
    
         
            -
                gridContainerPosition: gridContainerPosition$
         
     | 
| 
       307 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       308 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       309 
     | 
    
         
            -
                switchMap(async d => d)
         
     | 
| 
       310 
     | 
    
         
            -
              ).subscribe(data => {
         
     | 
| 
       311 
     | 
    
         
            -
                data.containerSelection
         
     | 
| 
       312 
     | 
    
         
            -
                  .attr('transform', (d, i) => {
         
     | 
| 
       313 
     | 
    
         
            -
                    const gridContainerPosition = data.gridContainerPosition[i] ?? data.gridContainerPosition[0]
         
     | 
| 
       314 
     | 
    
         
            -
                    const translate = gridContainerPosition.translate
         
     | 
| 
       315 
     | 
    
         
            -
                    const scale = gridContainerPosition.scale
         
     | 
| 
       316 
     | 
    
         
            -
                    return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
         
     | 
| 
       317 
     | 
    
         
            -
                  })
         
     | 
| 
       318 
     | 
    
         
            -
                  // .attr('opacity', 0)
         
     | 
| 
       319 
     | 
    
         
            -
                  // .transition()
         
     | 
| 
       320 
     | 
    
         
            -
                  // .attr('opacity', 1)
         
     | 
| 
       321 
     | 
    
         
            -
              })
         
     | 
| 
       322 
     | 
    
         
            -
             
     | 
| 
       323 
     | 
    
         
            -
              combineLatest({
         
     | 
| 
       324 
     | 
    
         
            -
                axisSelection: axisSelection$,
         
     | 
| 
       325 
     | 
    
         
            -
                gridAxesTransform: gridAxesTransform$,
         
     | 
| 
       326 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       327 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       328 
     | 
    
         
            -
                switchMap(async d => d)
         
     | 
| 
       329 
     | 
    
         
            -
              ).subscribe(data => {
         
     | 
| 
       330 
     | 
    
         
            -
                data.axisSelection
         
     | 
| 
       331 
     | 
    
         
            -
                  .style('transform', data.gridAxesTransform.value)
         
     | 
| 
       332 
     | 
    
         
            -
                  // .attr('opacity', 0)
         
     | 
| 
       333 
     | 
    
         
            -
                  // .transition()
         
     | 
| 
       334 
     | 
    
         
            -
                  // .attr('opacity', 1)
         
     | 
| 
       335 
     | 
    
         
            -
                  
         
     | 
| 
       336 
     | 
    
         
            -
              })
         
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
              // const gridAxesSize$ = gridAxisSizeObservable({
         
     | 
| 
       339 
     | 
    
         
            -
              //   fullDataFormatter$,
         
     | 
| 
       340 
     | 
    
         
            -
              //   layout$
         
     | 
| 
       341 
     | 
    
         
            -
              // })
         
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
     | 
    
         
            -
              // const textReverseTransform$: Observable<string> = new Observable(subscriber => {
         
     | 
| 
       344 
     | 
    
         
            -
              //   combineLatest({
         
     | 
| 
       345 
     | 
    
         
            -
              //     fullParams: fullParams$,
         
     | 
| 
       346 
     | 
    
         
            -
              //     layout: layout$
         
     | 
| 
       347 
     | 
    
         
            -
              //   }).pipe(
         
     | 
| 
       348 
     | 
    
         
            -
              //     takeUntil(destroy$),
         
     | 
| 
       349 
     | 
    
         
            -
              //     // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
         
     | 
| 
       350 
     | 
    
         
            -
              //     switchMap(async (d) => d),
         
     | 
| 
       351 
     | 
    
         
            -
              //   ).subscribe(data => {
         
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
              //     const transformData = Object.assign({}, data.layout.content.axesTransformData)
         
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
              //     const value = getAxesTransformValue({
         
     | 
| 
       356 
     | 
    
         
            -
              //       translate: [0, 0],
         
     | 
| 
       357 
     | 
    
         
            -
              //       scale: [transformData.scale[0] * -1, transformData.scale[1] * -1],
         
     | 
| 
       358 
     | 
    
         
            -
              //       rotate: transformData.rotate * -1 + data.fullParams.tickTextRotate,
         
     | 
| 
       359 
     | 
    
         
            -
              //       rotateX: transformData.rotateX * -1,
         
     | 
| 
       360 
     | 
    
         
            -
              //       rotateY: transformData.rotateY * -1
         
     | 
| 
       361 
     | 
    
         
            -
              //     })
         
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
              //     subscriber.next(value)
         
     | 
| 
       364 
     | 
    
         
            -
              //   })
         
     | 
| 
       365 
     | 
    
         
            -
              // })
         
     | 
| 
       366 
     | 
    
         
            -
              // const reverseTransform$: Observable<TransformData> = gridAxesTransform$.pipe(
         
     | 
| 
       367 
     | 
    
         
            -
              //   takeUntil(destroy$),
         
     | 
| 
       368 
     | 
    
         
            -
              //   map(d => {
         
     | 
| 
       369 
     | 
    
         
            -
              //     const translate: [number, number] = [d.translate[0] * -1, d.translate[1] * -1]
         
     | 
| 
       370 
     | 
    
         
            -
              //     const scale: [number, number] = [d.scale[0] * -1, d.scale[1] * -1]
         
     | 
| 
       371 
     | 
    
         
            -
              //     const rotate = d.rotate * -1
         
     | 
| 
       372 
     | 
    
         
            -
              //     const rotateX = d.rotateX * -1
         
     | 
| 
       373 
     | 
    
         
            -
              //     const rotateY = d.rotateY * -1
         
     | 
| 
       374 
     | 
    
         
            -
              //     return {
         
     | 
| 
       375 
     | 
    
         
            -
              //       translate,
         
     | 
| 
       376 
     | 
    
         
            -
              //       scale,
         
     | 
| 
       377 
     | 
    
         
            -
              //       rotate,
         
     | 
| 
       378 
     | 
    
         
            -
              //       rotateX,
         
     | 
| 
       379 
     | 
    
         
            -
              //       rotateY,
         
     | 
| 
       380 
     | 
    
         
            -
              //       value: ''
         
     | 
| 
       381 
     | 
    
         
            -
              //     }
         
     | 
| 
       382 
     | 
    
         
            -
              //   }),
         
     | 
| 
       383 
     | 
    
         
            -
              // )
         
     | 
| 
       384 
     | 
    
         
            -
              const textReverseTransform$ = combineLatest({
         
     | 
| 
       385 
     | 
    
         
            -
                gridAxesReverseTransform: gridAxesReverseTransform$,
         
     | 
| 
       386 
     | 
    
         
            -
                gridContainerPosition: gridContainerPosition$
         
     | 
| 
       387 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       388 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       389 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       390 
     | 
    
         
            -
                map(data => {
         
     | 
| 
       391 
     | 
    
         
            -
                  // const axisReverseTranslateValue = `translate(${data.gridAxesReverseTransform.translate[0]}px, ${data.gridAxesReverseTransform.translate[1]}px)`
         
     | 
| 
       392 
     | 
    
         
            -
                  const axesRotateXYReverseValue = `rotateX(${data.gridAxesReverseTransform.rotateX}deg) rotateY(${data.gridAxesReverseTransform.rotateY}deg)`
         
     | 
| 
       393 
     | 
    
         
            -
                  const axesRotateReverseValue = `rotate(${data.gridAxesReverseTransform.rotate}deg)`
         
     | 
| 
       394 
     | 
    
         
            -
                  const containerScaleReverseValue = `scale(${1 / data.gridContainerPosition[0].scale[0]}, ${1 / data.gridContainerPosition[0].scale[1]})`
         
     | 
| 
       395 
     | 
    
         
            -
                  // 必須按照順序(先抵消外層rotate,再抵消最外層scale)
         
     | 
| 
       396 
     | 
    
         
            -
                  return `${axesRotateXYReverseValue} ${axesRotateReverseValue} ${containerScaleReverseValue}`
         
     | 
| 
       397 
     | 
    
         
            -
                }),
         
     | 
| 
       398 
     | 
    
         
            -
                distinctUntilChanged()
         
     | 
| 
       399 
     | 
    
         
            -
              )
         
     | 
| 
       400 
     | 
    
         
            -
             
     | 
| 
       401 
     | 
    
         
            -
              const textReverseTransformWithRotate$ = combineLatest({
         
     | 
| 
       402 
     | 
    
         
            -
                textReverseTransform: textReverseTransform$,
         
     | 
| 
       403 
     | 
    
         
            -
                fullParams: fullParams$,
         
     | 
| 
       404 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       405 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       406 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       407 
     | 
    
         
            -
                map(data => {
         
     | 
| 
       408 
     | 
    
         
            -
                  // 必須按照順序(先抵消外層rotate,再抵消最外層scale,最後再做本身的rotate)
         
     | 
| 
       409 
     | 
    
         
            -
                  return `${data.textReverseTransform} rotate(${data.fullParams.tickTextRotate}deg)`
         
     | 
| 
       410 
     | 
    
         
            -
                })
         
     | 
| 
       411 
     | 
    
         
            -
              )
         
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
              const minAndMax$: Observable<[number, number]> = new Observable(subscriber => {
         
     | 
| 
       414 
     | 
    
         
            -
                combineLatest({
         
     | 
| 
       415 
     | 
    
         
            -
                  fullDataFormatter: fullDataFormatter$,
         
     | 
| 
       416 
     | 
    
         
            -
                  gridAxesSize: gridAxesSize$,
         
     | 
| 
       417 
     | 
    
         
            -
                  computedData: computedData$
         
     | 
| 
       418 
     | 
    
         
            -
                }).pipe(
         
     | 
| 
       419 
     | 
    
         
            -
                  takeUntil(destroy$),
         
     | 
| 
       420 
     | 
    
         
            -
                  switchMap(async (d) => d),
         
     | 
| 
       421 
     | 
    
         
            -
                ).subscribe(data => {
         
     | 
| 
       422 
     | 
    
         
            -
                  const groupMin = 0
         
     | 
| 
       423 
     | 
    
         
            -
                  const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
         
     | 
| 
       424 
     | 
    
         
            -
                  // const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
         
     | 
| 
       425 
     | 
    
         
            -
                  //   ? groupMin - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
       426 
     | 
    
         
            -
                  //   : data.fullDataFormatter.grid.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
       427 
     | 
    
         
            -
                  const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
       428 
     | 
    
         
            -
                  const groupScaleDomainMax = data.fullDataFormatter.grid.groupAxis.scaleDomain[1] === 'max'
         
     | 
| 
       429 
     | 
    
         
            -
                    ? groupMax + data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
       430 
     | 
    
         
            -
                    : data.fullDataFormatter.grid.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
       431 
     | 
    
         
            -
                    
         
     | 
| 
       432 
     | 
    
         
            -
                  const filteredData = data.computedData.map((d, i) => {
         
     | 
| 
       433 
     | 
    
         
            -
                    return d.filter((_d, _i) => {
         
     | 
| 
       434 
     | 
    
         
            -
                      return _i >= groupScaleDomainMin && _i <= groupScaleDomainMax
         
     | 
| 
       435 
     | 
    
         
            -
                    })
         
     | 
| 
       436 
     | 
    
         
            -
                  })
         
     | 
| 
       437 
     | 
    
         
            -
                
         
     | 
| 
       438 
     | 
    
         
            -
                  const filteredMinAndMax = getMinAndMaxValue(filteredData.flat())
         
     | 
| 
       439 
     | 
    
         
            -
                  if (filteredMinAndMax[0] === filteredMinAndMax[1]) {
         
     | 
| 
       440 
     | 
    
         
            -
                    filteredMinAndMax[0] = filteredMinAndMax[1] - 1 // 避免最大及最小值相同造成無法計算scale
         
     | 
| 
       441 
     | 
    
         
            -
                  }
         
     | 
| 
       442 
     | 
    
         
            -
                  subscriber.next(filteredMinAndMax)
         
     | 
| 
       443 
     | 
    
         
            -
                })
         
     | 
| 
       444 
     | 
    
         
            -
              })
         
     | 
| 
       445 
     | 
    
         
            -
             
     | 
| 
       446 
     | 
    
         
            -
              const valueScale$: Observable<d3.ScaleLinear<number, number>> = new Observable(subscriber => {
         
     | 
| 
       447 
     | 
    
         
            -
                combineLatest({
         
     | 
| 
       448 
     | 
    
         
            -
                  fullDataFormatter: fullDataFormatter$,
         
     | 
| 
       449 
     | 
    
         
            -
                  gridAxesSize: gridAxesSize$,
         
     | 
| 
       450 
     | 
    
         
            -
                  minAndMax: minAndMax$
         
     | 
| 
       451 
     | 
    
         
            -
                }).pipe(
         
     | 
| 
       452 
     | 
    
         
            -
                  takeUntil(destroy$),
         
     | 
| 
       453 
     | 
    
         
            -
                  switchMap(async (d) => d),
         
     | 
| 
       454 
     | 
    
         
            -
                ).subscribe(data => {
         
     | 
| 
       455 
     | 
    
         
            -
                
         
     | 
| 
       456 
     | 
    
         
            -
                  const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
         
     | 
| 
       457 
     | 
    
         
            -
                    maxValue: data.minAndMax[1],
         
     | 
| 
       458 
     | 
    
         
            -
                    minValue: data.minAndMax[0],
         
     | 
| 
       459 
     | 
    
         
            -
                    axisWidth: data.gridAxesSize.height,
         
     | 
| 
       460 
     | 
    
         
            -
                    scaleDomain: data.fullDataFormatter.grid.valueAxis.scaleDomain,
         
     | 
| 
       461 
     | 
    
         
            -
                    scaleRange: data.fullDataFormatter.grid.valueAxis.scaleRange
         
     | 
| 
       462 
     | 
    
         
            -
                  })
         
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
                  subscriber.next(valueScale)
         
     | 
| 
       465 
     | 
    
         
            -
                })
         
     | 
| 
       466 
     | 
    
         
            -
              })
         
     | 
| 
       467 
     | 
    
         
            -
             
     | 
| 
       468 
     | 
    
         
            -
              const tickTextAlign$: Observable<TextAlign> = combineLatest({
         
     | 
| 
       469 
     | 
    
         
            -
                fullDataFormatter: fullDataFormatter$,
         
     | 
| 
       470 
     | 
    
         
            -
                fullParams: fullParams$
         
     | 
| 
       471 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       472 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       473 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       474 
     | 
    
         
            -
                map(data => {
         
     | 
| 
       475 
     | 
    
         
            -
                  let textAnchor: 'start' | 'middle' | 'end' = 'start'
         
     | 
| 
       476 
     | 
    
         
            -
                  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
         
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
                  if (data.fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
       479 
     | 
    
         
            -
                    textAnchor = 'end'
         
     | 
| 
       480 
     | 
    
         
            -
                    dominantBaseline = 'middle'
         
     | 
| 
       481 
     | 
    
         
            -
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
       482 
     | 
    
         
            -
                    textAnchor = 'start'
         
     | 
| 
       483 
     | 
    
         
            -
                    dominantBaseline = 'middle'
         
     | 
| 
       484 
     | 
    
         
            -
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
       485 
     | 
    
         
            -
                    textAnchor = data.fullParams.tickTextRotate
         
     | 
| 
       486 
     | 
    
         
            -
                      ? 'end'
         
     | 
| 
       487 
     | 
    
         
            -
                      : 'middle'
         
     | 
| 
       488 
     | 
    
         
            -
                    dominantBaseline = 'hanging'
         
     | 
| 
       489 
     | 
    
         
            -
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
       490 
     | 
    
         
            -
                    textAnchor = data.fullParams.tickTextRotate
         
     | 
| 
       491 
     | 
    
         
            -
                      ? 'start'
         
     | 
| 
       492 
     | 
    
         
            -
                      : 'middle'
         
     | 
| 
       493 
     | 
    
         
            -
                    dominantBaseline = 'auto'
         
     | 
| 
       494 
     | 
    
         
            -
                  }
         
     | 
| 
       495 
     | 
    
         
            -
                  return {
         
     | 
| 
       496 
     | 
    
         
            -
                    textAnchor,
         
     | 
| 
       497 
     | 
    
         
            -
                    dominantBaseline
         
     | 
| 
       498 
     | 
    
         
            -
                  }
         
     | 
| 
       499 
     | 
    
         
            -
                })
         
     | 
| 
       500 
     | 
    
         
            -
              )
         
     | 
| 
       501 
     | 
    
         
            -
             
     | 
| 
       502 
     | 
    
         
            -
              const axisLabelAlign$: Observable<TextAlign> = fullDataFormatter$.pipe(
         
     | 
| 
       503 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       504 
     | 
    
         
            -
                map(d => {
         
     | 
| 
       505 
     | 
    
         
            -
                  let textAnchor: 'start' | 'middle' | 'end' = 'start'
         
     | 
| 
       506 
     | 
    
         
            -
                  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
         
     | 
| 
       507 
     | 
    
         
            -
             
     | 
| 
       508 
     | 
    
         
            -
                  if (d.grid.groupAxis.position === 'bottom') {
         
     | 
| 
       509 
     | 
    
         
            -
                    dominantBaseline = 'auto'
         
     | 
| 
       510 
     | 
    
         
            -
                  } else if (d.grid.groupAxis.position === 'top') {
         
     | 
| 
       511 
     | 
    
         
            -
                    dominantBaseline = 'hanging'
         
     | 
| 
       512 
     | 
    
         
            -
                  } else if (d.grid.groupAxis.position === 'left') {
         
     | 
| 
       513 
     | 
    
         
            -
                    textAnchor = 'start'
         
     | 
| 
       514 
     | 
    
         
            -
                  } else if (d.grid.groupAxis.position === 'right') {
         
     | 
| 
       515 
     | 
    
         
            -
                    textAnchor = 'end'
         
     | 
| 
       516 
     | 
    
         
            -
                  }
         
     | 
| 
       517 
     | 
    
         
            -
                  if (d.grid.valueAxis.position === 'left') {
         
     | 
| 
       518 
     | 
    
         
            -
                    textAnchor = 'end'
         
     | 
| 
       519 
     | 
    
         
            -
                  } else if (d.grid.valueAxis.position === 'right') {
         
     | 
| 
       520 
     | 
    
         
            -
                    textAnchor = 'start'
         
     | 
| 
       521 
     | 
    
         
            -
                  } else if (d.grid.valueAxis.position === 'bottom') {
         
     | 
| 
       522 
     | 
    
         
            -
                    dominantBaseline = 'hanging'
         
     | 
| 
       523 
     | 
    
         
            -
                  } else if (d.grid.valueAxis.position === 'top') {
         
     | 
| 
       524 
     | 
    
         
            -
                    dominantBaseline = 'auto'
         
     | 
| 
       525 
     | 
    
         
            -
                  }
         
     | 
| 
       526 
     | 
    
         
            -
                  return {
         
     | 
| 
       527 
     | 
    
         
            -
                    textAnchor,
         
     | 
| 
       528 
     | 
    
         
            -
                    dominantBaseline
         
     | 
| 
       529 
     | 
    
         
            -
                  }
         
     | 
| 
       530 
     | 
    
         
            -
                })
         
     | 
| 
       531 
     | 
    
         
            -
              )
         
     | 
| 
       532 
     | 
    
         
            -
              
         
     | 
| 
       533 
     | 
    
         
            -
             
     | 
| 
       534 
     | 
    
         
            -
              combineLatest({
         
     | 
| 
       535 
     | 
    
         
            -
                axisSelection: axisSelection$,
         
     | 
| 
       536 
     | 
    
         
            -
                fullParams: fullParams$,
         
     | 
| 
       537 
     | 
    
         
            -
                tickTextAlign: tickTextAlign$,
         
     | 
| 
       538 
     | 
    
         
            -
                axisLabelAlign: axisLabelAlign$,
         
     | 
| 
       539 
     | 
    
         
            -
                computedData: computedData$,
         
     | 
| 
       540 
     | 
    
         
            -
                gridAxesSize: gridAxesSize$,
         
     | 
| 
       541 
     | 
    
         
            -
                fullDataFormatter: fullDataFormatter$,
         
     | 
| 
       542 
     | 
    
         
            -
                fullChartParams: fullChartParams$,
         
     | 
| 
       543 
     | 
    
         
            -
                valueScale: valueScale$,
         
     | 
| 
       544 
     | 
    
         
            -
                textReverseTransform: textReverseTransform$,
         
     | 
| 
       545 
     | 
    
         
            -
                textReverseTransformWithRotate: textReverseTransformWithRotate$,
         
     | 
| 
       546 
     | 
    
         
            -
                minAndMax: minAndMax$
         
     | 
| 
       547 
     | 
    
         
            -
              }).pipe(
         
     | 
| 
       548 
     | 
    
         
            -
                takeUntil(destroy$),
         
     | 
| 
       549 
     | 
    
         
            -
                switchMap(async (d) => d),
         
     | 
| 
       550 
     | 
    
         
            -
              ).subscribe(data => {
         
     | 
| 
       551 
     | 
    
         
            -
             
     | 
| 
       552 
     | 
    
         
            -
                renderAxis({
         
     | 
| 
       553 
     | 
    
         
            -
                  selection: data.axisSelection,
         
     | 
| 
       554 
     | 
    
         
            -
                  yAxisClassName,
         
     | 
| 
       555 
     | 
    
         
            -
                  fullParams: data.fullParams,
         
     | 
| 
       556 
     | 
    
         
            -
                  tickTextAlign: data.tickTextAlign,
         
     | 
| 
       557 
     | 
    
         
            -
                  gridAxesSize: data.gridAxesSize,
         
     | 
| 
       558 
     | 
    
         
            -
                  fullDataFormatter: data.fullDataFormatter,
         
     | 
| 
       559 
     | 
    
         
            -
                  fullChartParams: data.fullChartParams,
         
     | 
| 
       560 
     | 
    
         
            -
                  valueScale: data.valueScale,
         
     | 
| 
       561 
     | 
    
         
            -
                  textReverseTransformWithRotate: data.textReverseTransformWithRotate,
         
     | 
| 
       562 
     | 
    
         
            -
                  minAndMax: data.minAndMax
         
     | 
| 
       563 
     | 
    
         
            -
                })
         
     | 
| 
       564 
     | 
    
         
            -
             
     | 
| 
       565 
     | 
    
         
            -
                renderAxisLabel({
         
     | 
| 
       566 
     | 
    
         
            -
                  selection: data.axisSelection,
         
     | 
| 
       567 
     | 
    
         
            -
                  textClassName,
         
     | 
| 
       568 
     | 
    
         
            -
                  fullParams: data.fullParams,
         
     | 
| 
       569 
     | 
    
         
            -
                  axisLabelAlign: data.axisLabelAlign,
         
     | 
| 
       570 
     | 
    
         
            -
                  gridAxesSize: data.gridAxesSize,
         
     | 
| 
       571 
     | 
    
         
            -
                  fullDataFormatter: data.fullDataFormatter,
         
     | 
| 
       572 
     | 
    
         
            -
                  fullChartParams: data.fullChartParams,
         
     | 
| 
       573 
     | 
    
         
            -
                  textReverseTransform: data.textReverseTransform,
         
     | 
| 
       574 
     | 
    
         
            -
                })
         
     | 
| 
       575 
     | 
    
         
            -
              })
         
     | 
| 
       576 
     | 
    
         
            -
             
     | 
| 
       577 
     | 
    
         
            -
              return () => {
         
     | 
| 
       578 
     | 
    
         
            -
                destroy$.next(undefined)
         
     | 
| 
       579 
     | 
    
         
            -
              }
         
     | 
| 
       580 
     | 
    
         
            -
            }
         
     | 
| 
      
 1 
     | 
    
         
            +
            import * as d3 from 'd3'
         
     | 
| 
      
 2 
     | 
    
         
            +
            import {
         
     | 
| 
      
 3 
     | 
    
         
            +
              combineLatest,
         
     | 
| 
      
 4 
     | 
    
         
            +
              switchMap,
         
     | 
| 
      
 5 
     | 
    
         
            +
              distinctUntilChanged,
         
     | 
| 
      
 6 
     | 
    
         
            +
              first,
         
     | 
| 
      
 7 
     | 
    
         
            +
              map,
         
     | 
| 
      
 8 
     | 
    
         
            +
              takeUntil,
         
     | 
| 
      
 9 
     | 
    
         
            +
              Observable,
         
     | 
| 
      
 10 
     | 
    
         
            +
              Subject } from 'rxjs'
         
     | 
| 
      
 11 
     | 
    
         
            +
            import { createAxisLinearScale } from '../../lib/core'
         
     | 
| 
      
 12 
     | 
    
         
            +
            import type { BasePluginFn } from './types'
         
     | 
| 
      
 13 
     | 
    
         
            +
            import type {
         
     | 
| 
      
 14 
     | 
    
         
            +
              ComputedDataGrid,
         
     | 
| 
      
 15 
     | 
    
         
            +
              DataFormatterGrid,
         
     | 
| 
      
 16 
     | 
    
         
            +
              ChartParams,
         
     | 
| 
      
 17 
     | 
    
         
            +
              ComputedDatumGrid,
         
     | 
| 
      
 18 
     | 
    
         
            +
              GridContainerPosition,
         
     | 
| 
      
 19 
     | 
    
         
            +
              TransformData,
         
     | 
| 
      
 20 
     | 
    
         
            +
              EventGrid,
         
     | 
| 
      
 21 
     | 
    
         
            +
              ColorType
         
     | 
| 
      
 22 
     | 
    
         
            +
            } from '../../lib/core-types'
         
     | 
| 
      
 23 
     | 
    
         
            +
            import type { BaseValueAxisParams } from '../../lib/plugins-basic-types'
         
     | 
| 
      
 24 
     | 
    
         
            +
            import { parseTickFormatValue } from '../utils/d3Utils'
         
     | 
| 
      
 25 
     | 
    
         
            +
            import { getColor, getMinAndMaxValue, getClassName, getUniID } from '../utils/orbchartsUtils'
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            // export interface BaseValueAxisParams {
         
     | 
| 
      
 28 
     | 
    
         
            +
            //   labelOffset: [number, number]
         
     | 
| 
      
 29 
     | 
    
         
            +
            //   labelColorType: ColorType
         
     | 
| 
      
 30 
     | 
    
         
            +
            //   axisLineVisible: boolean
         
     | 
| 
      
 31 
     | 
    
         
            +
            //   axisLineColorType: ColorType
         
     | 
| 
      
 32 
     | 
    
         
            +
            //   ticks: number
         
     | 
| 
      
 33 
     | 
    
         
            +
            //   tickFormat: string | ((text: d3.NumberValue) => string)
         
     | 
| 
      
 34 
     | 
    
         
            +
            //   tickLineVisible: boolean
         
     | 
| 
      
 35 
     | 
    
         
            +
            //   tickPadding: number
         
     | 
| 
      
 36 
     | 
    
         
            +
            //   tickFullLine: boolean
         
     | 
| 
      
 37 
     | 
    
         
            +
            //   tickFullLineDasharray: string
         
     | 
| 
      
 38 
     | 
    
         
            +
            //   tickColorType: ColorType
         
     | 
| 
      
 39 
     | 
    
         
            +
            //   tickTextRotate: number
         
     | 
| 
      
 40 
     | 
    
         
            +
            //   tickTextColorType: ColorType
         
     | 
| 
      
 41 
     | 
    
         
            +
            // }
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            interface BaseLinesContext {
         
     | 
| 
      
 44 
     | 
    
         
            +
              selection: d3.Selection<any, unknown, any, unknown>
         
     | 
| 
      
 45 
     | 
    
         
            +
              computedData$: Observable<ComputedDataGrid>
         
     | 
| 
      
 46 
     | 
    
         
            +
              fullParams$: Observable<BaseValueAxisParams>
         
     | 
| 
      
 47 
     | 
    
         
            +
              fullDataFormatter$: Observable<DataFormatterGrid>
         
     | 
| 
      
 48 
     | 
    
         
            +
              fullChartParams$: Observable<ChartParams>
         
     | 
| 
      
 49 
     | 
    
         
            +
              gridAxesTransform$: Observable<TransformData>
         
     | 
| 
      
 50 
     | 
    
         
            +
              gridAxesReverseTransform$: Observable<TransformData>
         
     | 
| 
      
 51 
     | 
    
         
            +
              gridAxesSize$: Observable<{
         
     | 
| 
      
 52 
     | 
    
         
            +
                width: number;
         
     | 
| 
      
 53 
     | 
    
         
            +
                height: number;
         
     | 
| 
      
 54 
     | 
    
         
            +
              }>
         
     | 
| 
      
 55 
     | 
    
         
            +
              gridContainerPosition$: Observable<GridContainerPosition[]>
         
     | 
| 
      
 56 
     | 
    
         
            +
              isSeriesSeprate$: Observable<boolean>
         
     | 
| 
      
 57 
     | 
    
         
            +
            }
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            interface TextAlign {
         
     | 
| 
      
 60 
     | 
    
         
            +
              textAnchor: "start" | "middle" | "end"
         
     | 
| 
      
 61 
     | 
    
         
            +
              dominantBaseline: "middle" | "auto" | "hanging"
         
     | 
| 
      
 62 
     | 
    
         
            +
            }
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            // const pluginName = 'ValueAxis'
         
     | 
| 
      
 65 
     | 
    
         
            +
            // const containerClassName = getClassName(pluginName, 'container')
         
     | 
| 
      
 66 
     | 
    
         
            +
            // const yAxisGClassName = getClassName(pluginName, 'yAxisG')
         
     | 
| 
      
 67 
     | 
    
         
            +
            // const yAxisClassName = getClassName(pluginName, 'yAxis')
         
     | 
| 
      
 68 
     | 
    
         
            +
            // const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
      
 69 
     | 
    
         
            +
            const defaultTickSize = 6
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            function renderAxisLabel ({ selection, textClassName, fullParams, axisLabelAlign, gridAxesSize, fullDataFormatter, fullChartParams, textReverseTransform }: {
         
     | 
| 
      
 72 
     | 
    
         
            +
              selection: d3.Selection<SVGGElement, any, any, any>,
         
     | 
| 
      
 73 
     | 
    
         
            +
              textClassName: string
         
     | 
| 
      
 74 
     | 
    
         
            +
              fullParams: BaseValueAxisParams
         
     | 
| 
      
 75 
     | 
    
         
            +
              axisLabelAlign: TextAlign
         
     | 
| 
      
 76 
     | 
    
         
            +
              gridAxesSize: { width: number, height: number }
         
     | 
| 
      
 77 
     | 
    
         
            +
              fullDataFormatter: DataFormatterGrid,
         
     | 
| 
      
 78 
     | 
    
         
            +
              fullChartParams: ChartParams
         
     | 
| 
      
 79 
     | 
    
         
            +
              textReverseTransform: string,
         
     | 
| 
      
 80 
     | 
    
         
            +
            }) {
         
     | 
| 
      
 81 
     | 
    
         
            +
              const offsetX = fullParams.tickPadding - fullParams.labelOffset[0]
         
     | 
| 
      
 82 
     | 
    
         
            +
              const offsetY = fullParams.tickPadding + fullParams.labelOffset[1]
         
     | 
| 
      
 83 
     | 
    
         
            +
              let labelX = 0
         
     | 
| 
      
 84 
     | 
    
         
            +
              let labelY = 0
         
     | 
| 
      
 85 
     | 
    
         
            +
              if (fullDataFormatter.grid.groupAxis.position === 'bottom') {
         
     | 
| 
      
 86 
     | 
    
         
            +
                // labelY = - gridAxesSize.height - offsetY
         
     | 
| 
      
 87 
     | 
    
         
            +
                labelY = - offsetY
         
     | 
| 
      
 88 
     | 
    
         
            +
                if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
      
 89 
     | 
    
         
            +
                  labelX = - offsetX
         
     | 
| 
      
 90 
     | 
    
         
            +
                } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
      
 91 
     | 
    
         
            +
                  labelX = offsetX
         
     | 
| 
      
 92 
     | 
    
         
            +
                }
         
     | 
| 
      
 93 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.groupAxis.position === 'top') {
         
     | 
| 
      
 94 
     | 
    
         
            +
                // labelY = gridAxesSize.height + offsetY
         
     | 
| 
      
 95 
     | 
    
         
            +
                labelY = offsetY
         
     | 
| 
      
 96 
     | 
    
         
            +
                if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
      
 97 
     | 
    
         
            +
                  labelX = - offsetX
         
     | 
| 
      
 98 
     | 
    
         
            +
                } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
      
 99 
     | 
    
         
            +
                  labelX = offsetX
         
     | 
| 
      
 100 
     | 
    
         
            +
                }
         
     | 
| 
      
 101 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.groupAxis.position === 'left') {
         
     | 
| 
      
 102 
     | 
    
         
            +
                // labelX = gridAxesSize.width + offsetX
         
     | 
| 
      
 103 
     | 
    
         
            +
                labelX = offsetX
         
     | 
| 
      
 104 
     | 
    
         
            +
                if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
      
 105 
     | 
    
         
            +
                  labelY = offsetY
         
     | 
| 
      
 106 
     | 
    
         
            +
                } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 107 
     | 
    
         
            +
                  labelY = - offsetY
         
     | 
| 
      
 108 
     | 
    
         
            +
                }
         
     | 
| 
      
 109 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.groupAxis.position === 'right') {
         
     | 
| 
      
 110 
     | 
    
         
            +
                labelX = - offsetX
         
     | 
| 
      
 111 
     | 
    
         
            +
                if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
      
 112 
     | 
    
         
            +
                  labelY = offsetY
         
     | 
| 
      
 113 
     | 
    
         
            +
                } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 114 
     | 
    
         
            +
                  labelY = - offsetY
         
     | 
| 
      
 115 
     | 
    
         
            +
                }
         
     | 
| 
      
 116 
     | 
    
         
            +
              }
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              const axisLabelSelection = selection
         
     | 
| 
      
 119 
     | 
    
         
            +
                .selectAll<SVGGElement, BaseValueAxisParams>(`g.${textClassName}`)
         
     | 
| 
      
 120 
     | 
    
         
            +
                .data([fullParams])
         
     | 
| 
      
 121 
     | 
    
         
            +
                .join('g')
         
     | 
| 
      
 122 
     | 
    
         
            +
                .classed(textClassName, true)
         
     | 
| 
      
 123 
     | 
    
         
            +
                .each((d, i, g) => {
         
     | 
| 
      
 124 
     | 
    
         
            +
                  const text = d3.select(g[i])
         
     | 
| 
      
 125 
     | 
    
         
            +
                    .selectAll<SVGTextElement, BaseValueAxisParams>(`text`)
         
     | 
| 
      
 126 
     | 
    
         
            +
                    .data([d])
         
     | 
| 
      
 127 
     | 
    
         
            +
                    .join(
         
     | 
| 
      
 128 
     | 
    
         
            +
                      enter => {
         
     | 
| 
      
 129 
     | 
    
         
            +
                        return enter
         
     | 
| 
      
 130 
     | 
    
         
            +
                          .append('text')
         
     | 
| 
      
 131 
     | 
    
         
            +
                          .style('font-weight', 'bold')
         
     | 
| 
      
 132 
     | 
    
         
            +
                      },
         
     | 
| 
      
 133 
     | 
    
         
            +
                      update => update,
         
     | 
| 
      
 134 
     | 
    
         
            +
                      exit => exit.remove()
         
     | 
| 
      
 135 
     | 
    
         
            +
                    )
         
     | 
| 
      
 136 
     | 
    
         
            +
                    .attr('text-anchor', axisLabelAlign.textAnchor)
         
     | 
| 
      
 137 
     | 
    
         
            +
                    .attr('dominant-baseline', axisLabelAlign.dominantBaseline)
         
     | 
| 
      
 138 
     | 
    
         
            +
                    .attr('font-size', fullChartParams.styles.textSize)
         
     | 
| 
      
 139 
     | 
    
         
            +
                    .style('fill', getColor(fullParams.labelColorType, fullChartParams))
         
     | 
| 
      
 140 
     | 
    
         
            +
                    .style('transform', textReverseTransform)
         
     | 
| 
      
 141 
     | 
    
         
            +
                    // 偏移使用 x, y 而非 transform 才不會受到外層 scale 變形影響
         
     | 
| 
      
 142 
     | 
    
         
            +
                    .attr('x', labelX)
         
     | 
| 
      
 143 
     | 
    
         
            +
                    .attr('y', labelY)
         
     | 
| 
      
 144 
     | 
    
         
            +
                    .text(d => fullDataFormatter.grid.valueAxis.label)
         
     | 
| 
      
 145 
     | 
    
         
            +
                })
         
     | 
| 
      
 146 
     | 
    
         
            +
                .attr('transform', d => `translate(0, ${gridAxesSize.height})`)
         
     | 
| 
      
 147 
     | 
    
         
            +
                // .attr('transform', d => `translate(${- fullParams.tickPadding + fullParams.labelOffset[0]}, ${gridAxesSize.height + fullParams.tickPadding + fullParams.labelOffset[1]})`)
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
            }
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
            function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gridAxesSize, fullDataFormatter, fullChartParams, valueScale, textReverseTransformWithRotate, minAndMax }: {
         
     | 
| 
      
 153 
     | 
    
         
            +
              selection: d3.Selection<SVGGElement, any, any, any>,
         
     | 
| 
      
 154 
     | 
    
         
            +
              yAxisClassName: string
         
     | 
| 
      
 155 
     | 
    
         
            +
              fullParams: BaseValueAxisParams
         
     | 
| 
      
 156 
     | 
    
         
            +
              tickTextAlign: TextAlign
         
     | 
| 
      
 157 
     | 
    
         
            +
              gridAxesSize: { width: number, height: number }
         
     | 
| 
      
 158 
     | 
    
         
            +
              fullDataFormatter: DataFormatterGrid,
         
     | 
| 
      
 159 
     | 
    
         
            +
              fullChartParams: ChartParams
         
     | 
| 
      
 160 
     | 
    
         
            +
              valueScale: d3.ScaleLinear<number, number>
         
     | 
| 
      
 161 
     | 
    
         
            +
              textReverseTransformWithRotate: string,
         
     | 
| 
      
 162 
     | 
    
         
            +
              minAndMax: [number, number]
         
     | 
| 
      
 163 
     | 
    
         
            +
            }) {
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
              const yAxisSelection = selection
         
     | 
| 
      
 166 
     | 
    
         
            +
                .selectAll<SVGGElement, BaseValueAxisParams>(`g.${yAxisClassName}`)
         
     | 
| 
      
 167 
     | 
    
         
            +
                .data([fullParams])
         
     | 
| 
      
 168 
     | 
    
         
            +
                .join('g')
         
     | 
| 
      
 169 
     | 
    
         
            +
                .classed(yAxisClassName, true)
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
              const valueLength = minAndMax[1] - minAndMax[0]
         
     | 
| 
      
 172 
     | 
    
         
            +
              
         
     | 
| 
      
 173 
     | 
    
         
            +
              // const _valueScale = d3.scaleLinear()
         
     | 
| 
      
 174 
     | 
    
         
            +
              //   .domain([0, 150])
         
     | 
| 
      
 175 
     | 
    
         
            +
              //   .range([416.5, 791.349])
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
              // 刻度文字偏移
         
     | 
| 
      
 178 
     | 
    
         
            +
              let tickPadding = 0
         
     | 
| 
      
 179 
     | 
    
         
            +
              let textY = 0
         
     | 
| 
      
 180 
     | 
    
         
            +
              if (fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
      
 181 
     | 
    
         
            +
                tickPadding = fullParams.tickPadding
         
     | 
| 
      
 182 
     | 
    
         
            +
                textY = 0
         
     | 
| 
      
 183 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
      
 184 
     | 
    
         
            +
                tickPadding = - fullParams.tickPadding
         
     | 
| 
      
 185 
     | 
    
         
            +
                textY = 0
         
     | 
| 
      
 186 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
      
 187 
     | 
    
         
            +
                tickPadding = 0
         
     | 
| 
      
 188 
     | 
    
         
            +
                textY = fullParams.tickPadding
         
     | 
| 
      
 189 
     | 
    
         
            +
              } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 190 
     | 
    
         
            +
                tickPadding = 0
         
     | 
| 
      
 191 
     | 
    
         
            +
                textY = - fullParams.tickPadding
         
     | 
| 
      
 192 
     | 
    
         
            +
              }
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
              // 設定Y軸刻度
         
     | 
| 
      
 195 
     | 
    
         
            +
              const yAxis = d3.axisLeft(valueScale)
         
     | 
| 
      
 196 
     | 
    
         
            +
                .scale(valueScale)
         
     | 
| 
      
 197 
     | 
    
         
            +
                .ticks(valueLength > fullParams.ticks
         
     | 
| 
      
 198 
     | 
    
         
            +
                  ? fullParams.ticks
         
     | 
| 
      
 199 
     | 
    
         
            +
                  : ((minAndMax[0] === 0 && minAndMax[1] === 0)
         
     | 
| 
      
 200 
     | 
    
         
            +
                    ? 1
         
     | 
| 
      
 201 
     | 
    
         
            +
                    : Math.ceil(valueLength))) // 刻度分段數量
         
     | 
| 
      
 202 
     | 
    
         
            +
                .tickFormat(d => parseTickFormatValue(d, fullParams.tickFormat))
         
     | 
| 
      
 203 
     | 
    
         
            +
                .tickSize(fullParams.tickFullLine == true
         
     | 
| 
      
 204 
     | 
    
         
            +
                  ? -gridAxesSize.width
         
     | 
| 
      
 205 
     | 
    
         
            +
                  : defaultTickSize)
         
     | 
| 
      
 206 
     | 
    
         
            +
                .tickPadding(tickPadding)
         
     | 
| 
      
 207 
     | 
    
         
            +
              
         
     | 
| 
      
 208 
     | 
    
         
            +
              const yAxisEl = yAxisSelection
         
     | 
| 
      
 209 
     | 
    
         
            +
                .transition()
         
     | 
| 
      
 210 
     | 
    
         
            +
                .duration(100)
         
     | 
| 
      
 211 
     | 
    
         
            +
                .call(yAxis)
         
     | 
| 
      
 212 
     | 
    
         
            +
              
         
     | 
| 
      
 213 
     | 
    
         
            +
              yAxisEl.selectAll('line')
         
     | 
| 
      
 214 
     | 
    
         
            +
                .style('fill', 'none')
         
     | 
| 
      
 215 
     | 
    
         
            +
                .style('stroke', fullParams.tickLineVisible == true ? getColor(fullParams.tickColorType, fullChartParams) : 'none')
         
     | 
| 
      
 216 
     | 
    
         
            +
                .style('stroke-dasharray', fullParams.tickFullLineDasharray)
         
     | 
| 
      
 217 
     | 
    
         
            +
                .attr('pointer-events', 'none')
         
     | 
| 
      
 218 
     | 
    
         
            +
              
         
     | 
| 
      
 219 
     | 
    
         
            +
              yAxisEl.selectAll('path')
         
     | 
| 
      
 220 
     | 
    
         
            +
                .style('fill', 'none')
         
     | 
| 
      
 221 
     | 
    
         
            +
                // .style('stroke', this.fullParams.axisLineColor!)
         
     | 
| 
      
 222 
     | 
    
         
            +
                .style('stroke', fullParams.axisLineVisible == true ? getColor(fullParams.axisLineColorType, fullChartParams) : 'none')
         
     | 
| 
      
 223 
     | 
    
         
            +
                .style('shape-rendering', 'crispEdges')
         
     | 
| 
      
 224 
     | 
    
         
            +
              
         
     | 
| 
      
 225 
     | 
    
         
            +
              // const yText = yAxisEl.selectAll('text')
         
     | 
| 
      
 226 
     | 
    
         
            +
              const yText = yAxisSelection.selectAll('text')
         
     | 
| 
      
 227 
     | 
    
         
            +
                // .style('font-family', 'sans-serif')
         
     | 
| 
      
 228 
     | 
    
         
            +
                .attr('font-size', fullChartParams.styles.textSize)
         
     | 
| 
      
 229 
     | 
    
         
            +
                .style('color', getColor(fullParams.tickTextColorType, fullChartParams))
         
     | 
| 
      
 230 
     | 
    
         
            +
                .attr('text-anchor', tickTextAlign.textAnchor)
         
     | 
| 
      
 231 
     | 
    
         
            +
                .attr('dominant-baseline', tickTextAlign.dominantBaseline)
         
     | 
| 
      
 232 
     | 
    
         
            +
                // .attr('dy', 0)
         
     | 
| 
      
 233 
     | 
    
         
            +
                .attr('y', textY)
         
     | 
| 
      
 234 
     | 
    
         
            +
              yText.style('transform', textReverseTransformWithRotate)
         
     | 
| 
      
 235 
     | 
    
         
            +
              
         
     | 
| 
      
 236 
     | 
    
         
            +
              // 抵消掉預設的偏移
         
     | 
| 
      
 237 
     | 
    
         
            +
              if (fullDataFormatter.grid.valueAxis.position === 'bottom' || fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 238 
     | 
    
         
            +
                yText.attr('dy', 0)
         
     | 
| 
      
 239 
     | 
    
         
            +
              }
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
              return yAxisSelection
         
     | 
| 
      
 242 
     | 
    
         
            +
            }
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
            export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName: string, {
         
     | 
| 
      
 247 
     | 
    
         
            +
              selection,
         
     | 
| 
      
 248 
     | 
    
         
            +
              computedData$,
         
     | 
| 
      
 249 
     | 
    
         
            +
              fullParams$,
         
     | 
| 
      
 250 
     | 
    
         
            +
              fullDataFormatter$,
         
     | 
| 
      
 251 
     | 
    
         
            +
              fullChartParams$,
         
     | 
| 
      
 252 
     | 
    
         
            +
              gridAxesTransform$,
         
     | 
| 
      
 253 
     | 
    
         
            +
              gridAxesReverseTransform$,
         
     | 
| 
      
 254 
     | 
    
         
            +
              gridAxesSize$,
         
     | 
| 
      
 255 
     | 
    
         
            +
              gridContainerPosition$,
         
     | 
| 
      
 256 
     | 
    
         
            +
              isSeriesSeprate$,
         
     | 
| 
      
 257 
     | 
    
         
            +
            }) => {
         
     | 
| 
      
 258 
     | 
    
         
            +
              
         
     | 
| 
      
 259 
     | 
    
         
            +
              const destroy$ = new Subject()
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
              const containerClassName = getClassName(pluginName, 'container')
         
     | 
| 
      
 262 
     | 
    
         
            +
              const yAxisGClassName = getClassName(pluginName, 'yAxisG')
         
     | 
| 
      
 263 
     | 
    
         
            +
              const yAxisClassName = getClassName(pluginName, 'yAxis')
         
     | 
| 
      
 264 
     | 
    
         
            +
              const textClassName = getClassName(pluginName, 'text')
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
              const containerSelection$ = combineLatest({
         
     | 
| 
      
 267 
     | 
    
         
            +
                computedData: computedData$.pipe(
         
     | 
| 
      
 268 
     | 
    
         
            +
                  distinctUntilChanged((a, b) => {
         
     | 
| 
      
 269 
     | 
    
         
            +
                    // 只有當series的數量改變時,才重新計算
         
     | 
| 
      
 270 
     | 
    
         
            +
                    return a.length === b.length
         
     | 
| 
      
 271 
     | 
    
         
            +
                  }),
         
     | 
| 
      
 272 
     | 
    
         
            +
                ),
         
     | 
| 
      
 273 
     | 
    
         
            +
                isSeriesSeprate: isSeriesSeprate$
         
     | 
| 
      
 274 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 275 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 276 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 277 
     | 
    
         
            +
                map(data => {
         
     | 
| 
      
 278 
     | 
    
         
            +
                  return data.isSeriesSeprate
         
     | 
| 
      
 279 
     | 
    
         
            +
                    // series分開的時候顯示各別axis
         
     | 
| 
      
 280 
     | 
    
         
            +
                    ? data.computedData
         
     | 
| 
      
 281 
     | 
    
         
            +
                    // series合併的時候只顯示第一個axis
         
     | 
| 
      
 282 
     | 
    
         
            +
                    : [data.computedData[0]]
         
     | 
| 
      
 283 
     | 
    
         
            +
                }),
         
     | 
| 
      
 284 
     | 
    
         
            +
                map((computedData, i) => {
         
     | 
| 
      
 285 
     | 
    
         
            +
                  return selection
         
     | 
| 
      
 286 
     | 
    
         
            +
                    .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${containerClassName}`)
         
     | 
| 
      
 287 
     | 
    
         
            +
                    .data(computedData, d => d[0] ? d[0].seriesIndex : i)
         
     | 
| 
      
 288 
     | 
    
         
            +
                    .join('g')
         
     | 
| 
      
 289 
     | 
    
         
            +
                    .classed(containerClassName, true)
         
     | 
| 
      
 290 
     | 
    
         
            +
                })
         
     | 
| 
      
 291 
     | 
    
         
            +
              )
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
              const axisSelection$ = containerSelection$.pipe(
         
     | 
| 
      
 294 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 295 
     | 
    
         
            +
                map((containerSelection, i) => {
         
     | 
| 
      
 296 
     | 
    
         
            +
                  return containerSelection
         
     | 
| 
      
 297 
     | 
    
         
            +
                    .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${yAxisGClassName}`)
         
     | 
| 
      
 298 
     | 
    
         
            +
                    .data([yAxisGClassName])
         
     | 
| 
      
 299 
     | 
    
         
            +
                    .join('g')
         
     | 
| 
      
 300 
     | 
    
         
            +
                    .classed(yAxisGClassName, true)
         
     | 
| 
      
 301 
     | 
    
         
            +
                })
         
     | 
| 
      
 302 
     | 
    
         
            +
              )
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
              combineLatest({
         
     | 
| 
      
 305 
     | 
    
         
            +
                containerSelection: containerSelection$,
         
     | 
| 
      
 306 
     | 
    
         
            +
                gridContainerPosition: gridContainerPosition$
         
     | 
| 
      
 307 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 308 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 309 
     | 
    
         
            +
                switchMap(async d => d)
         
     | 
| 
      
 310 
     | 
    
         
            +
              ).subscribe(data => {
         
     | 
| 
      
 311 
     | 
    
         
            +
                data.containerSelection
         
     | 
| 
      
 312 
     | 
    
         
            +
                  .attr('transform', (d, i) => {
         
     | 
| 
      
 313 
     | 
    
         
            +
                    const gridContainerPosition = data.gridContainerPosition[i] ?? data.gridContainerPosition[0]
         
     | 
| 
      
 314 
     | 
    
         
            +
                    const translate = gridContainerPosition.translate
         
     | 
| 
      
 315 
     | 
    
         
            +
                    const scale = gridContainerPosition.scale
         
     | 
| 
      
 316 
     | 
    
         
            +
                    return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
         
     | 
| 
      
 317 
     | 
    
         
            +
                  })
         
     | 
| 
      
 318 
     | 
    
         
            +
                  // .attr('opacity', 0)
         
     | 
| 
      
 319 
     | 
    
         
            +
                  // .transition()
         
     | 
| 
      
 320 
     | 
    
         
            +
                  // .attr('opacity', 1)
         
     | 
| 
      
 321 
     | 
    
         
            +
              })
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
              combineLatest({
         
     | 
| 
      
 324 
     | 
    
         
            +
                axisSelection: axisSelection$,
         
     | 
| 
      
 325 
     | 
    
         
            +
                gridAxesTransform: gridAxesTransform$,
         
     | 
| 
      
 326 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 327 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 328 
     | 
    
         
            +
                switchMap(async d => d)
         
     | 
| 
      
 329 
     | 
    
         
            +
              ).subscribe(data => {
         
     | 
| 
      
 330 
     | 
    
         
            +
                data.axisSelection
         
     | 
| 
      
 331 
     | 
    
         
            +
                  .style('transform', data.gridAxesTransform.value)
         
     | 
| 
      
 332 
     | 
    
         
            +
                  // .attr('opacity', 0)
         
     | 
| 
      
 333 
     | 
    
         
            +
                  // .transition()
         
     | 
| 
      
 334 
     | 
    
         
            +
                  // .attr('opacity', 1)
         
     | 
| 
      
 335 
     | 
    
         
            +
                  
         
     | 
| 
      
 336 
     | 
    
         
            +
              })
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
              // const gridAxesSize$ = gridAxisSizeObservable({
         
     | 
| 
      
 339 
     | 
    
         
            +
              //   fullDataFormatter$,
         
     | 
| 
      
 340 
     | 
    
         
            +
              //   layout$
         
     | 
| 
      
 341 
     | 
    
         
            +
              // })
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
              // const textReverseTransform$: Observable<string> = new Observable(subscriber => {
         
     | 
| 
      
 344 
     | 
    
         
            +
              //   combineLatest({
         
     | 
| 
      
 345 
     | 
    
         
            +
              //     fullParams: fullParams$,
         
     | 
| 
      
 346 
     | 
    
         
            +
              //     layout: layout$
         
     | 
| 
      
 347 
     | 
    
         
            +
              //   }).pipe(
         
     | 
| 
      
 348 
     | 
    
         
            +
              //     takeUntil(destroy$),
         
     | 
| 
      
 349 
     | 
    
         
            +
              //     // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
         
     | 
| 
      
 350 
     | 
    
         
            +
              //     switchMap(async (d) => d),
         
     | 
| 
      
 351 
     | 
    
         
            +
              //   ).subscribe(data => {
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
              //     const transformData = Object.assign({}, data.layout.content.axesTransformData)
         
     | 
| 
      
 354 
     | 
    
         
            +
             
     | 
| 
      
 355 
     | 
    
         
            +
              //     const value = getAxesTransformValue({
         
     | 
| 
      
 356 
     | 
    
         
            +
              //       translate: [0, 0],
         
     | 
| 
      
 357 
     | 
    
         
            +
              //       scale: [transformData.scale[0] * -1, transformData.scale[1] * -1],
         
     | 
| 
      
 358 
     | 
    
         
            +
              //       rotate: transformData.rotate * -1 + data.fullParams.tickTextRotate,
         
     | 
| 
      
 359 
     | 
    
         
            +
              //       rotateX: transformData.rotateX * -1,
         
     | 
| 
      
 360 
     | 
    
         
            +
              //       rotateY: transformData.rotateY * -1
         
     | 
| 
      
 361 
     | 
    
         
            +
              //     })
         
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
      
 363 
     | 
    
         
            +
              //     subscriber.next(value)
         
     | 
| 
      
 364 
     | 
    
         
            +
              //   })
         
     | 
| 
      
 365 
     | 
    
         
            +
              // })
         
     | 
| 
      
 366 
     | 
    
         
            +
              // const reverseTransform$: Observable<TransformData> = gridAxesTransform$.pipe(
         
     | 
| 
      
 367 
     | 
    
         
            +
              //   takeUntil(destroy$),
         
     | 
| 
      
 368 
     | 
    
         
            +
              //   map(d => {
         
     | 
| 
      
 369 
     | 
    
         
            +
              //     const translate: [number, number] = [d.translate[0] * -1, d.translate[1] * -1]
         
     | 
| 
      
 370 
     | 
    
         
            +
              //     const scale: [number, number] = [d.scale[0] * -1, d.scale[1] * -1]
         
     | 
| 
      
 371 
     | 
    
         
            +
              //     const rotate = d.rotate * -1
         
     | 
| 
      
 372 
     | 
    
         
            +
              //     const rotateX = d.rotateX * -1
         
     | 
| 
      
 373 
     | 
    
         
            +
              //     const rotateY = d.rotateY * -1
         
     | 
| 
      
 374 
     | 
    
         
            +
              //     return {
         
     | 
| 
      
 375 
     | 
    
         
            +
              //       translate,
         
     | 
| 
      
 376 
     | 
    
         
            +
              //       scale,
         
     | 
| 
      
 377 
     | 
    
         
            +
              //       rotate,
         
     | 
| 
      
 378 
     | 
    
         
            +
              //       rotateX,
         
     | 
| 
      
 379 
     | 
    
         
            +
              //       rotateY,
         
     | 
| 
      
 380 
     | 
    
         
            +
              //       value: ''
         
     | 
| 
      
 381 
     | 
    
         
            +
              //     }
         
     | 
| 
      
 382 
     | 
    
         
            +
              //   }),
         
     | 
| 
      
 383 
     | 
    
         
            +
              // )
         
     | 
| 
      
 384 
     | 
    
         
            +
              const textReverseTransform$ = combineLatest({
         
     | 
| 
      
 385 
     | 
    
         
            +
                gridAxesReverseTransform: gridAxesReverseTransform$,
         
     | 
| 
      
 386 
     | 
    
         
            +
                gridContainerPosition: gridContainerPosition$
         
     | 
| 
      
 387 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 388 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 389 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 390 
     | 
    
         
            +
                map(data => {
         
     | 
| 
      
 391 
     | 
    
         
            +
                  // const axisReverseTranslateValue = `translate(${data.gridAxesReverseTransform.translate[0]}px, ${data.gridAxesReverseTransform.translate[1]}px)`
         
     | 
| 
      
 392 
     | 
    
         
            +
                  const axesRotateXYReverseValue = `rotateX(${data.gridAxesReverseTransform.rotateX}deg) rotateY(${data.gridAxesReverseTransform.rotateY}deg)`
         
     | 
| 
      
 393 
     | 
    
         
            +
                  const axesRotateReverseValue = `rotate(${data.gridAxesReverseTransform.rotate}deg)`
         
     | 
| 
      
 394 
     | 
    
         
            +
                  const containerScaleReverseValue = `scale(${1 / data.gridContainerPosition[0].scale[0]}, ${1 / data.gridContainerPosition[0].scale[1]})`
         
     | 
| 
      
 395 
     | 
    
         
            +
                  // 必須按照順序(先抵消外層rotate,再抵消最外層scale)
         
     | 
| 
      
 396 
     | 
    
         
            +
                  return `${axesRotateXYReverseValue} ${axesRotateReverseValue} ${containerScaleReverseValue}`
         
     | 
| 
      
 397 
     | 
    
         
            +
                }),
         
     | 
| 
      
 398 
     | 
    
         
            +
                distinctUntilChanged()
         
     | 
| 
      
 399 
     | 
    
         
            +
              )
         
     | 
| 
      
 400 
     | 
    
         
            +
             
     | 
| 
      
 401 
     | 
    
         
            +
              const textReverseTransformWithRotate$ = combineLatest({
         
     | 
| 
      
 402 
     | 
    
         
            +
                textReverseTransform: textReverseTransform$,
         
     | 
| 
      
 403 
     | 
    
         
            +
                fullParams: fullParams$,
         
     | 
| 
      
 404 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 405 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 406 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 407 
     | 
    
         
            +
                map(data => {
         
     | 
| 
      
 408 
     | 
    
         
            +
                  // 必須按照順序(先抵消外層rotate,再抵消最外層scale,最後再做本身的rotate)
         
     | 
| 
      
 409 
     | 
    
         
            +
                  return `${data.textReverseTransform} rotate(${data.fullParams.tickTextRotate}deg)`
         
     | 
| 
      
 410 
     | 
    
         
            +
                })
         
     | 
| 
      
 411 
     | 
    
         
            +
              )
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
              const minAndMax$: Observable<[number, number]> = new Observable(subscriber => {
         
     | 
| 
      
 414 
     | 
    
         
            +
                combineLatest({
         
     | 
| 
      
 415 
     | 
    
         
            +
                  fullDataFormatter: fullDataFormatter$,
         
     | 
| 
      
 416 
     | 
    
         
            +
                  gridAxesSize: gridAxesSize$,
         
     | 
| 
      
 417 
     | 
    
         
            +
                  computedData: computedData$
         
     | 
| 
      
 418 
     | 
    
         
            +
                }).pipe(
         
     | 
| 
      
 419 
     | 
    
         
            +
                  takeUntil(destroy$),
         
     | 
| 
      
 420 
     | 
    
         
            +
                  switchMap(async (d) => d),
         
     | 
| 
      
 421 
     | 
    
         
            +
                ).subscribe(data => {
         
     | 
| 
      
 422 
     | 
    
         
            +
                  const groupMin = 0
         
     | 
| 
      
 423 
     | 
    
         
            +
                  const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
         
     | 
| 
      
 424 
     | 
    
         
            +
                  // const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
         
     | 
| 
      
 425 
     | 
    
         
            +
                  //   ? groupMin - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
      
 426 
     | 
    
         
            +
                  //   : data.fullDataFormatter.grid.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
      
 427 
     | 
    
         
            +
                  const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] - data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
      
 428 
     | 
    
         
            +
                  const groupScaleDomainMax = data.fullDataFormatter.grid.groupAxis.scaleDomain[1] === 'max'
         
     | 
| 
      
 429 
     | 
    
         
            +
                    ? groupMax + data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
      
 430 
     | 
    
         
            +
                    : data.fullDataFormatter.grid.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.grid.groupAxis.scalePadding
         
     | 
| 
      
 431 
     | 
    
         
            +
                    
         
     | 
| 
      
 432 
     | 
    
         
            +
                  const filteredData = data.computedData.map((d, i) => {
         
     | 
| 
      
 433 
     | 
    
         
            +
                    return d.filter((_d, _i) => {
         
     | 
| 
      
 434 
     | 
    
         
            +
                      return _i >= groupScaleDomainMin && _i <= groupScaleDomainMax
         
     | 
| 
      
 435 
     | 
    
         
            +
                    })
         
     | 
| 
      
 436 
     | 
    
         
            +
                  })
         
     | 
| 
      
 437 
     | 
    
         
            +
                
         
     | 
| 
      
 438 
     | 
    
         
            +
                  const filteredMinAndMax = getMinAndMaxValue(filteredData.flat())
         
     | 
| 
      
 439 
     | 
    
         
            +
                  if (filteredMinAndMax[0] === filteredMinAndMax[1]) {
         
     | 
| 
      
 440 
     | 
    
         
            +
                    filteredMinAndMax[0] = filteredMinAndMax[1] - 1 // 避免最大及最小值相同造成無法計算scale
         
     | 
| 
      
 441 
     | 
    
         
            +
                  }
         
     | 
| 
      
 442 
     | 
    
         
            +
                  subscriber.next(filteredMinAndMax)
         
     | 
| 
      
 443 
     | 
    
         
            +
                })
         
     | 
| 
      
 444 
     | 
    
         
            +
              })
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
              const valueScale$: Observable<d3.ScaleLinear<number, number>> = new Observable(subscriber => {
         
     | 
| 
      
 447 
     | 
    
         
            +
                combineLatest({
         
     | 
| 
      
 448 
     | 
    
         
            +
                  fullDataFormatter: fullDataFormatter$,
         
     | 
| 
      
 449 
     | 
    
         
            +
                  gridAxesSize: gridAxesSize$,
         
     | 
| 
      
 450 
     | 
    
         
            +
                  minAndMax: minAndMax$
         
     | 
| 
      
 451 
     | 
    
         
            +
                }).pipe(
         
     | 
| 
      
 452 
     | 
    
         
            +
                  takeUntil(destroy$),
         
     | 
| 
      
 453 
     | 
    
         
            +
                  switchMap(async (d) => d),
         
     | 
| 
      
 454 
     | 
    
         
            +
                ).subscribe(data => {
         
     | 
| 
      
 455 
     | 
    
         
            +
                
         
     | 
| 
      
 456 
     | 
    
         
            +
                  const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
         
     | 
| 
      
 457 
     | 
    
         
            +
                    maxValue: data.minAndMax[1],
         
     | 
| 
      
 458 
     | 
    
         
            +
                    minValue: data.minAndMax[0],
         
     | 
| 
      
 459 
     | 
    
         
            +
                    axisWidth: data.gridAxesSize.height,
         
     | 
| 
      
 460 
     | 
    
         
            +
                    scaleDomain: data.fullDataFormatter.grid.valueAxis.scaleDomain,
         
     | 
| 
      
 461 
     | 
    
         
            +
                    scaleRange: data.fullDataFormatter.grid.valueAxis.scaleRange
         
     | 
| 
      
 462 
     | 
    
         
            +
                  })
         
     | 
| 
      
 463 
     | 
    
         
            +
             
     | 
| 
      
 464 
     | 
    
         
            +
                  subscriber.next(valueScale)
         
     | 
| 
      
 465 
     | 
    
         
            +
                })
         
     | 
| 
      
 466 
     | 
    
         
            +
              })
         
     | 
| 
      
 467 
     | 
    
         
            +
             
     | 
| 
      
 468 
     | 
    
         
            +
              const tickTextAlign$: Observable<TextAlign> = combineLatest({
         
     | 
| 
      
 469 
     | 
    
         
            +
                fullDataFormatter: fullDataFormatter$,
         
     | 
| 
      
 470 
     | 
    
         
            +
                fullParams: fullParams$
         
     | 
| 
      
 471 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 472 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 473 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 474 
     | 
    
         
            +
                map(data => {
         
     | 
| 
      
 475 
     | 
    
         
            +
                  let textAnchor: 'start' | 'middle' | 'end' = 'start'
         
     | 
| 
      
 476 
     | 
    
         
            +
                  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
         
     | 
| 
      
 477 
     | 
    
         
            +
             
     | 
| 
      
 478 
     | 
    
         
            +
                  if (data.fullDataFormatter.grid.valueAxis.position === 'left') {
         
     | 
| 
      
 479 
     | 
    
         
            +
                    textAnchor = 'end'
         
     | 
| 
      
 480 
     | 
    
         
            +
                    dominantBaseline = 'middle'
         
     | 
| 
      
 481 
     | 
    
         
            +
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'right') {
         
     | 
| 
      
 482 
     | 
    
         
            +
                    textAnchor = 'start'
         
     | 
| 
      
 483 
     | 
    
         
            +
                    dominantBaseline = 'middle'
         
     | 
| 
      
 484 
     | 
    
         
            +
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'bottom') {
         
     | 
| 
      
 485 
     | 
    
         
            +
                    textAnchor = data.fullParams.tickTextRotate
         
     | 
| 
      
 486 
     | 
    
         
            +
                      ? 'end'
         
     | 
| 
      
 487 
     | 
    
         
            +
                      : 'middle'
         
     | 
| 
      
 488 
     | 
    
         
            +
                    dominantBaseline = 'hanging'
         
     | 
| 
      
 489 
     | 
    
         
            +
                  } else if (data.fullDataFormatter.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 490 
     | 
    
         
            +
                    textAnchor = data.fullParams.tickTextRotate
         
     | 
| 
      
 491 
     | 
    
         
            +
                      ? 'start'
         
     | 
| 
      
 492 
     | 
    
         
            +
                      : 'middle'
         
     | 
| 
      
 493 
     | 
    
         
            +
                    dominantBaseline = 'auto'
         
     | 
| 
      
 494 
     | 
    
         
            +
                  }
         
     | 
| 
      
 495 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 496 
     | 
    
         
            +
                    textAnchor,
         
     | 
| 
      
 497 
     | 
    
         
            +
                    dominantBaseline
         
     | 
| 
      
 498 
     | 
    
         
            +
                  }
         
     | 
| 
      
 499 
     | 
    
         
            +
                })
         
     | 
| 
      
 500 
     | 
    
         
            +
              )
         
     | 
| 
      
 501 
     | 
    
         
            +
             
     | 
| 
      
 502 
     | 
    
         
            +
              const axisLabelAlign$: Observable<TextAlign> = fullDataFormatter$.pipe(
         
     | 
| 
      
 503 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 504 
     | 
    
         
            +
                map(d => {
         
     | 
| 
      
 505 
     | 
    
         
            +
                  let textAnchor: 'start' | 'middle' | 'end' = 'start'
         
     | 
| 
      
 506 
     | 
    
         
            +
                  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
         
     | 
| 
      
 507 
     | 
    
         
            +
             
     | 
| 
      
 508 
     | 
    
         
            +
                  if (d.grid.groupAxis.position === 'bottom') {
         
     | 
| 
      
 509 
     | 
    
         
            +
                    dominantBaseline = 'auto'
         
     | 
| 
      
 510 
     | 
    
         
            +
                  } else if (d.grid.groupAxis.position === 'top') {
         
     | 
| 
      
 511 
     | 
    
         
            +
                    dominantBaseline = 'hanging'
         
     | 
| 
      
 512 
     | 
    
         
            +
                  } else if (d.grid.groupAxis.position === 'left') {
         
     | 
| 
      
 513 
     | 
    
         
            +
                    textAnchor = 'start'
         
     | 
| 
      
 514 
     | 
    
         
            +
                  } else if (d.grid.groupAxis.position === 'right') {
         
     | 
| 
      
 515 
     | 
    
         
            +
                    textAnchor = 'end'
         
     | 
| 
      
 516 
     | 
    
         
            +
                  }
         
     | 
| 
      
 517 
     | 
    
         
            +
                  if (d.grid.valueAxis.position === 'left') {
         
     | 
| 
      
 518 
     | 
    
         
            +
                    textAnchor = 'end'
         
     | 
| 
      
 519 
     | 
    
         
            +
                  } else if (d.grid.valueAxis.position === 'right') {
         
     | 
| 
      
 520 
     | 
    
         
            +
                    textAnchor = 'start'
         
     | 
| 
      
 521 
     | 
    
         
            +
                  } else if (d.grid.valueAxis.position === 'bottom') {
         
     | 
| 
      
 522 
     | 
    
         
            +
                    dominantBaseline = 'hanging'
         
     | 
| 
      
 523 
     | 
    
         
            +
                  } else if (d.grid.valueAxis.position === 'top') {
         
     | 
| 
      
 524 
     | 
    
         
            +
                    dominantBaseline = 'auto'
         
     | 
| 
      
 525 
     | 
    
         
            +
                  }
         
     | 
| 
      
 526 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 527 
     | 
    
         
            +
                    textAnchor,
         
     | 
| 
      
 528 
     | 
    
         
            +
                    dominantBaseline
         
     | 
| 
      
 529 
     | 
    
         
            +
                  }
         
     | 
| 
      
 530 
     | 
    
         
            +
                })
         
     | 
| 
      
 531 
     | 
    
         
            +
              )
         
     | 
| 
      
 532 
     | 
    
         
            +
              
         
     | 
| 
      
 533 
     | 
    
         
            +
             
     | 
| 
      
 534 
     | 
    
         
            +
              combineLatest({
         
     | 
| 
      
 535 
     | 
    
         
            +
                axisSelection: axisSelection$,
         
     | 
| 
      
 536 
     | 
    
         
            +
                fullParams: fullParams$,
         
     | 
| 
      
 537 
     | 
    
         
            +
                tickTextAlign: tickTextAlign$,
         
     | 
| 
      
 538 
     | 
    
         
            +
                axisLabelAlign: axisLabelAlign$,
         
     | 
| 
      
 539 
     | 
    
         
            +
                computedData: computedData$,
         
     | 
| 
      
 540 
     | 
    
         
            +
                gridAxesSize: gridAxesSize$,
         
     | 
| 
      
 541 
     | 
    
         
            +
                fullDataFormatter: fullDataFormatter$,
         
     | 
| 
      
 542 
     | 
    
         
            +
                fullChartParams: fullChartParams$,
         
     | 
| 
      
 543 
     | 
    
         
            +
                valueScale: valueScale$,
         
     | 
| 
      
 544 
     | 
    
         
            +
                textReverseTransform: textReverseTransform$,
         
     | 
| 
      
 545 
     | 
    
         
            +
                textReverseTransformWithRotate: textReverseTransformWithRotate$,
         
     | 
| 
      
 546 
     | 
    
         
            +
                minAndMax: minAndMax$
         
     | 
| 
      
 547 
     | 
    
         
            +
              }).pipe(
         
     | 
| 
      
 548 
     | 
    
         
            +
                takeUntil(destroy$),
         
     | 
| 
      
 549 
     | 
    
         
            +
                switchMap(async (d) => d),
         
     | 
| 
      
 550 
     | 
    
         
            +
              ).subscribe(data => {
         
     | 
| 
      
 551 
     | 
    
         
            +
             
     | 
| 
      
 552 
     | 
    
         
            +
                renderAxis({
         
     | 
| 
      
 553 
     | 
    
         
            +
                  selection: data.axisSelection,
         
     | 
| 
      
 554 
     | 
    
         
            +
                  yAxisClassName,
         
     | 
| 
      
 555 
     | 
    
         
            +
                  fullParams: data.fullParams,
         
     | 
| 
      
 556 
     | 
    
         
            +
                  tickTextAlign: data.tickTextAlign,
         
     | 
| 
      
 557 
     | 
    
         
            +
                  gridAxesSize: data.gridAxesSize,
         
     | 
| 
      
 558 
     | 
    
         
            +
                  fullDataFormatter: data.fullDataFormatter,
         
     | 
| 
      
 559 
     | 
    
         
            +
                  fullChartParams: data.fullChartParams,
         
     | 
| 
      
 560 
     | 
    
         
            +
                  valueScale: data.valueScale,
         
     | 
| 
      
 561 
     | 
    
         
            +
                  textReverseTransformWithRotate: data.textReverseTransformWithRotate,
         
     | 
| 
      
 562 
     | 
    
         
            +
                  minAndMax: data.minAndMax
         
     | 
| 
      
 563 
     | 
    
         
            +
                })
         
     | 
| 
      
 564 
     | 
    
         
            +
             
     | 
| 
      
 565 
     | 
    
         
            +
                renderAxisLabel({
         
     | 
| 
      
 566 
     | 
    
         
            +
                  selection: data.axisSelection,
         
     | 
| 
      
 567 
     | 
    
         
            +
                  textClassName,
         
     | 
| 
      
 568 
     | 
    
         
            +
                  fullParams: data.fullParams,
         
     | 
| 
      
 569 
     | 
    
         
            +
                  axisLabelAlign: data.axisLabelAlign,
         
     | 
| 
      
 570 
     | 
    
         
            +
                  gridAxesSize: data.gridAxesSize,
         
     | 
| 
      
 571 
     | 
    
         
            +
                  fullDataFormatter: data.fullDataFormatter,
         
     | 
| 
      
 572 
     | 
    
         
            +
                  fullChartParams: data.fullChartParams,
         
     | 
| 
      
 573 
     | 
    
         
            +
                  textReverseTransform: data.textReverseTransform,
         
     | 
| 
      
 574 
     | 
    
         
            +
                })
         
     | 
| 
      
 575 
     | 
    
         
            +
              })
         
     | 
| 
      
 576 
     | 
    
         
            +
             
     | 
| 
      
 577 
     | 
    
         
            +
              return () => {
         
     | 
| 
      
 578 
     | 
    
         
            +
                destroy$.next(undefined)
         
     | 
| 
      
 579 
     | 
    
         
            +
              }
         
     | 
| 
      
 580 
     | 
    
         
            +
            }
         
     |