@orbcharts/core 3.0.0-alpha.52 → 3.0.0-alpha.54

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- declare const _default: import('vite').UserConfig & Promise<import('vite').UserConfig> & (import('vite').UserConfigFnObject & import('vite').UserConfigExport);
1
+ declare const _default: import('vite').UserConfigFnObject;
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/core",
3
- "version": "3.0.0-alpha.52",
3
+ "version": "3.0.0-alpha.54",
4
4
  "description": "OrbCharts is an open source chart library based on d3.js and rx.js",
5
5
  "author": "Blue Planet Inc.",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  "types": "./dist/src/index.d.ts",
26
26
  "scripts": {
27
27
  "test": "echo \"Error: no test specified\" && exit 1",
28
- "build": "vite build --mode release"
28
+ "build": "vite build --mode production"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/d3": "^7.4.0",
@@ -1,7 +1,8 @@
1
1
  import {
2
+ map,
2
3
  shareReplay } from 'rxjs'
3
4
  import type { ContextObserverFn } from '../types'
4
- import { multiGridEachDetailObservable } from './multiGridObservables'
5
+ import { multiGridEachDetailObservable, multiGridContainerObservable } from './multiGridObservables'
5
6
  import { textSizePxObservable } from '../utils/observables'
6
7
 
7
8
  export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({ subject, observer }) => {
@@ -20,12 +21,11 @@ export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({
20
21
  shareReplay(1)
21
22
  )
22
23
 
23
- // const multiGridContainer$ = multiGridContainerObservable({
24
- // computedData$: observer.computedData$,
25
- // fullDataFormatter$: observer.fullDataFormatter$,
26
- // fullChartParams$: observer.fullChartParams$,
27
- // layout$: observer.layout$,
28
- // })
24
+ const multiGridContainerPosition$ = multiGridContainerObservable({
25
+ computedData$: observer.computedData$,
26
+ fullDataFormatter$: observer.fullDataFormatter$,
27
+ layout$: observer.layout$,
28
+ })
29
29
 
30
30
  return {
31
31
  fullParams$: observer.fullParams$,
@@ -34,6 +34,7 @@ export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({
34
34
  computedData$: observer.computedData$,
35
35
  layout$: observer.layout$,
36
36
  textSizePx$,
37
+ multiGridContainerPosition$,
37
38
  multiGridEachDetail$,
38
39
  // multiGridContainer$
39
40
  }
@@ -315,6 +315,7 @@ export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$
315
315
  }
316
316
  return seriesContainerArr
317
317
  })
318
+ console.log('gridContainerPositionArr', gridContainerPositionArr)
318
319
 
319
320
  // let accGridSlotIndex = 0
320
321
 
@@ -2,10 +2,11 @@ import { Observable } from 'rxjs'
2
2
  import type { ContextObserverBase } from './ContextObserver'
3
3
  import type { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid'
4
4
  import type { DataFormatterGrid } from './DataFormatterGrid'
5
- import type { ContextObserverGridDetail } from './ContextObserverGrid'
5
+ import type { GridContainerPosition, ContextObserverGridDetail } from './ContextObserverGrid'
6
6
 
7
7
  export interface ContextObserverMultiGrid<PluginParams> extends ContextObserverBase<'multiGrid', PluginParams> {
8
8
  textSizePx$: Observable<number>
9
+ multiGridContainerPosition$: Observable<GridContainerPosition[][]>
9
10
  multiGridEachDetail$: Observable<ContextObserverMultiGridDetail[]>
10
11
  }
11
12
 
@@ -65,13 +65,12 @@ export const createAxisPointScale = ({ axisLabels, axisWidth, padding = 0.5 }: {
65
65
  }
66
66
 
67
67
  // scaleQuantize - 比例尺座標對應非連續資料索引
68
- export const createAxisQuantizeScale = ({ axisLabels, axisWidth, padding = 0.5, reverse = false }:{
68
+ export const createAxisQuantizeScale = ({ axisLabels, axisWidth, padding = 0, reverse = false }:{
69
69
  axisLabels: string[] | Date[],
70
70
  axisWidth: number
71
71
  padding?: number
72
72
  reverse?: boolean
73
73
  }) => {
74
- const rangePadding = 0
75
74
 
76
75
  let range: number[] = axisLabels.map((d: string | Date, i: number) => i)
77
76
  if (reverse) {
@@ -82,8 +81,12 @@ export const createAxisQuantizeScale = ({ axisLabels, axisWidth, padding = 0.5,
82
81
  // } else {
83
82
  // range = axisLabels.map((d: string | Date, i: number) => i)
84
83
  // }
84
+ const step = range.length - 1 + (padding * 2) // 圖軸刻度分段數量
85
+ const stepWidth = axisWidth / step
86
+ const rangePadding = stepWidth * padding - (stepWidth * 0.5) // 實際要計算的範圍是圖軸左右那邊增加0.5
85
87
 
88
+ // console.log('rangePadding', rangePadding)
86
89
  return d3.scaleQuantize<number>()
87
- .domain([- rangePadding, axisWidth + rangePadding])
90
+ .domain([rangePadding, axisWidth - rangePadding])
88
91
  .range(range)
89
92
  }
package/vite.config.js CHANGED
@@ -1,45 +1,23 @@
1
- // import { fileURLToPath, URL } from 'node:url'
2
-
3
- // import { resolve } from 'path'
4
1
  import { defineConfig } from 'vite'
5
2
  import dts from 'vite-plugin-dts'
6
3
 
7
- const releaseConfig = {
8
- plugins: [
9
- dts({
10
- insertTypesEntry: true
11
- })
12
- ],
13
- compilerOptions: {
14
- composite: true
15
- },
16
- build: {
17
- lib: {
18
- entry: "src/index.ts",
19
- name: 'orbcharts-core',
20
- formats: ["es", "umd"],
21
- fileName: format => `orbcharts-core.${format}.js`
22
- },
23
- // rollupOptions: {
24
- // input: {
25
- // main: resolve(__dirname, "src/index.ts")
26
- // },
27
- // external: ['vue'],
28
- // output: {
29
- // assetFileNames: 'my-library.css',
30
- // exports: "named",
31
- // globals: {
32
- // vue: 'Vue',
33
- // },
34
- // },
35
- // },
36
- }
37
- }
38
-
39
4
  export default defineConfig(({ command, mode }) => {
40
- if (mode === 'release') {
41
- return releaseConfig
42
- } else {
43
- return releaseConfig
5
+ return {
6
+ plugins: [
7
+ dts({
8
+ insertTypesEntry: true
9
+ })
10
+ ],
11
+ compilerOptions: {
12
+ composite: true
13
+ },
14
+ build: {
15
+ lib: {
16
+ entry: "src/index.ts",
17
+ name: 'orbcharts-core',
18
+ formats: ["es", "umd"],
19
+ fileName: format => `orbcharts-core.${format}.js`
20
+ },
21
+ }
44
22
  }
45
23
  })