Skip to content

Fix/231 bug after updatedata did not call global scale update domain #232

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: add global-scale updateDomain on chart updateData\n\n",
"type": "patch",
"packageName": "@visactor/lark-vchart"
}
],
"packageName": "@visactor/lark-vchart",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: add global-scale updateDomain on chart updateData\n\n",
"type": "patch",
"packageName": "@visactor/react-vchart"
}
],
"packageName": "@visactor/react-vchart",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: add global-scale updateDomain on chart updateData\n\n",
"type": "patch",
"packageName": "@visactor/taro-vchart"
}
],
"packageName": "@visactor/taro-vchart",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: add global-scale updateDomain on chart updateData\n\n",
"type": "patch",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix(global-scale): add global-scale updateDomain on chart updateData",
"type": "patch"
}
],
"packageName": "@visactor/vchart"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix(data): add miss params of data.parse in chart updateData",
"type": "patch"
}
],
"packageName": "@visactor/vchart"
}
7 changes: 5 additions & 2 deletions packages/vchart/src/chart/base-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,13 @@ export class BaseChart extends CompilableBase implements IChart {
}
}

updateData(id: StringOrNumber, data: unknown, options?: IParserOptions) {
updateData(id: StringOrNumber, data: unknown, updateGlobalScale: boolean = true, options?: IParserOptions) {
const dv = this._dataSet.getDataView(id as string);
if (dv) {
dv.parseNewData(data);
dv.parseNewData(data, options);
}
if (updateGlobalScale) {
this.updateGlobalScaleDomain();
}
this.getAllModels().forEach(model => model.onDataUpdate());
}
Expand Down
5 changes: 3 additions & 2 deletions packages/vchart/src/chart/interface/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export interface IChart extends ICompilable {
// 使用parse后的数据结构,直接更新数据
updateParseData: (id: string, data: Datum[], options?: IParserOptions) => void;
// 使用parse前的原始数据结构更新数据
updateData: (id: StringOrNumber, data: unknown, options?: IParserOptions) => void;

updateData: (id: StringOrNumber, data: unknown, updateGlobalScale?: boolean, options?: IParserOptions) => void;
// update scale domain which in GlobalScale
updateGlobalScaleDomain: () => void;
//生命周期
created: () => void;
transformSpec: (spec: any) => void;
Expand Down
7 changes: 4 additions & 3 deletions packages/vchart/src/core/vchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export class VChart implements IVChart {
return this as unknown as IVChart;
}
if (this._chart) {
this._chart.updateData(id, data, options);
this._chart.updateData(id, data, true, options);

// after layout
await this._compiler.renderAsync();
Expand Down Expand Up @@ -548,8 +548,9 @@ export class VChart implements IVChart {
): Promise<IVChart> {
if (this._chart) {
list.forEach(({ id, data, options }) => {
this._chart.updateData(id, data, options);
this._chart.updateData(id, data, false, options);
});
this._chart.updateGlobalScaleDomain();
await this._compiler.renderAsync();
return this as unknown as IVChart;
}
Expand Down Expand Up @@ -578,7 +579,7 @@ export class VChart implements IVChart {
return this as unknown as IVChart;
}
if (this._chart) {
this._chart.updateData(id, data, options);
this._chart.updateData(id, data, true, options);
// after layout
this._compiler.renderSync();
return this as unknown as IVChart;
Expand Down