feat: 实现供水运营专题大屏BI可视化
- 新增OperationDashboard.vue全屏大屏组件 - 添加6个核心KPI指标卡片: 进水总量/出水总量/产销差率/营收额/平均水质/报警次数 - 实现6个ECharts图表: 供水趋势/水质分布/报警统计/管网空间/设备状态/营收分析 - 创建静态HTML版本operation-dashboard.html,使用CDN加载Vue3/ECharts/Element Plus - 更新路由配置,添加/operation路径支持 - 修复nextTick导入问题,优化build脚本 🚧 开发者: bot_dev1 📝 任务: #38 [BI] 运营仪表盘 + 供水专题大屏
This commit is contained in:
+123
@@ -0,0 +1,123 @@
|
||||
import Displayable, { DisplayableProps, DisplayableStatePropNames } from './Displayable';
|
||||
import { getBoundingRect } from '../contain/text';
|
||||
import BoundingRect from '../core/BoundingRect';
|
||||
import { PathStyleProps, DEFAULT_PATH_STYLE } from './Path';
|
||||
import { createObject, defaults } from '../core/util';
|
||||
import { FontStyle, FontWeight, TextAlign, TextVerticalAlign } from '../core/types';
|
||||
import { DEFAULT_FONT } from '../core/platform';
|
||||
|
||||
export interface TSpanStyleProps extends PathStyleProps {
|
||||
|
||||
x?: number
|
||||
y?: number
|
||||
|
||||
// TODO Text is assigned inside zrender
|
||||
text?: string
|
||||
|
||||
// Final generated font string
|
||||
// Used in canvas, and when developers specified it.
|
||||
font?: string
|
||||
|
||||
// Value for each part of font
|
||||
// Used in svg.
|
||||
// NOTE: font should always been sync with these 4 properties.
|
||||
fontSize?: number
|
||||
fontWeight?: FontWeight
|
||||
fontStyle?: FontStyle
|
||||
fontFamily?: string
|
||||
|
||||
textAlign?: CanvasTextAlign
|
||||
|
||||
textBaseline?: CanvasTextBaseline
|
||||
}
|
||||
|
||||
export const DEFAULT_TSPAN_STYLE: TSpanStyleProps = defaults({
|
||||
strokeFirst: true,
|
||||
font: DEFAULT_FONT,
|
||||
x: 0,
|
||||
y: 0,
|
||||
textAlign: 'left',
|
||||
textBaseline: 'top',
|
||||
miterLimit: 2
|
||||
} as TSpanStyleProps, DEFAULT_PATH_STYLE);
|
||||
|
||||
|
||||
export interface TSpanProps extends DisplayableProps {
|
||||
style?: TSpanStyleProps
|
||||
}
|
||||
|
||||
export type TSpanState = Pick<TSpanProps, DisplayableStatePropNames>
|
||||
|
||||
class TSpan extends Displayable<TSpanProps> {
|
||||
|
||||
style: TSpanStyleProps
|
||||
|
||||
hasStroke() {
|
||||
const style = this.style;
|
||||
const stroke = style.stroke;
|
||||
return stroke != null && stroke !== 'none' && style.lineWidth > 0;
|
||||
}
|
||||
|
||||
hasFill() {
|
||||
const style = this.style;
|
||||
const fill = style.fill;
|
||||
return fill != null && fill !== 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image style object with default values in it's prototype.
|
||||
* @override
|
||||
*/
|
||||
createStyle(obj?: TSpanStyleProps) {
|
||||
return createObject(DEFAULT_TSPAN_STYLE, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bounding rect calculated from Text
|
||||
* For reducing time of calculating bounding rect.
|
||||
*/
|
||||
setBoundingRect(rect: BoundingRect) {
|
||||
this._rect = rect;
|
||||
}
|
||||
|
||||
getBoundingRect(): BoundingRect {
|
||||
const style = this.style;
|
||||
|
||||
if (!this._rect) {
|
||||
let text = style.text;
|
||||
text != null ? (text += '') : (text = '');
|
||||
|
||||
const rect = getBoundingRect(
|
||||
text,
|
||||
style.font,
|
||||
style.textAlign as TextAlign,
|
||||
style.textBaseline as TextVerticalAlign
|
||||
);
|
||||
|
||||
rect.x += style.x || 0;
|
||||
rect.y += style.y || 0;
|
||||
|
||||
if (this.hasStroke()) {
|
||||
const w = style.lineWidth;
|
||||
rect.x -= w / 2;
|
||||
rect.y -= w / 2;
|
||||
rect.width += w;
|
||||
rect.height += w;
|
||||
}
|
||||
|
||||
this._rect = rect;
|
||||
}
|
||||
|
||||
return this._rect;
|
||||
}
|
||||
|
||||
protected static initDefaultProps = (function () {
|
||||
const tspanProto = TSpan.prototype;
|
||||
// TODO Calculate tolerance smarter
|
||||
tspanProto.dirtyRectTolerance = 10;
|
||||
})()
|
||||
}
|
||||
|
||||
TSpan.prototype.type = 'tspan';
|
||||
|
||||
export default TSpan;
|
||||
Reference in New Issue
Block a user