Skip to content

Commit bb28e15

Browse files
committed
fix: attrs update
fixes: #1392
1 parent 34050b2 commit bb28e15

File tree

42 files changed

+3133
-3649
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3133
-3649
lines changed

__tests__/plots/circle-packing.spec.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { mount } from '@vue/test-utils'
2-
import CirclePackingChart, {
3-
CirclePackingChartProps,
4-
} from '../../src/plots/circle-packing'
2+
import CirclePackingChart, { CirclePackingChartProps } from '../../src/plots/circle-packing'
53
import data from './circle-packing-data.json'
64

75
const config: CirclePackingChartProps = {

__tests__/plots/stock.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const data = [
1515
const config = {
1616
width: 400,
1717
height: 500,
18-
data: data,
18+
data,
1919
xField: 'x',
2020
yField: ['low', 'q1', 'median', 'q3', 'high'],
2121
boxStyle: {

package-lock.json

+3,069-3,487
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
},
6464
"homepage": "https://github.com/open-data-plan/g2plot-vue#readme",
6565
"devDependencies": {
66-
"@antv/g2": "^5.1.0",
67-
"@antv/g2plot": "^2.3.13",
66+
"@antv/g2plot": "^2.4.31",
6867
"@babel/cli": "^7.12.1",
6968
"@babel/preset-typescript": "^7.12.1",
7069
"@commitlint/cli": "^18.0.0",
@@ -79,6 +78,7 @@
7978
"@vue/babel-preset-jsx": "^1.3.0",
8079
"@vue/composition-api": "^1.7.0",
8180
"@vue/test-utils": "^2.0.0-beta.7",
81+
"@vue/tsconfig": "^0.5.1",
8282
"canvas": "^2.6.1",
8383
"conventional-changelog-cli": "^4.0.0",
8484
"cross-env": "^7.0.2",

src/components/base.tsx

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { defineComponent, Ref } from 'vue-demi'
21
import { Plot as BasePlot } from '@antv/g2plot'
3-
import isEqual from 'lodash/isEqual'
42
import isEmpty from 'lodash/isEmpty'
3+
import isEqual from 'lodash/isEqual'
54
import { HTMLAttributes } from 'vue'
5+
import { defineComponent, Ref } from 'vue-demi'
66

77
interface Options {
88
[x: string]: any
@@ -16,8 +16,7 @@ type PickedAttrs = 'class' | 'style'
1616

1717
type Data = Record<string, any>[] | Record<string, any>
1818

19-
export interface BaseChartProps<C extends Options>
20-
extends Pick<HTMLAttributes, PickedAttrs> {
19+
export interface BaseChartProps<C extends Options> extends Pick<HTMLAttributes, PickedAttrs> {
2120
chart: any
2221
data: Data
2322
chartRef?: Ref<BasePlot<C> | null>
@@ -34,16 +33,12 @@ export interface BaseChartRawBindings<C extends Options> {
3433
plot: BasePlot<C>
3534
}
3635

37-
const BaseChart = defineComponent<
38-
BaseChartProps<any>,
39-
BaseChartRawBindings<any>,
40-
ComputedOptions<any>
41-
>({
36+
const BaseChart = defineComponent<BaseChartProps<any>, BaseChartRawBindings<any>, ComputedOptions<any>>({
4237
inheritAttrs: false,
4338
name: 'BaseChart',
4439
computed: {
4540
attrConfig() {
46-
return this.$attrs
41+
return { ...this.$attrs }
4742
},
4843
chartData() {
4944
const { data } = this.attrConfig
@@ -65,8 +60,7 @@ const BaseChart = defineComponent<
6560
},
6661
},
6762
mounted() {
68-
const chartRef = this.$attrs
69-
.chartRef as unknown as Ref<BasePlot<any> | null>
63+
const chartRef = this.$attrs.chartRef as unknown as Ref<BasePlot<any> | null>
7064
const { chart: Chart, onReady } = this.attrConfig
7165
const plot = new Chart(this.$el as HTMLElement, {
7266
data: this.chartData,

src/plots/area/index.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { App, defineComponent } from 'vue-demi'
21
import { Area, AreaOptions } from '@antv/g2plot'
2+
import { App, defineComponent } from 'vue-demi'
33
import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type AreaChartProps = Writeable<
8-
Omit<BaseChartProps<AreaOptions>, 'chart' | 'data'> & AreaOptions
9-
>
7+
export type AreaChartProps = Writeable<Omit<BaseChartProps<AreaOptions>, 'chart' | 'data'> & AreaOptions>
108

119
const AreaChart = defineComponent<AreaChartProps>({
1210
name: 'AreaChart',

src/plots/bar/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type BarChartProps = Writeable<
8-
Omit<BaseChartProps<BarOptions>, 'chart' | 'data'> & BarOptions
9-
>
7+
export type BarChartProps = Writeable<Omit<BaseChartProps<BarOptions>, 'chart' | 'data'> & BarOptions>
108

119
const BarChart = defineComponent<BarChartProps>({
1210
name: 'BarChart',

src/plots/bidirectional-bar/index.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

77
export type BidirectionalBarChartProps = Writeable<
8-
Omit<BaseChartProps<BidirectionalBarOptions>, 'chart' | 'data'> &
9-
BidirectionalBarOptions
8+
Omit<BaseChartProps<BidirectionalBarOptions>, 'chart' | 'data'> & BidirectionalBarOptions
109
>
1110

1211
const BidirectionalBarChart = defineComponent<BidirectionalBarChartProps>({
1312
name: 'BidirectionalBarChart',
1413
setup: (props, ctx) => {
15-
return () => (
16-
<BaseChart chart={BidirectionalBar} {...mergeAttrs(props, ctx.attrs)} />
17-
)
14+
return () => <BaseChart chart={BidirectionalBar} {...mergeAttrs(props, ctx.attrs)} />
1815
},
1916
})
2017

src/plots/box/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type BoxChartProps = Writeable<
8-
Omit<BaseChartProps<BoxOptions>, 'chart' | 'data'> & BoxOptions
9-
>
7+
export type BoxChartProps = Writeable<Omit<BaseChartProps<BoxOptions>, 'chart' | 'data'> & BoxOptions>
108

119
const BoxChart = defineComponent<BoxChartProps>({
1210
name: 'BoxChart',

src/plots/bullet/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type BulletChartProps = Writeable<
8-
Omit<BaseChartProps<BulletOptions>, 'chart' | 'data'> & BulletOptions
9-
>
7+
export type BulletChartProps = Writeable<Omit<BaseChartProps<BulletOptions>, 'chart' | 'data'> & BulletOptions>
108

119
const BulletChart = defineComponent<BulletChartProps>({
1210
name: 'BulletChart',

src/plots/chord/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type ChordChartProps = Writeable<
8-
Omit<BaseChartProps<ChordOptions>, 'chart' | 'data'> & ChordOptions
9-
>
7+
export type ChordChartProps = Writeable<Omit<BaseChartProps<ChordOptions>, 'chart' | 'data'> & ChordOptions>
108

119
const ChordChart = defineComponent<ChordChartProps>({
1210
name: 'ChordChart',

src/plots/circle-packing/index.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

77
export type CirclePackingChartProps = Writeable<
8-
Omit<BaseChartProps<CirclePackingOptions>, 'chart' | 'data'> &
9-
CirclePackingOptions
8+
Omit<BaseChartProps<CirclePackingOptions>, 'chart' | 'data'> & CirclePackingOptions
109
>
1110

1211
const CirclePackingChart = defineComponent<CirclePackingChartProps>({
1312
name: 'CirclePackingChart',
1413
setup(props, ctx) {
15-
return () => (
16-
<BaseChart chart={CirclePacking} {...mergeAttrs(props, ctx.attrs)} />
17-
)
14+
return () => <BaseChart chart={CirclePacking} {...mergeAttrs(props, ctx.attrs)} />
1815
},
1916
})
2017

src/plots/column/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type ColumnChartProps = Writeable<
8-
Omit<BaseChartProps<ColumnOptions>, 'chart' | 'data'> & ColumnOptions
9-
>
7+
export type ColumnChartProps = Writeable<Omit<BaseChartProps<ColumnOptions>, 'chart' | 'data'> & ColumnOptions>
108

119
const ColumnChart = defineComponent<ColumnChartProps>({
1210
name: 'ColumnChart',

src/plots/dual-axes/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type DualAxesChartProps = Writeable<
8-
Omit<BaseChartProps<DualAxesOptions>, 'chart' | 'data'> & DualAxesOptions
9-
>
7+
export type DualAxesChartProps = Writeable<Omit<BaseChartProps<DualAxesOptions>, 'chart' | 'data'> & DualAxesOptions>
108

119
const DualAxesChart = defineComponent<DualAxesChartProps>({
1210
name: 'DualAxesChart',
1311
setup: (props, ctx) => {
14-
return () => (
15-
<BaseChart chart={DualAxes} {...mergeAttrs(props, ctx.attrs)} />
16-
)
12+
return () => <BaseChart chart={DualAxes} {...mergeAttrs(props, ctx.attrs)} />
1713
},
1814
})
1915

src/plots/facet/index.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { App, defineComponent } from 'vue-demi'
21
import { Facet, FacetOptions } from '@antv/g2plot'
2+
import { App, defineComponent } from 'vue-demi'
33
import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type FacetChartProps = Writeable<
8-
Omit<BaseChartProps<FacetOptions>, 'chart' | 'data'> & FacetOptions
9-
>
7+
export type FacetChartProps = Writeable<Omit<BaseChartProps<FacetOptions>, 'chart' | 'data'> & FacetOptions>
108

119
const FacetChart = defineComponent<FacetChartProps>({
1210
name: 'FacetChart',

src/plots/funnel/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type FunnelChartProps = Writeable<
8-
Omit<BaseChartProps<FunnelOptions>, 'chart' | 'data'> & FunnelOptions
9-
>
7+
export type FunnelChartProps = Writeable<Omit<BaseChartProps<FunnelOptions>, 'chart' | 'data'> & FunnelOptions>
108

119
const FunnelChart = defineComponent<FunnelChartProps>({
1210
name: 'FunnelChart',

src/plots/gauge/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type GaugeChartProps = Writeable<
8-
Omit<BaseChartProps<GaugeOptions>, 'chart' | 'data'> & GaugeOptions
9-
>
7+
export type GaugeChartProps = Writeable<Omit<BaseChartProps<GaugeOptions>, 'chart' | 'data'> & GaugeOptions>
108

119
const GaugeChart = defineComponent<GaugeChartProps>({
1210
name: 'GaugeChart',

src/plots/heatmap/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type HeatmapChartProps = Writeable<
8-
Omit<BaseChartProps<HeatmapOptions>, 'chart' | 'data'> & HeatmapOptions
9-
>
7+
export type HeatmapChartProps = Writeable<Omit<BaseChartProps<HeatmapOptions>, 'chart' | 'data'> & HeatmapOptions>
108

119
const HeatmapChart = defineComponent<HeatmapChartProps>({
1210
name: 'HeatmapChart',

src/plots/histogram/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type HistogramChartProps = Writeable<
8-
Omit<BaseChartProps<HistogramOptions>, 'chart' | 'data'> & HistogramOptions
9-
>
7+
export type HistogramChartProps = Writeable<Omit<BaseChartProps<HistogramOptions>, 'chart' | 'data'> & HistogramOptions>
108

119
const HistogramChart = defineComponent<HistogramChartProps>({
1210
name: 'HistogramChart',
1311
setup: (props, ctx) => {
14-
return () => (
15-
<BaseChart chart={Histogram} {...mergeAttrs(props, ctx.attrs)} />
16-
)
12+
return () => <BaseChart chart={Histogram} {...mergeAttrs(props, ctx.attrs)} />
1713
},
1814
})
1915

src/plots/line/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type LineChartProps = Writeable<
8-
Omit<BaseChartProps<LineOptions>, 'chart' | 'data'> & LineOptions
9-
>
7+
export type LineChartProps = Writeable<Omit<BaseChartProps<LineOptions>, 'chart' | 'data'> & LineOptions>
108

119
const LineChart = defineComponent<LineChartProps>({
1210
name: 'LineChart',

src/plots/liquid/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type LiquidChartProps = Writeable<
8-
Omit<BaseChartProps<LiquidOptions>, 'chart' | 'data'> & LiquidOptions
9-
>
7+
export type LiquidChartProps = Writeable<Omit<BaseChartProps<LiquidOptions>, 'chart' | 'data'> & LiquidOptions>
108

119
const LiquidChart = defineComponent<LiquidChartProps>({
1210
name: 'LiquidChart',

src/plots/mix/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type MixChartProps = Writeable<
8-
Omit<BaseChartProps<MixOptions>, 'chart' | 'data'> & MixOptions
9-
>
7+
export type MixChartProps = Writeable<Omit<BaseChartProps<MixOptions>, 'chart' | 'data'> & MixOptions>
108

119
const MixChart = defineComponent<MixChartProps>({
1210
name: 'MixChart',

src/plots/multi-view/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type MultiViewChartProps = Writeable<
8-
Omit<BaseChartProps<MixOptions>, 'chart' | 'data'> & MixOptions
9-
>
7+
export type MultiViewChartProps = Writeable<Omit<BaseChartProps<MixOptions>, 'chart' | 'data'> & MixOptions>
108

119
/**
1210
* @deprecated use `MixChart` instead

src/plots/pie/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type PieChartProps = Writeable<
8-
Omit<BaseChartProps<PieOptions>, 'chart' | 'data'> & PieOptions
9-
>
7+
export type PieChartProps = Writeable<Omit<BaseChartProps<PieOptions>, 'chart' | 'data'> & PieOptions>
108

119
const PieChart = defineComponent<PieChartProps>({
1210
name: 'PieChart',

src/plots/progress/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type ProgressChartProps = Writeable<
8-
Omit<BaseChartProps<ProgressOptions>, 'chart' | 'data'> & ProgressOptions
9-
>
7+
export type ProgressChartProps = Writeable<Omit<BaseChartProps<ProgressOptions>, 'chart' | 'data'> & ProgressOptions>
108

119
const ProgressChart = defineComponent<ProgressChartProps>({
1210
name: 'ProgressChart',
1311
setup: (props, ctx) => {
14-
return () => (
15-
<BaseChart chart={Progress} {...mergeAttrs(props, ctx.attrs)} />
16-
)
12+
return () => <BaseChart chart={Progress} {...mergeAttrs(props, ctx.attrs)} />
1713
},
1814
})
1915

src/plots/radar/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type RadarChartProps = Writeable<
8-
Omit<BaseChartProps<RadarOptions>, 'chart' | 'data'> & RadarOptions
9-
>
7+
export type RadarChartProps = Writeable<Omit<BaseChartProps<RadarOptions>, 'chart' | 'data'> & RadarOptions>
108

119
const RadarChart = defineComponent<RadarChartProps>({
1210
name: 'RadarChart',

src/plots/radial-bar/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import BaseChart, { BaseChartProps } from '../../components/base'
44
import { Writeable } from '../../types'
55
import { mergeAttrs } from '../../utils'
66

7-
export type RadialBarChartProps = Writeable<
8-
Omit<BaseChartProps<RadialBarOptions>, 'chart' | 'data'> & RadialBarOptions
9-
>
7+
export type RadialBarChartProps = Writeable<Omit<BaseChartProps<RadialBarOptions>, 'chart' | 'data'> & RadialBarOptions>
108

119
const RadialBarChart = defineComponent<RadialBarChartProps>({
1210
name: 'RadialBarChart',
1311
setup: (props, ctx) => {
14-
return () => (
15-
<BaseChart chart={RadialBar} {...mergeAttrs(props, ctx.attrs)} />
16-
)
12+
return () => <BaseChart chart={RadialBar} {...mergeAttrs(props, ctx.attrs)} />
1713
},
1814
})
1915

0 commit comments

Comments
 (0)