VisActor / VisActor/VChart

[Feature] axes support 'sameDomain' for different axes

Open
#4,134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.8k
Forks
221
Avg merge
1d 6h
Merged PRs (30d)
26

Description

What problem does this feature solve?
Image

问题: 在实现双向条形图的时候,发现想要左右轴保持刻度完全同步,除了写死min,max 没有其他的方案,希望可以提供一个 'sameTick' 配置

const spec = {
  type: 'common',
  title: {
    id: 'title',
    visible: true,
    text: 'Congo Population Pyramid 2021',
  },
  layout: {
    type: 'grid',
    col: 3,
    row: 4,
    elements: [
      { modelId: 'title', col: 0, row: 0, colSpan: 3 },

      { modelId: 'legend', col: 0, row: 3, colSpan: 3 },

      { modelId: 'yAxis', col: 1, row: 1 },
      { modelId: 'leftRegion', col: 0, row: 1 },
      { modelId: 'leftXAxis', col: 0, row: 2 },

      { modelId: 'rightRegion', col: 2, row: 1 },
      { modelId: 'rightXAxis', col: 2, row: 2 }
    ]
  },
  region: [{ id: 'leftRegion' }, { id: 'rightRegion' }],
  legends: [
    {
      visible: true,
      orient: 'bottom',
      id: 'legend',
      interactive: false
    }
  ],
  series: [
    {
      id: 'male',
      regionId: 'leftRegion',
      type: 'bar',
      data: {
        id: 'maleData',
        values: [
          {
            age: '0-4',
            type: 'Male',
            population: 232671,
          },
          {
            age: '5-9',
            type: 'Male',
            population: 118331,
          }
        ]
      },
      direction: 'horizontal',
      xField: 'population',
      yField: 'age',
    },
    {
      id: 'female',
      regionId: 'rightRegion',
      type: 'bar',
      data: {
        id: 'femaleData',
        values: [
          {
            age: '0-4',
            type: 'Female',
            population: 424322
          },
          {
            age: '5-9',
            type: 'Female',
            population: 410397
          }
        ]
      },
      direction: 'horizontal',
      xField: 'population',
      yField: 'age',
    }
  ],
  axes: [
    {
      id: 'yAxis',
      regionId: ['leftRegion', 'rightRegion'],
      orient: 'left',
      type: 'band',
      grid: { visible: false }
    },
    {
      id: 'leftXAxis',
      regionId: 'leftRegion',
      seriesId: ['female', 'male'],
      orient: 'bottom',
      type: 'linear',
      inverse: true,
    },
    {
      id: 'rightXAxis',
      regionId: 'rightRegion',
      seriesId: ['female', 'male'],
      orient: 'bottom',
      type: 'linear',
      sync: {
        axisId: 'leftXAxis',
        zeroAlign: true,
        tickAlign: true
      }
    }
  ]
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;
What does the proposed API look like?

轴的 sync 新增配置

{
    keepSame?: boolean
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the axis sync configuration in the supplied dual-axis population-pyramid example, then inspect the existing zeroAlign and tickAlign behavior. Determine how the proposed sync.keepSame option should preserve the same domain or ticks across axes, and verify the result using the example configuration. No implementation files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.