@dfsj/echarts
Version:
专业的水文曲线组件或构造函数以及通用的echart二次封装图表
47 lines (43 loc) • 2.74 kB
JavaScript
/**
*
* @dfsj/echarts: 专业的水文曲线组件或构造函数以及通用的echart二次封装图表
* 版本: v3.7.0-alpha.5
* 作者:yangbo <1747837358@qq.com>
* 日期:2025-11-21 13:30:34
*
*
*/
import { to, min, max, sum, avg } from './tools.js';
import { CATEGORY } from '../config.js';
function statistics(chart, value) {
var _options$dataset$, _source$start, _source$end;
var dimensions = value === null || value === void 0 ? void 0 : value.dimensions;
var options = chart === null || chart === void 0 ? void 0 : chart.getOption();
var source = options === null || options === void 0 || (_options$dataset$ = options.dataset[0]) === null || _options$dataset$ === void 0 ? void 0 : _options$dataset$.source;
var zoom = options === null || options === void 0 ? void 0 : options.dataZoom[0],
start = zoom.startValue,
end = zoom.endValue;
var rows = options === null || options === void 0 ? void 0 : options.series.filter(function (e) {
return options.legend[0].selected[e.name] !== false && e.type !== 'mark';
}).map(function (e) {
var index = e.encode.y;
var rainfall = !!(dimensions[index].code & CATEGORY.RAINFALL);
var min$1 = to(min(source, index, start, end));
var max$1 = to(max(source, index, start, end));
var sum$1 = to(rainfall && sum(source, index, start, end));
var avg$1 = to(avg(source, index, start, end));
return "<tr><td>".concat(e.name, "</td><td>").concat(min$1, "</td><td>").concat(max$1, "</td><td>").concat(avg$1, "</td><td>").concat(sum$1, "</td></tr>");
}).join('');
return "<div class=\"time\">".concat(source === null || source === void 0 || (_source$start = source[start]) === null || _source$start === void 0 ? void 0 : _source$start[0], " ~ ").concat(source === null || source === void 0 || (_source$end = source[end]) === null || _source$end === void 0 ? void 0 : _source$end[0], "</div>\n <table>\n <thead>\n <tr>\n <th>\u7C7B\u76EE</th>\n <th>\u6700\u5C0F\u503C</th>\n <th>\u6700\u5927\u503C</th>\n <th>\u5E73\u5747\u503C</th>\n <th>\u7D2F\u8BA1\u503C</th>\n </tr>\n </thead>\n <tbody>\n ").concat(rows, " \n </tbody>\n </table>");
}
function dimensions(chart, value) {
var _value$dimensions;
return value === null || value === void 0 || (_value$dimensions = value.dimensions) === null || _value$dimensions === void 0 ? void 0 : _value$dimensions.map(function (e, i) {
return {
label: typeof e === 'string' ? e : e.name,
field: i,
selected: e.selected
};
});
}
export { dimensions, statistics };