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(slider): with annotation #5280

Merged
merged 2 commits into from
Jul 6, 2023
Merged

fix(slider): with annotation #5280

merged 2 commits into from
Jul 6, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Jul 6, 2023

Slider

修复 slider 不能和 annotation 一起使用的问题。

开始使用

下面是一个四象限散点图的例子。

export function countriesAnnotationSliderFilter(): G2Spec {
  return {
    type: 'view',
    theme: 'classic',
    padding: 'auto',
    data: {
      type: 'fetch',
      value: 'data/countries.json',
    },
    children: [
      { type: 'lineX', data: [0] },
      { type: 'lineY', data: [0] },
      {
        type: 'range',
        data: [
          { x: [-25, 0], y: [-30, 0], region: '1' },
          { x: [-25, 0], y: [0, 20], region: '2' },
          { x: [0, 5], y: [-30, 0], region: '2' },
          { x: [0, 5], y: [0, 20], region: '1' },
        ],
        encode: { x: 'x', y: 'y' },
        style: {
          fillOpacity: 0.2,
          fill: (d) => (d.region === '1' ? '#d8d0c0' : '#a3dda1'),
        },
      },
      {
        type: 'point',
        encode: {
          x: 'change in female rate',
          y: 'change in male rate',
          size: 'pop',
          color: 'continent',
          shape: 'point',
        },
        scale: {
          color: {
            range: ['#ffd500', '#82cab2', '#193442', '#d18768', '#7e827a'],
          },
          x: { nice: true },
          y: { nice: true },
          size: { range: [4, 30] },
        },
        legend: { size: false },
        style: { stroke: '#bbb', fillOpacity: 0.8 },
        axis: { x: { title: 'Female' }, y: { title: 'Male' } },
        slider: {
          x: { labelFormatter: (d) => d.toFixed(1) },
          y: { labelFormatter: (d) => d.toFixed(1) },
        },
        tooltip: {
          items: [
            { channel: 'x', valueFormatter: '.1f' },
            { channel: 'y', valueFormatter: '.1f' },
          ],
        },
      },
    ],
  };
}

@hustcc
Copy link
Member

hustcc commented Jul 6, 2023

四象限图,适合加到官网 DEMO 中。

@pearmini pearmini merged commit 9418bdd into v5 Jul 6, 2023
@pearmini pearmini deleted the fix/slider-annotation branch July 6, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants