Files
lan-manager/web/node_modules/@antv/g6-plugin/lib/timeBar/trend.js
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

119 lines
3.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.LINE_STYLE = exports.AREA_STYLE = void 0;
var _path = require("./path");
var __assign = void 0 && (void 0).__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var LINE_STYLE = exports.LINE_STYLE = {
stroke: '#C5C5C5',
strokeOpacity: 0.85
};
var AREA_STYLE = exports.AREA_STYLE = {
fill: '#CACED4',
opacity: 0.85
};
/**
* 缩略趋势图
*/
var Trend = /** @class */function () {
function Trend(cfg) {
var _a = cfg.x,
x = _a === void 0 ? 0 : _a,
_b = cfg.y,
y = _b === void 0 ? 0 : _b,
_c = cfg.width,
width = _c === void 0 ? 200 : _c,
_d = cfg.height,
height = _d === void 0 ? 26 : _d,
_e = cfg.smooth,
smooth = _e === void 0 ? true : _e,
_f = cfg.isArea,
isArea = _f === void 0 ? false : _f,
_g = cfg.data,
data = _g === void 0 ? [] : _g,
lineStyle = cfg.lineStyle,
areaStyle = cfg.areaStyle,
group = cfg.group,
_h = cfg.interval,
interval = _h === void 0 ? null : _h;
this.group = group;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.data = data;
this.smooth = smooth;
this.isArea = isArea;
this.lineStyle = Object.assign({}, LINE_STYLE, lineStyle);
this.areaStyle = Object.assign({}, AREA_STYLE, areaStyle);
this.intervalConfig = interval;
this.renderLine();
}
/**
* 构造
* @private
*/
Trend.prototype.renderLine = function () {
var _a = this,
x = _a.x,
y = _a.y,
width = _a.width,
height = _a.height,
barWidth = _a.barWidth,
data = _a.data,
smooth = _a.smooth,
isArea = _a.isArea,
lineStyle = _a.lineStyle,
areaStyle = _a.areaStyle;
var trendGroup = this.group.addGroup({
name: 'trend-group'
});
if (data) {
var path = (0, _path.dataToPath)(data, width, height, smooth);
// 线
trendGroup.addShape('path', {
attrs: __assign({
path: path
}, lineStyle),
name: 'trend-line'
});
// 在 line 的基础上,绘制面积图
if (isArea) {
var areaPath = (0, _path.linePathToAreaPath)(path, width, height, data);
trendGroup.addShape('path', {
attrs: __assign({
path: areaPath
}, areaStyle),
name: 'trend-area'
});
}
}
// 绘制柱状图📊
if (this.intervalConfig) {
trendGroup.addShape('path', {
attrs: __assign({
path: (0, _path.dataToRectPath)(this.intervalConfig.data, width, height, this.intervalConfig.style.barWidth)
}, this.intervalConfig.style),
name: 'trend-interval'
});
}
// 统一移动到对应的位置
trendGroup.move(x, y);
};
Trend.prototype.destory = function () {
this.group.destroy();
};
return Trend;
}();
var _default = exports.default = Trend;