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

feat(plugin): add plugin plot for customize #1519

Merged
merged 2 commits into from
Sep 4, 2020
Merged

Conversation

hustcc
Copy link
Member

@hustcc hustcc commented Sep 3, 2020

  • 对于不通用、长尾、领域专业的图表,由开放的形式,由社区开发
  • G2Plot

使用方式 示例:

  • 封装并发布 g2plot-step-line
import { Params, Options } from '@antv/g2plot';

export interface StepLineOption extends Options {
  readonly xField: string;
  readonly yField: string;
  readonly stepType?: 'vh' | 'hv' | 'vhv' | 'hvh';
}

/** 这个方法作为一个包 export 出去 */
export function StepLineAdaptor(params: Params<StepLineOption>): Params<StepLineOption> {
  const { chart, options } = params;
  const { xField, yField, stepType = 'vh', data } = options;

  chart.line().position(`${xField}*${yField}`).shape(stepType);
  chart.data(data);

  return params;
}
  • 使用三方包
import { G2Plot } from '@antv/g2plot';
import { StepLineAdaptor, StepLineOption } from 'g2plot-step-line';

const plot = new G2Plot<StepLineOption>('container', {
  width: 400,
  height: 300,
  appendPadding: 10,
  data,
  xField: 'date',
  yField: 'value',
  stepType: 'hv',
}, StepLineAdaptor);

plot.render();
  • 示例

image

@auto-add-label auto-add-label bot added the enhancement New feature or request label Sep 3, 2020
@hustcc hustcc requested review from visiky and lessmost September 3, 2020 06:21
@lessmost lessmost merged commit 6346fcd into master Sep 4, 2020
@lessmost lessmost deleted the feat-plugin-plot branch September 4, 2020 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR: merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants