antvis/G2

Breaking Change (5.0.0-beta.10) #4657

pearmini posted onGitHub

Breaking Change (5.0.0-beta.10)

There are some breaking changes for 5.0.0-beta.10.

node.interaction

Change Interaction from array prop to object prop.(https://github.com/antvis/G2/pull/4628)

// Before
chart.interaction({ type: 'tooltip', series: true });

// After
chart.interaction('tooltip', { series: true });

node.coordinate

Change coordinate from array prop to object prop. (https://github.com/antvis/G2/pull/4637)

// Before
chart.coordinate({ type: 'polar' }).coordinate({ type: 'transpose' });

// After
chart.coordinate({ type: 'polar', transform: [{ type: 'transpose' }] });

node.state

Specify the state of elements by mark.state API rather than in the chart.interaction.(https://github.com/antvis/G2/pull/4649)

// Before
chart.interaction({ type: 'elementHighlight', highlightedFill: 'red' });

// After
chart.interval().state('active', { fill: 'red' }).interaction('elementHighlight', true);

mark.label.style

Specify style props supported by G element through label.style.(https://github.com/antvis/G2/pull/4639)

// Before
chart.interval().data(data).label({
  text: 'hello',
  formatter: '~s',
  fill: 'red',
  stroke: 'blue',
});

// After
chart
  .interval()
  .data(data)
  .label({
    text: 'hello',
    formatter: '~s',
    style: {
      // Style props supported by G.
      fill: 'red',
      stroke: 'blue',
    },
  });

放到 release 的描述中吧。

posted by hustcc about 2 years ago

放到 release 的描述中吧。

嗯嗯,我在 release 里面引用了这个 issue 的。

posted by pearmini about 2 years ago

what happened to functions like getEngine, registerInteraction etc? I wanna upgrade from v4.1.32 to v5 beta12, but all these functions are gone and I can't find any info to this.

posted by clmz about 2 years ago
  • getEngine currently changes to chart.getContext().canvas, and the returned canvas is an instance of G Canvas.
  • register* APIs are in the experimental stage and are not recommended to use. The related abilities for customizing will be ready in 5.1.0, released at the end of April. If you want to customize interaction, you can add event listeners as follows for a temporal solution.
const chart = new Chart();

// ....

const { canvas } = chart.getContext().canvas;
const elements = canvas.document.getElementsByClassName('element');
elements[0].addEventListener('click', () => {});

So for 4.0 users, the best time to upgrade is after releasing 5.1.0. Sorry for the inconvenience caused to you, we'll provide detailed upgrade docs and optimize API docs as soon as possible.

posted by pearmini about 2 years ago

@pearmini Thank you! Is there already a forecast when this will happen?

posted by clmz about 2 years ago

Fund this Issue

$0.00
Funded

Pull requests