| 31 | } |
| 32 | |
| 33 | export default class BubbleSeries extends Component { |
| 34 | models: CircleSeriesModels = { series: [] }; |
| 35 | |
| 36 | drawModels!: CircleSeriesModels; |
| 37 | |
| 38 | responders!: CircleResponderModel[]; |
| 39 | |
| 40 | activatedResponders: CircleResponderModel[] = []; |
| 41 | |
| 42 | theme!: Required<BubbleChartSeriesTheme>; |
| 43 | |
| 44 | rect!: Rect; |
| 45 | |
| 46 | maxRadius = -1; |
| 47 | |
| 48 | maxValue = -1; |
| 49 | |
| 50 | initialize() { |
| 51 | this.type = 'series'; |
| 52 | this.name = 'bubble'; |
| 53 | this.eventBus.on('selectSeries', this.selectSeries); |
| 54 | this.eventBus.on('showTooltip', this.showTooltip); |
| 55 | this.eventBus.on('hideTooltip', this.onMouseoutComponent); |
| 56 | } |
| 57 | |
| 58 | initUpdate(delta: number) { |
| 59 | this.drawModels.series.forEach((model, index) => { |
| 60 | model.radius = (this.models.series[index] as CircleModel).radius * delta; |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | render(chartState: ChartState<BaseOptions>) { |
| 65 | const { layout, series, scale, axes, circleLegend, legend, options, theme } = chartState; |
| 66 | const { plot } = layout; |
| 67 | |
| 68 | if (!series.bubble) { |
| 69 | throw new Error(message.noDataError(this.name)); |
| 70 | } |
| 71 | |
| 72 | const { xAxis, yAxis } = axes; |
| 73 | const bubbleData = series.bubble.data; |
| 74 | |
| 75 | this.theme = theme.series.bubble as Required<BubbleChartSeriesTheme>; |
| 76 | this.rect = plot; |
| 77 | this.activeSeriesMap = getActiveSeriesMap(legend); |
| 78 | this.selectable = this.getSelectableOption(options); |
| 79 | |
| 80 | const xAxisTickSize = this.rect.width / xAxis!.tickCount; |
| 81 | const yAxisTickSize = this.rect.height / yAxis!.tickCount; |
| 82 | |
| 83 | this.maxRadius = circleLegend.radius |
| 84 | ? circleLegend.radius |
| 85 | : Math.min(xAxisTickSize, yAxisTickSize); |
| 86 | this.maxValue = getMaxRadius(bubbleData); |
| 87 | |
| 88 | const seriesModel = this.renderBubblePointsModel(bubbleData, scale); |
| 89 | const tooltipModel = this.makeTooltipModel(bubbleData); |
| 90 |
nothing calls this directly
no test coverage detected