UNPKG

@antv/g2

Version:

the Grammar of Graphics in Javascript

34 lines (30 loc) 851 B
import { GuideComponentComponent as GCC } from '../runtime'; import { scaleOf } from './utils'; import { LegendContinuous, LegendContinuousOptions } from './legendContinuous'; export type LegendContinuousSizeOptions = LegendContinuousOptions; export const LegendContinuousSize: GCC<LegendContinuousSizeOptions> = ( options, ) => { return (context) => { const { scales } = context; const sizeScale = scaleOf(scales, 'size'); return LegendContinuous( Object.assign( {}, { type: 'size', data: sizeScale.getTicks().map((value, index) => ({ value, label: String(value), })), }, options, ), )(context); }; }; LegendContinuousSize.props = { ...LegendContinuous.props, defaultPosition: 'top', defaultOrientation: 'horizontal', };