UNPKG

@xiaomengqiang/charts

Version:

hcharts library for web visualization

108 lines (106 loc) 4.55 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import cloneDeep from '../../util/cloneDeep.js'; import BaseOption from './BaseOption.js'; import { setTooltip, setLegend } from './handleOption.js'; import { handleColor } from './handleColor.js'; import { handleRootData } from './handleRootData.js'; import { handleVirtualLengend } from './handleVirtualLengend.js'; import { handleSeriesData } from './handleSeriesData.js'; import { legendDisappear, legendShow } from './legendSelectChanged.js'; import { event } from '../../util/event.js'; import init from '../../option/init/index.js'; import { isArray } from '../../util/type.js'; import { CHART_TYPE } from '../../util/constants.js'; /** * Copyright (c) 2024 - present OpenTiny HUICharts Authors. * Copyright (c) 2024 - present Huawei Cloud Computing Technologies Co., Ltd. * * Use of this source code is governed by an MIT-style license. * * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. * */ var AssembleBubbleChart = /*#__PURE__*/function () { function AssembleBubbleChart(iChartOption, chartInstance, plugins) { this.baseOption = cloneDeep(BaseOption); this.iChartOption = init(iChartOption); this.chartInstance = chartInstance; this.plugins = plugins; this.updateOption(chartInstance); // 配置图表事件 event(chartInstance, this.iChartOption.event); } var _proto = AssembleBubbleChart.prototype; _proto.updateOption = function updateOption(chartInstance) { var _this$baseOption$seri; var d3 = this.plugins.d3; if (!d3) throw new Error('您必须安装d3才可以使用聚合气泡图'); if (!isArray(this.iChartOption.color)) { this.iChartOption.color = [this.iChartOption.color]; } var _this$iChartOption = this.iChartOption, color = _this$iChartOption.color, type = _this$iChartOption.type; this.baseOption.color = color; this.baseOption.tooltip = setTooltip(this.iChartOption); this.baseOption.legend = setLegend(this.iChartOption); var _handleSeriesData = handleSeriesData(this.iChartOption, this.baseOption), depthFirst = _handleSeriesData.depthFirst, depthMore = _handleSeriesData.depthMore; handleColor({ depthFirst: depthFirst, depthMore: depthMore, color: color, type: type }, this.baseOption); // 给BaseOption设置虚拟图例 (_this$baseOption$seri = this.baseOption.series).unshift.apply(_this$baseOption$seri, handleVirtualLengend(this.baseOption.legend.data)); handleRootData({ d3: d3, baseOption: this.baseOption, chartInstance: chartInstance, iChartOption: this.iChartOption }); var baseOption = this.baseOption; chartInstance.on('legendselectchanged', function (params) { if (!params.selected[params.name]) { // 点击图例消失 legendDisappear({ seriesData: baseOption.dataset[0].source, params: params, type: type, baseOption: baseOption, chartInstance: chartInstance }); } else { handleColor({ depthFirst: depthFirst, depthMore: depthMore, color: color, type: type }, baseOption); // 点击图例出现 legendShow({ seriesData: baseOption.dataset[0].source, type: type, params: params, baseOption: baseOption, chartInstance: chartInstance }); } }); }; _proto.getOption = function getOption() { return this.baseOption; }; _proto.setOption = function setOption(option) { this.baseOption = option; }; return AssembleBubbleChart; }(); _defineProperty(AssembleBubbleChart, "name", CHART_TYPE.ASSEMBLE_BUBBLE); export { AssembleBubbleChart as default };