SVG文件格式
4.3.3 SVG文件格式
Section titled “4.3.3 SVG文件格式”以下为SVG内部片段,放入带xmlns="http://www.w3.org/2000/svg"的<svg>根元素后使用。每个元素的id在同一张图中应唯一,先验证XML可解析,再验证测点和交互。
<tspan id="path1" displayType='measure' pointNumber="1001" measureUnit="kW" measureRound="2"> ...</tspan>pointNumber填写已配置的测点号,measureUnit是显示在数值后的单位文字,measureRound
控制小数位数(默认2)。不显示单位时也显式写measureUnit="",避免缺少属性。量测值与单位会替换标签内部内容;本例显示点1001的值并保留两位小数。
<g id="g1" pointNumber="1001" displayType="enum"> <g id="g1-1" enumValue="0" > ... </g> <g id="g1-2" enumValue="1,2" display="none" > ... </g></g>- 只枚举
displayType="enum"标签下的第一层子标签 enumValue="1,2"表示闭区间1≤值≤2;离散多个值写1;2,多个值或区间之间用英文分号分隔。- 一般需要手动设置其他内容
display="none",以保证初始状态显示正常
<path id="path1" pointNumber="1001" displayType="current" currentType="triangle" currentReverse="0" currentWidth="10" currentDur="4" currentNum="3" currentBegin="0.15" currentRepeat="3" currentColor="#1e4e8c" arrowPid="1002" arrowValue="0;1" arrowColor="#1e4e8c;red" style="fill:none;stroke:#00ffff;stroke-width:20px" d="M 958.51083,348.58552 H 1005.389 V 719.1 H 958.51083" />| 属性 | 含义与默认值 |
|---|---|
pointNumber | 关联的量测点号,量测正负决定动画方向 |
currentType | 图形类型,triangle为三角形,point为实心圆;须显式填写 |
currentReverse | 默认0;填1时反转正负量测对应的动画方向 |
currentWidth | 动画图形宽度,单位px;省略时为路径线宽的1.5倍 |
currentDur | 跑完整条路径的时间,单位秒,默认4 |
currentNum | 每组图形数量,默认1 |
currentBegin | 组内相邻图形出发的时间差,单位秒,默认0.15 |
currentRepeat | 同时出现的图形组数,默认1 |
currentColor | 固定颜色,默认green |
arrowPid | 用于改变动画颜色的测点号 |
arrowValue/arrowColor | 匹配值与颜色列表,用;分隔并一一对应 |
-
只支持
path标签 -
电流方向
currentReverse=0时,电流值 > 0 正向,< 0 反向(通过翻转180°实现),= 0 时隐藏动画图形 -
节点类型
triangle:三角形
point:实心圆
-
如果节点颜色不需要跟随测点值变化,则不需要配置
arrowPid、arrowValue和arrowColor这几个属性
<rect id="rect1" width="180" height="70" displayType="breathe" pointNumber="1001" breatheValue="1;0" breatheColor="#ffff00;blue" style="fill:#4b6188;stroke-width:5" />pointNumber选择量测点;breatheValue是触发呼吸效果的值,默认1,breatheColor为对应颜色,
默认red。建议显式填写breatheValue="1"和所需颜色,确保值列表与颜色列表对应。
breatheValue的值支持区间[a, b],用逗号,隔开,表示满足 a ≤ 量测值 ≤ bbreatheValue和breatheColor的值支持多个,用分号;隔开,下标一一对应,需保证成对出现
pointNumber指定量测,colorValue与colorColor分别是匹配值列表和颜色列表,二者都需填写,没有自动的默认配色。
<text id="text1" displayType="color" pointNumber="101" colorValue="0;1" colorColor="#00ffff;red" xml:space="preserve" style="font-size:12px;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;stroke-width:3"> ...</text>- 对
displayType="color"标签下的后代元素着色:path改变stroke,其他元素改变fill;无子节点时处理该元素自身。 - 该逻辑不会保存着色前标签的颜色,如需恢复颜色,则需通过量测值再着色回去
colorValue的值支持区间[a, b],用逗号,隔开,表示满足 a ≤ 量测值 ≤ bcolorValue和colorColor的值支持多个,用分号;隔开,下标一一对应,需保证成对出现
<tspan id="path1" displayType='measure' pointNumber="1001"> ...</tspan>- 事件触发时,参数value的值为
pointNumber中定义的测点号
<g id="device"> <g id="g1" deviceId="101"> ... </g></g>设备元素必须位于id="device"的分组内,内部层级不限;deviceId填写实际设备ID。
事件触发时,参数value的值为deviceId中定义的设备ID。
<g id="button1" displayType="button" buttonValue="1"> ...</g>- 事件触发时,参数value的值为
buttonValue中定义的值
<g id="g1" displayType="enum" pointNumber="101"> <!-- 用透明矩形覆盖整个开关,使整个区域都能接收鼠标事件。 --> <g id="g1-1"> <rect id="rect1" fill="transparent" /> </g> <!-- 断开状态,初始隐藏。 --> <g id="g1-2" enumValue="0" display="none"> ... </g> <!-- 闭合状态,初始显示。 --> <g id="g1-3" enumValue="1"> ... </g></g>- 开关建议采用枚举来实现
<text id="text1" displayType="enum" pointNumber="101" xml:space="preserve" style="font-size:12px;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;stroke-width:3"> <tspan id="tspan1" enumValue="1"> 开启 </tspan> <tspan id="tspan2" enumValue="0" display="none"> 关闭 </tspan></text><g displayType="button" buttonValue="1" style="cursor:pointer"> <rect x="129.36285" y="-64.731697" width="190" height="54" rx="12" ry="12" stroke="#6699ff" stroke-width="2" id="rect6" fill="#333333" /> <text x="225.70145" y="-30.041756" text-anchor="middle" font-size="18px" fill="#ffffff" font-family="'Segoe UI', Roboto, Helvetica, Arial, sans-serif" id="text6"> 按钮文字 </text></g>上面的代码块省略了具体图形路径。实际SVG需有合法XML结构,属性区不能插入//注释,
说明性注释放在标签外的XML注释中。pointNumber/deviceId须能转为对应ID,区间与多值的
分隔符按各属性约定填写;测点值、枚举显示与浏览器事件是三类行为,不会自动创建后台测点。
完成后按SVG配置导入并应用,在监控图中分别检查量测显示、状态变化和点击事件。