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

[Bug] updateSpec not work with only data change #912

Closed
xiaoluoHe opened this issue Sep 12, 2023 · 0 comments
Closed

[Bug] updateSpec not work with only data change #912

xiaoluoHe opened this issue Sep 12, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@xiaoluoHe
Copy link
Contributor

Version

1.3.0

Link to Minimal Reproduction

none

Steps to Reproduce

import { isMobile } from 'react-device-detect';
import type { IHistogramChartSpec } from '../../../../src/index';
// eslint-disable-next-line no-duplicate-imports
import { default as VChart } from '../../../../src/index';

const run = () => {
  const values = [
    {
      label: '200',
      value: 92
    },
    {
      label: '502',
      value: 8
    }
  ];
  const spec = {
    color: ['#207BFE', '#00CEFF', '#FC7703', '#5BCF78', '#2F4DE0', '#94D8FF', '#F5C040', '#39608C'],
    padding: 0,
    data: [
      {
        values: [
          // {
          //     "label": "200",
          //     "value": 92
          // },
          // {
          //     "label": "502",
          //     "value": 8
          // }
        ]
      }
    ],
    categoryField: 'label',
    valueField: 'value',
    outerRadius: 0.9,
    innerRadius: 0.76,
    pie: {
      state: {
        hover: {
          outerRadius: 0.92
        }
      }
    },
    legends: {
      visible: true,
      orient: 'right',
      hover: false,
      padding: [2, 0, 0, 30],
      item: {
        width: 236,
        shape: {
          space: 4,
          style: {
            size: 8
          }
        },
        label: {
          style: {
            maxLineWidth: 162,
            fill: '#42464E'
          }
        },
        value: {
          alignRight: true,
          style: {
            lineWidth: '20%',
            fontSize: '12px',
            fill: '#42464E'
          }
        }
      }
    },
    tooltip: {
      mark: {
        content: [{}]
      }
    },
    type: 'pie',
    region: [{}],
    series: [
      {
        data: {
          values: [
            // {
            //     "label": "200",
            //     "value": 92
            // },
            // {
            //     "label": "502",
            //     "value": 8
            // }
          ]
        },
        animationThreshold: 2000,
        outerRadius: 0.9,
        innerRadius: 0.76,
        type: 'pie',
        pie: {
          state: {
            hover: {
              outerRadius: 0.92
            }
          }
        },
        categoryField: 'label',
        valueField: 'value'
      }
    ]
  };

  const cs2 = new VChart(spec, {
    dom: document.getElementById('chart') as HTMLElement,
    mode: isMobile ? 'mobile-browser' : 'desktop-browser'
  });
  cs2.renderAsync();

  // 不能正确更新
  setTimeout(() => {
    console.log('updateSpec 1');
    spec.data[0].values = values;
    spec.series[0].data.values = values;
    cs2.updateSpec(spec);
  }, 1000);

  // 可以正确更新
  // setTimeout(() => {
  //   console.log('updateSpec 2');
  //   delete spec.data;
  //   spec.series[0].data.values = values;
  //   cs2.updateSpec(spec);
  // }, 4000);
};
run();

Current Behavior

数据未正确更新

Expected Behavior

数据更新

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants