/* * Copyright (c) Baidu, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @file chart index */ import {Component} from 'san'; import {componentNameMap} from './constant'; import BarChart from './bar-chart'; import LineChart from './line-chart'; import PieChart from './pie-chart'; import MapChart from './map-chart'; import RadarChart from './radar-chart'; import {ChartProps, ChartMethods, RegisterMapParams} from './interface'; import {ECharts} from 'echarts'; import BaseChart from './base-chart'; export default class Chart extends Component implements ChartMethods { static trimWhitespace = 'all'; static template = ` `; static components = { 'cosd-line-chart': LineChart, 'cosd-bar-chart': BarChart, 'cosd-pie-chart': PieChart, 'cosd-map-chart': MapChart, 'cosd-radar-chart': RadarChart }; static computed = { componentChart(this: Chart) { return componentNameMap[this.data.get('type')]; } }; getEchartsInstance(): ECharts | null { const baseChart = this.ref('base-chart'); return baseChart.chartInstance; }; updateChart() { const baseChart = this.ref('base-chart'); baseChart.updateChart(); } registerMap(...args: RegisterMapParams) { const baseChart = this.ref('base-chart'); baseChart.registerMap(...args); } handleChartRendered() { this.fire('chart-rendered'); } }