Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: liquid data is not in object form antvis #6145 #6379

Merged
merged 13 commits into from
Jul 23, 2024
2 changes: 1 addition & 1 deletion site/docs/spec/mark/liquid.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const chart = new Chart({

chart
.liquid()
.data({value:.3})
.data(0.3)
.style({
outlineBorder: 4,
outlineDistance: 8,
Expand Down
2 changes: 1 addition & 1 deletion site/examples/general/Liquid/demo/liquid-background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chart = new Chart({
autoFit: true,
});

chart.liquid().data({ value: 0.3 }).style({
chart.liquid().data(0.3).style({
backgroundFill: 'pink',
});

Expand Down
2 changes: 1 addition & 1 deletion site/examples/general/Liquid/demo/liquid-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chart = new Chart({
autoFit: true,
});

chart.liquid().data({ value: 0.581 }).style({
chart.liquid().data(0.581).style({
contentFill: '#000',
contentText: 'center text',
contentStroke: '#fff',
Expand Down
2 changes: 1 addition & 1 deletion site/examples/general/Liquid/demo/liquid-custom-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const chart = new Chart({

chart
.liquid()
.data({ value: 0.3 })
.data(0.3)
.style({
shape: (x, y, r) => {
const path = [];
Expand Down
2 changes: 1 addition & 1 deletion site/examples/general/Liquid/demo/liquid-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chart = new Chart({
autoFit: true,
});

chart.liquid().data({ value: 0.3 }).style({
chart.liquid().data(0.3).style({
outlineBorder: 4,
outlineDistance: 8,
waveLength: 128,
Expand Down
2 changes: 1 addition & 1 deletion site/examples/general/Liquid/demo/liquid-pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chart = new Chart({
autoFit: true,
});

chart.liquid().data({ value: 0.581 }).style({
chart.liquid().data(0.581).style({
shape: 'pin', // Build-in shapes: rect, circle, pin, diamond, triangle.
contentFill: '#fff',
outlineBorder: 4,
Expand Down
5 changes: 3 additions & 2 deletions src/composition/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepMix } from '@antv/util';
import { deepMix, isNumber } from '@antv/util';

type Adapter<T> = (options: T, ...rest: any[]) => T;

Expand All @@ -17,11 +17,12 @@ export function useOverrideAdaptor<T>(adaptor: Adapter<T>): Adapter<T> {
}

export function mergeData(
dataDescriptor: any[] | { value: any; [key: string]: any },
dataDescriptor: any[] | { value: any; [key: string]: any } | number,
dataValue: any[],
) {
if (!dataDescriptor) return dataValue;
if (Array.isArray(dataDescriptor)) return dataDescriptor;
if (isNumber(dataDescriptor)) return dataDescriptor;
const { value = dataValue, ...rest } = dataDescriptor;
pearmini marked this conversation as resolved.
Show resolved Hide resolved
return { ...rest, value };
}
Loading