import _ from 'lodash'; // 坐标轴图表类型 export const AXIS_CHART_TYPES = ['line', 'bar', 'scatter', 'effectScatter']; /** * 推断图表类型是否为坐标轴类图表 * * @param {Object} option 图表配置项 * @returns Boolean: true坐标轴类图表, false 非坐标轴类图表 */ export const isAxisChart = (option) => { const { series: origin } = option; const series = Array.isArray(origin) ? origin : _.isObject(origin) ? [origin] : []; return !series.some((item) => AXIS_CHART_TYPES.indexOf(item.type) === -1); }; export const isLineType = (series) => series.type === 'line'; export const isBarType = (series) => series.type === 'bar';