UNPKG

@alicloud/cloud-charts

Version:

![](https://img.shields.io/npm/v/@alicloud/cloud-charts?color=%23ff8200)

181 lines (169 loc) 4.08 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.isEmptyData = isEmptyData; exports.processEmptyData = processEmptyData; exports.EmptyDataProcess = void 0; var _data = require("./data"); var _index = _interopRequireDefault(require("../themes/index")); /** 空数据处理的三种类型 */ var EmptyDataProcess; /** 根据数据量判断是否是空数据 */ exports.EmptyDataProcess = EmptyDataProcess; (function (EmptyDataProcess) { EmptyDataProcess[EmptyDataProcess["Axis"] = 0] = "Axis"; EmptyDataProcess[EmptyDataProcess["Polar"] = 1] = "Polar"; EmptyDataProcess[EmptyDataProcess["Background"] = 2] = "Background"; })(EmptyDataProcess || (exports.EmptyDataProcess = EmptyDataProcess = {})); function isEmptyData(dataSize) { return dataSize === 0; } /** 根据空数据处理类型、数据结构类型进行空数据处理,个别图表需要特殊处理 */ function processEmptyData(emptyType, dataType, chartName) { if (emptyType === EmptyDataProcess.Axis) { return { data: [], config: { xAxis: { min: 0, max: 100, label: false }, yAxis: { min: 0, max: 100, label: false }, padding: 0 } }; } else if (emptyType === EmptyDataProcess.Polar) { if (chartName === 'G2Radar') { // 雷达图特殊处理 return { data: [{ x: 'a', y: 0 }, { x: 'b', y: 0 }, { x: 'c', y: 0 }, { x: 'd', y: 0 }, { x: 'e', y: 0 }, { x: 'f', y: 0 }], config: { xAxis: { label: false }, yAxis: { min: 0, max: 100, label: false }, legend: false, tooltip: false, colors: _index["default"]['widgets-color-layout-background'] } }; } else if (dataType === _data.DataStructure.Common) { return { data: [{ x: 'a', y: 100 }], config: { legend: false, tooltip: false, colors: _index["default"]['widgets-color-layout-background'], label: false } }; } else if (dataType === _data.DataStructure.Tree) { return { data: { children: [{ name: 'root', value: 100 }] }, config: { legend: false, tooltip: false, colors: _index["default"]['widgets-color-layout-background'], label: false } }; } } else { if (dataType === _data.DataStructure.Common) { // 分箱图特殊处理 if (chartName === 'G2Rectangle') { return { data: [{ x: 0, y: 0 }], config: { padding: 0, xAxis: false, yAxis: false, tooltip: false, legend: false } }; } return { data: [], config: { padding: 0, xAxis: false, yAxis: false, tooltip: false, legend: false } }; } else if (dataType === _data.DataStructure.Tree) { return { data: { name: '', children: [] }, config: { padding: 0, xAxis: false, yAxis: false, tooltip: false, legend: false, colors: _index["default"]['widgets-color-layout-background'] } }; } else if (dataType === _data.DataStructure.Graph) { return { data: { nodes: [], links: [] }, config: { padding: 0, xAxis: false, yAxis: false, tooltip: false, legend: false } }; } } return { data: null, config: null }; }