import svgObject from "./svgOjbect"
|
import ConstParas from "@/utils/constParas.js"
|
import UnitHelper from "@/utils/unit.js"
|
import PointToleranceConfig from "./PointToleranceConfig.js"
|
|
var MultiSpeedChartDiagram = function () {
|
var m_svg;
|
|
var m_unit = { Q: 1, H: 0, P: 1,NPSH:0 };//功率、流量、扬程单位集合
|
var m_divChartName;//容器DIV名称
|
var m_chartSize;//图表尺寸
|
var m_localizationType;//语言类型
|
var m_toolTipContent;//内容提示DIV容器
|
var m_equipZeroH = 0;
|
|
|
var m_pumpInfo;//基本信息
|
var m_chartPointPara;
|
var m_chartObject;
|
var m_coordinatePara;//坐标
|
|
var m_maxSpeedCurve;
|
var m_simuSpeedCurves;
|
var onChangeSpeedListCb;//修改了列表通知外部
|
|
var m_chartSetting;//设置
|
var m_displayStyle;//显示设置
|
|
|
|
var m_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two;
|
|
var m_isDispCurveQE = false;//是否显示效率
|
var m_isDispCurveNPSH = false;//是否显示效率
|
var m_isHaveNpsh = false;//是否显示汽蚀
|
var m_colorArray = ["#426ab3", "#b2d235", "#840228", "#33a3dc", "#cd9a5b", "#96582a", "#f58220", "#f47920", "#f391a9", "#ed1941", "#f47a55", "#224b8f", "#2a5caa", "#9b95c9", "#f0dc70"];
|
|
|
var m_designPointTolerance = [0.91, 1.09, 0.95, 1.05];//设计点公差
|
|
//设置颜色
|
var setObjectColor = function (isMonorColor) {
|
m_displayStyle.IsMonoColor = isMonorColor;
|
if (m_displayStyle.IsMonoColor) {
|
m_displayStyle.ColorH = "#000000";
|
m_displayStyle.ColorE = "#000000";
|
m_displayStyle.ColorP = "#000000";
|
m_displayStyle.ColorNPSH = "#000000";
|
m_displayStyle.ColorEquipment = "#000000";
|
m_displayStyle.ColorEqualParaCurvesE = "#000000";
|
m_displayStyle.ColorSpectrumFill = "#f2eada";
|
m_displayStyle.ColorGridLine = "#cccccc"
|
}
|
else {
|
m_displayStyle.ColorH = "#000000";
|
m_displayStyle.ColorE = "#000000";
|
m_displayStyle.ColorP = "#000000";
|
m_displayStyle.ColorNPSH = "#000000";
|
m_displayStyle.ColorEquipment = "#013317";
|
m_displayStyle.ColorEqualParaCurvesE = "#402db7";
|
m_displayStyle.ColorSpectrumFill = "Aquamarine";
|
m_displayStyle.ColorGridLine = "#cccccc";
|
}
|
};
|
|
var m_curveMaxId = 1;
|
|
//初始化显示设置
|
var initialDispStyle = function (displayStyle, chartSetting) {
|
if (displayStyle != null) {
|
m_displayStyle = displayStyle;
|
}
|
else {
|
m_displayStyle = {};
|
m_displayStyle.IsMonoColor = false;
|
m_displayStyle.IsDispSpectrum = false;//默认不显示型谱
|
m_displayStyle.DesignPointDispType = 0;//设计点显示方式(eDesignPointDispType) Cross 0 LeftDownTriangle 2
|
}
|
|
|
//console.log(m_displayStyle)
|
|
m_isHaveNpsh = true;
|
if (m_chartObject != null && m_chartObject.MaxWaterCurveNPSH == null)
|
m_isHaveNpsh = false;
|
|
m_displayStyle.FeatCurveSize = 10;
|
m_displayStyle.EqualCurveSize = 9;
|
if (m_displayStyle.IsDispCurveLabel == null)
|
m_displayStyle.IsDispCurveLabel = true;
|
|
m_displayStyle.isDrawWaterMark = true;
|
m_displayStyle.isDispEquipmentCurve = false;
|
//是否显示子刻度
|
m_displayStyle.isDispMiniTick = true;
|
m_displayStyle.isRotateLabelX = false;
|
m_displayStyle.isAxisIntervalX = false;
|
m_displayStyle.MiniTickNumber = 4;
|
|
|
setObjectColor(m_displayStyle.IsMonoColor);
|
};
|
//
|
var initialSvg = function () {
|
if (m_divChartName == null) {
|
return false;
|
}
|
//
|
var m_svgID = "MultiSpeedCurveSvg";//暂时不知道做啥用
|
m_svg = new svgObject().init(m_divChartName, m_chartSize.TotalWidth, m_chartSize.TotalHeight, svgClick, svgMove, m_svgID);
|
|
return true;
|
}
|
//初始化面板尺寸
|
var initialPanelSize = function () {
|
if (!initialSvg())
|
return;
|
|
if (m_coordinatePara == null)
|
return;
|
|
if (m_chartSize == null) {
|
m_chartSize = {};
|
m_chartSize.TotalWidth = document.getElementById(m_divChartName).clientWidth;
|
m_chartSize.TotalHeight = document.getElementById(m_divChartName).clientHeight;
|
}
|
|
if (m_chartSize.TotalHeight < 500)
|
m_chartSize.TotalHeight = 500;
|
|
var space_left = 70;
|
var space_right = 60;
|
var space_top = 10;
|
var space_bottom = 60;
|
if (m_coordinatePara.SpaceP > 99) {
|
space_left = 80;
|
}
|
if (m_coordinatePara.SpaceP <= 0.1) {
|
space_left = 80;
|
}
|
if (m_localizationType >= 2) {
|
space_left = 75;
|
space_right = 75;
|
}
|
|
m_chartSize.SpaceTop = space_top;
|
m_chartSize.SpaceRight = space_right;
|
m_chartSize.SpaceBottom = space_bottom;
|
m_chartSize.SpaceLeft = space_left;
|
|
m_chartSize.DiagramTop = space_top;
|
m_chartSize.DiagramLeft = space_left;
|
m_chartSize.DiagramRight = m_chartSize.TotalWidth - space_right;
|
m_chartSize.DiagramBottom = m_chartSize.TotalHeight - space_bottom;
|
|
m_chartSize.DiagramWidth = m_chartSize.TotalWidth - space_left - space_right;
|
m_chartSize.DiagramHeight = m_chartSize.TotalHeight - space_top - space_bottom;
|
|
m_chartSize.SpaceGridX = m_chartSize.DiagramWidth / m_coordinatePara.GridNumberX;
|
|
if (m_chartDiagramPanelStyle == ConstParas.ChartDiagramPanelStyle.Whole) {
|
|
m_chartSize.UpDiagram = {};
|
m_chartSize.UpDiagram.Up = space_top;
|
m_chartSize.UpDiagram.Bottom = m_chartSize.TotalHeight - space_bottom;
|
m_chartSize.UpDiagram.SpaceGridY = m_chartSize.DiagramHeight / m_coordinatePara.GridNumberY;
|
m_chartSize.UpDiagram.GridNumberY = m_coordinatePara.GridNumberY;
|
|
m_chartSize.DownDiagram = {};//一样
|
m_chartSize.DownDiagram.Up = space_top;
|
m_chartSize.DownDiagram.Bottom = m_chartSize.TotalHeight - space_bottom;
|
m_chartSize.DownDiagram.SpaceGridY = m_chartSize.DiagramHeight / m_coordinatePara.GridNumberY;
|
m_chartSize.DownDiagram.GridNumberY = m_coordinatePara.GridNumberY;
|
|
|
m_chartSize.PanelH = {};
|
m_chartSize.PanelH.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoH;
|
m_chartSize.PanelH.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoH;
|
|
m_chartSize.PanelE = {};
|
m_chartSize.PanelE.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoE;
|
m_chartSize.PanelE.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoE;
|
|
m_chartSize.PanelP = {};
|
m_chartSize.PanelP.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoP;
|
m_chartSize.PanelP.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoP;
|
|
m_chartSize.PanelNPSH = {};
|
m_chartSize.PanelNPSH.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoNPSH;
|
m_chartSize.PanelNPSH.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoNPSH;
|
|
//console.log(m_chartSize)
|
//把间隙弄小点
|
var areaAttr = {
|
x: space_left,
|
y: space_top,
|
width: m_chartSize.DiagramWidth,
|
height: m_chartSize.DiagramHeight
|
};
|
|
var areaStyle = {
|
"stroke-width": "1px",
|
"stroke": "#cccccc",
|
"fill": "#ffffff",
|
"fill-opacity": "0.5",
|
"zIndex:": 5
|
};
|
|
//
|
m_svg.createArea(areaAttr, areaStyle);
|
}
|
else {
|
var panel_space = 35;
|
m_chartSize.PanelSpace = panel_space;
|
|
var grid_num_h = m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH;
|
var grid_num_e = m_coordinatePara.EndLineNoE - m_coordinatePara.StartLineNoE;
|
|
var grid_num_up = Math.max(grid_num_h, grid_num_e);
|
grid_num_up = grid_num_up + 2;//多两条
|
if (!m_isDispCurveQE) {
|
grid_num_up = m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH;
|
}
|
//console.log(grid_num_up, grid_num_h, grid_num_e) ;
|
var grid_num_NPSH = m_coordinatePara.EndLineNoNPSH - m_coordinatePara.StartLineNoNPSH;
|
var grid_num_p = m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP;
|
var grid_num_down = Math.max(grid_num_NPSH, grid_num_p) + 1;
|
|
|
m_chartSize.UpDiagram = {};
|
m_chartSize.UpDiagram.Up = space_top;
|
m_chartSize.UpDiagram.SpaceGridY = (m_chartSize.DiagramHeight - panel_space) / (grid_num_up + grid_num_down);
|
m_chartSize.UpDiagram.Bottom = space_top + grid_num_up * m_chartSize.UpDiagram.SpaceGridY;
|
m_chartSize.UpDiagram.GridNumberY = grid_num_up;
|
|
|
m_chartSize.DownDiagram = {};
|
m_chartSize.DownDiagram.Up = m_chartSize.UpDiagram.Bottom + panel_space;
|
m_chartSize.DownDiagram.SpaceGridY = (m_chartSize.DiagramHeight - panel_space) / (grid_num_up + grid_num_down);
|
m_chartSize.DownDiagram.Bottom = m_chartSize.TotalHeight - space_bottom;
|
m_chartSize.DownDiagram.GridNumberY = grid_num_down;
|
|
|
|
m_chartSize.PanelH = {};
|
m_chartSize.PanelH.Bottom = m_chartSize.UpDiagram.Up + m_chartSize.UpDiagram.SpaceGridY * grid_num_h;
|
m_chartSize.PanelH.Up = m_chartSize.UpDiagram.Up;
|
|
m_chartSize.PanelE = {};
|
m_chartSize.PanelE.Bottom = m_chartSize.UpDiagram.Bottom;
|
m_chartSize.PanelE.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * grid_num_e;
|
|
m_chartSize.PanelP = {};
|
m_chartSize.PanelP.Up = m_chartSize.DownDiagram.Up;
|
m_chartSize.PanelP.Bottom = m_chartSize.DownDiagram.Up + m_chartSize.DownDiagram.SpaceGridY * grid_num_p;
|
|
|
m_chartSize.PanelNPSH = {};
|
m_chartSize.PanelNPSH.Bottom = m_chartSize.DownDiagram.Bottom;
|
m_chartSize.PanelNPSH.Up = m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * grid_num_NPSH;
|
|
//console.log(m_chartSize)
|
}
|
};
|
//
|
var getSvgObjByName = function (objName) {
|
return m_svg.getPathByName(objName);
|
};
|
//代码临时注释
|
var svgClick = function (e) {
|
|
};
|
//
|
var svgMove = function (e) {
|
//alert("svgMove");
|
};
|
|
//翻译
|
var getTranslateString = function (cn) {
|
if (m_localizationType == 0)
|
return cn;
|
if(m_localizationType == 6){//ko
|
if (cn == "流量")
|
return "유량";
|
else if (cn == "压力")
|
return "압력받다";
|
else if (cn == "扬程")
|
return "양정";
|
else if (cn == "效率")
|
return "효율성";
|
else if (cn == "功率")
|
return "파워";
|
}
|
if(m_localizationType == 8){//es
|
if (cn == "流量")
|
return "Caudal";
|
else if (cn == "压力")
|
return "Presión";
|
else if (cn == "扬程")
|
return "Cabezal";
|
else if (cn == "效率")
|
return "Eficiencia";
|
else if (cn == "功率")
|
return "Potencia";
|
}
|
if(m_localizationType == 5){//ru
|
if (cn == "流量")
|
return "поток";
|
else if (cn == "压力")
|
return "давление";
|
else if (cn == "扬程")
|
return "напор";
|
else if (cn == "效率")
|
return "эффективность";
|
else if (cn == "功率")
|
return "мощность ";
|
}
|
if (cn == "流量")
|
return "Flow";
|
else if (cn == "压力")
|
return "Press";
|
else if (cn == "扬程")
|
return "Head";
|
else if (cn == "效率")
|
return "Eta";
|
else if (cn == "功率")
|
return "Power";
|
else if (cn == "汽蚀")
|
return "NPSHr";
|
else
|
return cn;
|
};
|
//绘制x坐标(含标题)
|
var createXAxis = function (bottom_posi, title_space) {
|
if (m_coordinatePara == null) {
|
return;
|
}
|
|
//刻度线
|
var attrAxisTickX = {
|
"stroke": "black",
|
"stroke-width": "1",
|
"fill": "none",
|
"zIndex": 10
|
};
|
|
//刻度长度
|
var minTickLength = 4;
|
var tickLength = 6;
|
|
//刻度文字
|
var styleAxisLabelX = "font-size:11px;fill-opacity:1;fill:black;";//font-weight:bold
|
|
//标题文字
|
var styleAxisTitleX = "font-size:14px;fill-opacity:1;fill:black;font-weight:bold;";
|
|
//
|
for (var i = 0; i <= m_coordinatePara.GridNumberX; i++) {
|
|
let q = m_coordinatePara.MinQ + i * m_coordinatePara.SpaceQ;
|
//console.log(q)
|
var content = UnitHelper.valueFormat(UnitHelper.getDispValueQ(UnitHelper.ConvertQ_fromM3H(m_unit.Q, q)));
|
var posiX_grid = m_chartSize.DiagramLeft + m_chartSize.SpaceGridX * i;
|
//刻度线
|
var valueMain = [];
|
valueMain.push("M ", posiX_grid, " ", bottom_posi, " L ", posiX_grid, " ", bottom_posi + tickLength);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickX, null);//"TickLineX" + i
|
|
//文字 m_displayStyle.isAxisIntervalX
|
var label_y = bottom_posi + tickLength + 15;
|
if (m_displayStyle.isRotateLabelX)
|
label_y = label_y + 1;
|
var attrAxisLabelX = {
|
"opacity": 1,
|
"x": posiX_grid,
|
"y": label_y,
|
"text-anchor": "middle"
|
};
|
var transform = null;
|
if (m_displayStyle.isRotateLabelX)
|
transform = "rotate(45 " + posiX_grid + "," + label_y + ")";
|
if (m_displayStyle.isAxisIntervalX) {
|
if (i % 2 == 0)
|
m_svg.createText(attrAxisLabelX, styleAxisLabelX, content, 10, null, transform);
|
}
|
else {
|
m_svg.createText(attrAxisLabelX, styleAxisLabelX, content, 10, null, transform);
|
}
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.GridNumberX) {
|
for (var j = 0; j <= m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiX_grid + m_chartSize.SpaceGridX * j / (m_displayStyle.MiniTickNumber + 1);
|
var valueMini = [];
|
valueMini.push("M ", pois_minTick, " ", bottom_posi, " L ", pois_minTick, " ", bottom_posi + minTickLength);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickX, null);
|
}
|
}
|
}
|
|
if (title_space > 0) {
|
var attrAxisTitleX = {
|
"opacity": 1,
|
"x": (m_chartSize.DiagramLeft + m_chartSize.DiagramRight) / 2,
|
"y": bottom_posi + title_space,
|
"text-anchor": "middle"
|
};
|
if (m_displayStyle.isRotateLabelX)
|
attrAxisTitleX.y = attrAxisTitleX.y + 12;
|
|
let unit_name = UnitHelper.GetUnitNameQ(m_unit.Q);
|
m_svg.createText(attrAxisTitleX, styleAxisTitleX, getTranslateString("流量") + " (" + unit_name + ")");
|
}
|
|
};
|
//绘制Y坐标(含标题)
|
var createYAxis_Whole = function () {
|
if (m_coordinatePara == null) {
|
return;
|
}
|
|
//刻度长度
|
var minTickLength = 3;
|
var tickLength = 6;
|
|
//扬程
|
if (m_coordinatePara.EndLineNoH > m_coordinatePara.StartLineNoH) {
|
//刻度线
|
var attrAxisTickH = {
|
"stroke": m_displayStyle.ColorH,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelH = "font-size:11px; fill-opacity:1; fill:" + m_displayStyle.ColorH + ";";
|
//标签
|
var styleAxisTitleH = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorH + ";";
|
|
let unit_h_name = UnitHelper.GetUnitNameH(m_unit.H);
|
|
//标签
|
var attrAxisTitleH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 52,
|
"y": m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * ((m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH) / 2 +
|
m_coordinatePara.StartLineNoH) - 10,
|
"text-anchor": "middle"
|
};
|
if (m_localizationType == 0) {//中文
|
if (m_unit.H == UnitHelper.H.MPa || m_unit.H == UnitHelper.H.KPa) {
|
attrAxisTitleH.y = attrAxisTitleH.y - 5;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "压");
|
attrAxisTitleH.y = attrAxisTitleH.y + 15;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "力");
|
|
attrAxisTitleH.x = attrAxisTitleH.x + 3;
|
attrAxisTitleH.y = attrAxisTitleH.y + 21;
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";
|
if (m_unit.H == UnitHelper.H.MPa)
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "(MPa)", 10, null, transform);
|
else if (m_unit.H == UnitHelper.H.MPa)
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "(kPa)", 10, null, transform);
|
|
}
|
else {
|
attrAxisTitleH.y = attrAxisTitleH.y - 5;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "扬");
|
attrAxisTitleH.y = attrAxisTitleH.y + 15;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "程");
|
|
if (m_unit.H == 0) {
|
attrAxisTitleH.x = attrAxisTitleH.x + 3;
|
attrAxisTitleH.y = attrAxisTitleH.y + 21;
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";//不用多出空格否则全屏会有问题expandChartFullScreen
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "(" + unit_h_name + ")", 10, null, transform);
|
}
|
}
|
}
|
else {
|
var content = "Head (" + unit_h_name + ")";
|
if (m_unit.H == UnitHelper.H.MPa) {
|
content = "Press (MPa)";
|
}
|
if (m_unit.H == UnitHelper.H.KPa) {
|
content = "Press (KPa)";
|
}
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";//不用多出空格否则全屏会有问题expandChartFullScreen
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, content, 10, null, transform);
|
}
|
|
|
//
|
for (var i = m_coordinatePara.StartLineNoH; i <= m_coordinatePara.EndLineNoH; i++) {
|
|
var posiY_grid = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * i;
|
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickH, null);
|
|
//文字
|
var attrAxisLabelH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 10,
|
"y": posiY_grid + 5,
|
"text-anchor": "end"
|
};
|
var content = UnitHelper.valueFormat(m_coordinatePara.MinH + i * m_coordinatePara.SpaceH);
|
m_svg.createText(attrAxisLabelH, styleAxisLabelH, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoH) {
|
for (var j = 1; j <= m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / (m_displayStyle.MiniTickNumber + 1);
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickH, null);
|
}
|
}
|
}
|
}
|
|
|
//效率
|
if (m_coordinatePara.EndLineNoE > m_coordinatePara.StartLineNoE && m_isDispCurveQE) {
|
//刻度线
|
var attrAxisTickE = {
|
"stroke": m_displayStyle.ColorE,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelE = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorE + ";";
|
//标签
|
var styleAxisTitleE = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorE + ";";
|
//
|
var attrAxisTitleE = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 44,
|
"y": m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * ((m_coordinatePara.EndLineNoE - m_coordinatePara.StartLineNoE) / 2 +
|
m_coordinatePara.StartLineNoE) - 10,
|
"text-anchor": "middle"
|
};
|
|
//标签
|
if (m_localizationType == 0) {//中文
|
attrAxisTitleE.y = attrAxisTitleE.y - 5;
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "效");
|
attrAxisTitleE.y = attrAxisTitleE.y + 15;
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "率");
|
|
attrAxisTitleE.x = attrAxisTitleE.x + 6;
|
attrAxisTitleE.y = attrAxisTitleE.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleE.x + "," + attrAxisTitleE.y + ")";
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "(%)", 10, null, transform);
|
}
|
else {
|
attrAxisTitleE.x = attrAxisTitleE.x + 6;
|
attrAxisTitleE.y = attrAxisTitleE.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleE.x + "," + attrAxisTitleE.y + ")";
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "Eta (%)", 10, null, transform);
|
}
|
|
//
|
for (var i = m_coordinatePara.StartLineNoE; i <= m_coordinatePara.EndLineNoE; i++) {
|
var content = m_coordinatePara.MinE + i * m_coordinatePara.SpaceE;
|
var posiY_grid = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramRight, " ", posiY_grid, " L ", m_chartSize.DiagramRight + tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickE, null);
|
|
//文字
|
var attrAxisLabelE = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 10,
|
"y": posiY_grid + 5
|
};
|
m_svg.createText(attrAxisLabelE, styleAxisLabelE, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoE) {
|
for (var j = 0; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickE, null);
|
}
|
}
|
|
}
|
}
|
|
//功率
|
if (m_coordinatePara.EndLineNoP > m_coordinatePara.StartLineNoP) {
|
//刻度线
|
var attrAxisTickP = {
|
"stroke": m_displayStyle.ColorP,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
let unit_p_name = UnitHelper.GetUnitNameP(m_unit.P);
|
|
//刻度文字
|
var styleAxisLabelP = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorP + ";";
|
//标签
|
var styleAxisTitleP = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorP + ";";
|
|
//标签
|
if (m_localizationType == 0) {//中文
|
var attrAxisTitleP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 52,
|
"y": m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * ((m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP) / 2 +
|
m_coordinatePara.StartLineNoP),
|
"text-anchor": "middle"
|
};
|
if (m_coordinatePara.SpaceP <= 0.1) {
|
attrAxisTitleP.x = attrAxisTitleP.x - 5;
|
}
|
attrAxisTitleP.y = attrAxisTitleP.y - 5;
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "功");
|
attrAxisTitleP.y = attrAxisTitleP.y + 15;
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "率");
|
|
attrAxisTitleP.x = attrAxisTitleP.x + 2;
|
attrAxisTitleP.y = attrAxisTitleP.y + 25;
|
var transform = "rotate(-90 " + attrAxisTitleP.x + "," + attrAxisTitleP.y + ")";
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "(" + unit_p_name + ")", 10, null, transform);
|
}
|
else {
|
var attrAxisTitleP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 60,
|
"y": m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * ((m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP) / 2 +
|
m_coordinatePara.StartLineNoP) - 10,
|
"text-anchor": "middle"
|
};
|
if (m_coordinatePara.SpaceP <= 0.1) {
|
attrAxisTitleP.x = attrAxisTitleP.x - 5;
|
}
|
attrAxisTitleP.x = attrAxisTitleP.x + 13;
|
attrAxisTitleP.y = attrAxisTitleP.y + 25;
|
var transform = "rotate(-90 " + attrAxisTitleP.x + "," + attrAxisTitleP.y + ")";
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "Power (" + unit_p_name + ")", 10, null, transform);
|
}
|
|
//
|
for (var i = m_coordinatePara.StartLineNoP; i <= m_coordinatePara.EndLineNoP; i++) {
|
var content = UnitHelper.valueFormat(m_coordinatePara.MinP + i * m_coordinatePara.SpaceP);
|
|
content = UnitHelper.formatToFixed(parseFloat(UnitHelper.ConvertP(UnitHelper.P.KW, m_unit.P, content)), 1)
|
|
var posiY_grid = m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickP, null);
|
|
//文字
|
var attrAxisLabelP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 10,
|
"y": posiY_grid + 5,
|
"text-anchor": "end"
|
};
|
|
m_svg.createText(attrAxisLabelP, styleAxisLabelP, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoP && i != m_coordinatePara.EndLineNoE) {
|
for (var j = 1; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.DownDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickP, null);
|
}
|
}
|
|
}
|
}
|
|
|
|
|
//汽蚀
|
if (m_isHaveNpsh && m_coordinatePara.EndLineNoNPSH > m_coordinatePara.StartLineNoNPSH) {
|
//刻度线
|
var attrAxisTickNPSH = {
|
"stroke": m_displayStyle.ColorNPSH,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelNPSH = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorNPSH + ";";
|
//标签
|
var styleAxisTitleNPSH = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorNPSH + ";";
|
|
//标签
|
var attrAxisTitleNPSH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 44,
|
"y": m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * ((m_coordinatePara.EndLineNoNPSH - m_coordinatePara.StartLineNoNPSH) / 2 +
|
m_coordinatePara.StartLineNoNPSH) - 10,
|
"text-anchor": "middle"
|
};
|
if (m_localizationType == 0) {//中文
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y - 5;
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "汽");
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 15;
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "蚀");
|
attrAxisTitleNPSH.x = attrAxisTitleNPSH.x + 6;
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleNPSH.x + "," + attrAxisTitleNPSH.y + ")";
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "(m)", 10, null, transform);
|
}
|
else {
|
attrAxisTitleNPSH.x = attrAxisTitleNPSH.x + 6;
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleNPSH.x + "," + attrAxisTitleNPSH.y + ")";
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "NPSHr (m)", 10, null, transform);
|
}
|
|
//
|
for (var i = m_coordinatePara.StartLineNoNPSH; i <= m_coordinatePara.EndLineNoNPSH; i++) {
|
var content = UnitHelper.valueFormat(m_coordinatePara.MinNPSH + i * m_coordinatePara.SpaceNPSH);
|
var posiY_grid = m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramRight, " ", posiY_grid, " L ", m_chartSize.DiagramRight + tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickNPSH, null);
|
|
//文字
|
var attrAxisLabelNPSH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 10,
|
"y": posiY_grid + 5
|
};
|
m_svg.createText(attrAxisLabelNPSH, styleAxisLabelNPSH, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoNPSH) {
|
for (var j = 0; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.DownDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickNPSH, null);
|
}
|
}
|
}
|
}
|
};
|
//绘制Y坐标(含标题)
|
var createYAxis_TwoPanel = function () {
|
if (m_coordinatePara == null) {
|
return;
|
}
|
|
//刻度长度
|
var minTickLength = 3;
|
var tickLength = 6;
|
|
//扬程
|
if (m_coordinatePara.EndLineNoH > m_coordinatePara.StartLineNoH) {
|
//刻度线
|
var attrAxisTickH = {
|
"stroke": m_displayStyle.ColorH,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelH = "font-size:11px; fill-opacity:1; fill:" + m_displayStyle.ColorH + ";";
|
//标签
|
var styleAxisTitleH = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorH + ";";
|
|
let unit_h_name = UnitHelper.GetUnitNameH(m_unit.H);
|
|
//标签
|
var attrAxisTitleH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 52,
|
"y": (m_chartSize.PanelH.Bottom + m_chartSize.PanelH.Up) / 2 - 10,
|
"text-anchor": "middle"
|
};
|
if (m_localizationType == 0) {//中文
|
if (m_unit.H == UnitHelper.H.MPa || m_unit.H == UnitHelper.H.KPa) {
|
attrAxisTitleH.y = attrAxisTitleH.y - 5;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "压");
|
attrAxisTitleH.y = attrAxisTitleH.y + 15;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "力");
|
|
attrAxisTitleH.x = attrAxisTitleH.x + 3;
|
attrAxisTitleH.y = attrAxisTitleH.y + 21;
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "(MPa)", 10, null, transform);
|
}
|
else {
|
attrAxisTitleH.y = attrAxisTitleH.y - 5;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "扬");
|
attrAxisTitleH.y = attrAxisTitleH.y + 15;
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "程");
|
|
if (m_unit.H == 0) {
|
attrAxisTitleH.x = attrAxisTitleH.x + 3;
|
attrAxisTitleH.y = attrAxisTitleH.y + 21;
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";//不用多出空格否则全屏会有问题expandChartFullScreen
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, "(" + unit_h_name + ")", 10, null, transform);
|
}
|
}
|
}
|
else {
|
var content = "Head (" + unit_h_name + ")";
|
if (m_unit.H == UnitHelper.H.MPa) {
|
content = "Press (MPa)";
|
}
|
if (m_unit.H == UnitHelper.H.KPa) {
|
content = "Press (MPa)";
|
}
|
var transform = "rotate(-90 " + attrAxisTitleH.x + "," + attrAxisTitleH.y + ")";//不用多出空格否则全屏会有问题expandChartFullScreen
|
m_svg.createText(attrAxisTitleH, styleAxisTitleH, content, 10, null, transform);
|
}
|
|
|
//
|
for (var i = 0; i <= m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH; i++) {
|
|
var posiY_grid = m_chartSize.PanelH.Bottom - m_chartSize.UpDiagram.SpaceGridY * i;
|
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickH, null);
|
|
//文字
|
var attrAxisLabelH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 10,
|
"y": posiY_grid + 5,
|
"text-anchor": "end"
|
};
|
var axis_h = UnitHelper.ConvertH_fromM(m_unit.H,m_coordinatePara.MinH + (i + m_coordinatePara.StartLineNoH) * m_coordinatePara.SpaceH);
|
if(axis_h < -0.01)
|
continue;
|
var content = UnitHelper.valueFormat(axis_h);
|
m_svg.createText(attrAxisLabelH, styleAxisLabelH, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != (m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH)) {
|
for (var j = 1; j <= m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / (m_displayStyle.MiniTickNumber + 1);
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickH, null);
|
}
|
}
|
}
|
}
|
|
|
//效率
|
if (m_coordinatePara.EndLineNoE > m_coordinatePara.StartLineNoE && m_isDispCurveQE) {
|
//刻度线
|
var attrAxisTickE = {
|
"stroke": m_displayStyle.ColorE,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelE = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorE + ";";
|
//标签
|
var styleAxisTitleE = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorE + ";";
|
//
|
var attrAxisTitleE = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 44,
|
"y": (m_chartSize.UpDiagram.Bottom + m_chartSize.UpDiagram.Up) / 2 - 10,
|
"text-anchor": "middle"
|
};
|
|
//标签
|
if (m_localizationType == 0) {//中文
|
attrAxisTitleE.y = attrAxisTitleE.y - 5;
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "效");
|
attrAxisTitleE.y = attrAxisTitleE.y + 15;
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "率");
|
|
attrAxisTitleE.x = attrAxisTitleE.x + 6;
|
attrAxisTitleE.y = attrAxisTitleE.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleE.x + "," + attrAxisTitleE.y + ")";
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "(%)", 10, null, transform);
|
}
|
else {
|
attrAxisTitleE.x = attrAxisTitleE.x + 6;
|
attrAxisTitleE.y = attrAxisTitleE.y + 24;
|
var transform = "rotate(-90 " + attrAxisTitleE.x + "," + attrAxisTitleE.y + ")";
|
m_svg.createText(attrAxisTitleE, styleAxisTitleE, "Eta (%)", 10, null, transform);
|
}
|
|
//
|
for (var i = 0; i <= m_coordinatePara.EndLineNoE - m_coordinatePara.StartLineNoE; i++) {
|
|
var posiY_grid = m_chartSize.PanelE.Bottom - m_chartSize.UpDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramRight, " ", posiY_grid, " L ", m_chartSize.DiagramRight + tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickE, null);
|
|
//文字
|
var attrAxisLabelE = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 10,
|
"y": posiY_grid + 5
|
};
|
var axis_e = m_coordinatePara.MinE + (i + m_coordinatePara.StartLineNoE) * m_coordinatePara.SpaceE;
|
if(axis_e < -0.01)
|
continue;
|
|
var content = UnitHelper.valueFormat(axis_e);
|
m_svg.createText(attrAxisLabelE, styleAxisLabelE, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != (m_coordinatePara.EndLineNoE - m_coordinatePara.StartLineNoE)) {
|
for (var j = 0; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickE, null);
|
}
|
}
|
|
}
|
}
|
|
//功率
|
if (m_coordinatePara.EndLineNoP > m_coordinatePara.StartLineNoP) {
|
//刻度线
|
var attrAxisTickP = {
|
"stroke": m_displayStyle.ColorP,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
let unit_p_name = UnitHelper.GetUnitNameP(m_unit.P);
|
|
//刻度文字
|
var styleAxisLabelP = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorP + ";";
|
//标签
|
var styleAxisTitleP = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorP + ";";
|
|
//标签
|
if (m_localizationType == 0) {//中文
|
var attrAxisTitleP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 52,
|
"y": (m_chartSize.PanelP.Bottom + m_chartSize.PanelP.Up) / 2 - 10,
|
"text-anchor": "middle"
|
};
|
if (m_coordinatePara.SpaceP <= 0.1) {
|
attrAxisTitleP.x = attrAxisTitleP.x - 5;
|
}
|
attrAxisTitleP.y = attrAxisTitleP.y - 5;
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "功");
|
attrAxisTitleP.y = attrAxisTitleP.y + 15;
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "率");
|
|
attrAxisTitleP.x = attrAxisTitleP.x + 2;
|
attrAxisTitleP.y = attrAxisTitleP.y + 25;
|
var transform = "rotate(-90 " + attrAxisTitleP.x + "," + attrAxisTitleP.y + ")";
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "(" + unit_p_name + ")", 10, null, transform);
|
}
|
else {
|
var attrAxisTitleP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 60,
|
"y": (m_chartSize.PanelP.Bottom + m_chartSize.PanelP.Up) / 2 - 10,
|
"text-anchor": "middle"
|
};
|
if (m_coordinatePara.SpaceP <= 0.1) {
|
attrAxisTitleP.x = attrAxisTitleP.x - 5;
|
}
|
attrAxisTitleP.x = attrAxisTitleP.x + 13;
|
attrAxisTitleP.y = attrAxisTitleP.y + 25;
|
var transform = "rotate(-90 " + attrAxisTitleP.x + "," + attrAxisTitleP.y + ")";
|
m_svg.createText(attrAxisTitleP, styleAxisTitleP, "Power (" + unit_p_name + ")", 10, null, transform);
|
}
|
|
//
|
for (var i = 0; i <= m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP; i++) {
|
|
var posiY_grid = m_chartSize.PanelP.Bottom - m_chartSize.DownDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickP, null);
|
|
//文字
|
var attrAxisLabelP = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramLeft - 10,
|
"y": posiY_grid + 5,
|
"text-anchor": "end"
|
};
|
var aixs_p = UnitHelper.ConvertP_fromKW(m_unit.P,m_coordinatePara.MinP + (i + m_coordinatePara.StartLineNoP) * m_coordinatePara.SpaceP);
|
aixs_p = UnitHelper.getDispValueP(aixs_p);
|
if (aixs_p < -0.01)
|
continue;
|
var content = aixs_p.toString();
|
m_svg.createText(attrAxisLabelP, styleAxisLabelP, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoP
|
&& i != (m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP)) {
|
for (var j = 1; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.DownDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickP, null);
|
}
|
}
|
|
}
|
}
|
|
|
|
|
//汽蚀
|
if (m_isHaveNpsh && m_isDispCurveNPSH && m_coordinatePara.EndLineNoNPSH > m_coordinatePara.StartLineNoNPSH) {
|
//刻度线
|
var attrAxisTickNPSH = {
|
"stroke": m_displayStyle.ColorNPSH,
|
"stroke-width": "1",
|
"fill": "none"
|
};
|
|
//刻度文字
|
var styleAxisLabelNPSH = "font-size:10px; fill-opacity:1; fill:" + m_displayStyle.ColorNPSH + ";";
|
//标签
|
var styleAxisTitleNPSH = "font-size:14px; ;fill-opacity:1; font-weight:bold; fill:" + m_displayStyle.ColorNPSH + ";";
|
|
//标签
|
var attrAxisTitleNPSH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 44,
|
"y": (m_chartSize.PanelNPSH.Bottom + m_chartSize.PanelNPSH.Up) / 2 - 10,
|
"text-anchor": "middle"
|
};
|
var unit_npsh_str = "("+UnitHelper.GetUnitNameNPSH(m_unit.NPSH)+")";
|
if (m_localizationType == 0) {//中文
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y - 5;
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "汽");
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 15;
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "蚀");
|
attrAxisTitleNPSH.x = attrAxisTitleNPSH.x - 4;
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 24;
|
var transform = "rotate(90 " + attrAxisTitleNPSH.x + "," + attrAxisTitleNPSH.y + ")";
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, unit_npsh_str, 10, null, transform);
|
}
|
else {
|
attrAxisTitleNPSH.x = attrAxisTitleNPSH.x + 6;
|
attrAxisTitleNPSH.y = attrAxisTitleNPSH.y + 24;
|
var transform = "rotate(90 " + attrAxisTitleNPSH.x + "," + attrAxisTitleNPSH.y + ")";
|
m_svg.createText(attrAxisTitleNPSH, styleAxisTitleNPSH, "NPSHr "+unit_npsh_str, 10, null, transform);
|
}
|
|
//
|
for (var i = 0; i <= m_coordinatePara.EndLineNoNPSH - m_coordinatePara.StartLineNoNPSH; i++) {
|
|
var posiY_grid = m_chartSize.PanelNPSH.Bottom - m_chartSize.DownDiagram.SpaceGridY * i;
|
//主刻度
|
var valueMain = [];
|
valueMain.push("M ", m_chartSize.DiagramRight, " ", posiY_grid, " L ", m_chartSize.DiagramRight + tickLength, " ", posiY_grid);
|
m_svg.createPath(null, valueMain.join(''), attrAxisTickNPSH, null);
|
|
//文字
|
var attrAxisLabelNPSH = {
|
"opacity": 1,
|
"x": m_chartSize.DiagramRight + 10,
|
"y": posiY_grid + 5
|
};
|
var axis_npsh = m_coordinatePara.MinNPSH + (i + m_coordinatePara.StartLineNoNPSH) * m_coordinatePara.SpaceNPSH;
|
axis_npsh = UnitHelper.ConvertNPSH_fromM(m_unit.NPSH, axis_npsh);
|
if(axis_npsh < -0.01)
|
continue;
|
var content = UnitHelper.valueFormat(axis_npsh);
|
m_svg.createText(attrAxisLabelNPSH, styleAxisLabelNPSH, content);
|
|
//子刻度线
|
if (m_displayStyle.isDispMiniTick && i != (m_coordinatePara.EndLineNoNPSH - m_coordinatePara.StartLineNoNPSH)) {
|
for (var j = 0; j < m_displayStyle.MiniTickNumber; j++) {
|
var pois_minTick = posiY_grid - m_chartSize.DownDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber;
|
var valueMini = [];
|
valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick);
|
m_svg.createPath(null, valueMini.join(''), attrAxisTickNPSH, null);
|
}
|
}
|
}
|
}
|
};
|
//绘制面板
|
var drawDiagramPanel = function () {
|
if (m_chartDiagramPanelStyle == ConstParas.ChartDiagramPanelStyle.Whole) {
|
//绘制网格线
|
createGridLineDiagram_Whole();
|
|
//绘制X坐标
|
createXAxis(m_chartSize.DownDiagram.Bottom, 40);
|
|
//绘制Y坐标
|
createYAxis_Whole();
|
}
|
else {
|
//绘制网格线
|
createGridLineDiagram_TwoPanel();
|
|
//绘制X坐标
|
createXAxis(m_chartSize.UpDiagram.Bottom, 0);
|
createXAxis(m_chartSize.DownDiagram.Bottom, 40);
|
|
//绘制Y坐标
|
createYAxis_TwoPanel();
|
}
|
};
|
//产生装置曲线
|
var drawEquipmentCurve = function () {
|
var equipmentCurveElement = document.getElementById("EquipmentCurve");
|
if (equipmentCurveElement) {
|
equipmentCurveElement.remove();
|
}
|
if (m_chartObject.EquipmentSectPt == null)
|
return;
|
var pointNumber = 20;
|
var EquipmentCurve = [];
|
var space = m_chartObject.EquipmentSectPt.X / (pointNumber - 1);
|
var k = (m_chartObject.EquipmentSectPt.Y - m_equipZeroH) / (m_chartObject.EquipmentSectPt.X * m_chartObject.EquipmentSectPt.X);
|
for (var i = 0; i < pointNumber; i++) {
|
var pt = {};
|
pt.X = space * i;
|
pt.Y = m_equipZeroH + k * pt.X * pt.X;
|
EquipmentCurve.push(pt);
|
}
|
createCurveQH("EquipmentCurve", EquipmentCurve, 1, m_displayStyle.ColorEquipment, m_displayStyle.isDispEquipmentCurve);
|
};
|
|
|
|
//绘制曲线(流量扬程)
|
var createCurveQH = function (curveElementName, curvePoints, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (curvePoints == null) {
|
return;
|
}
|
if (curveElementName == null) {
|
return;
|
}
|
|
var pixelPoints = [];
|
for (var v = 0; v < curvePoints.length; v++) {
|
var pt = curvePoints[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueH(pt.Y);
|
pixelPoints.push({ "X": x, "Y": y });
|
}
|
|
return createCurveQH_pixel(curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType);
|
};
|
//绘制曲线(流量扬程) : 像素点
|
var createCurveQH_pixel = function (curveElementName, pixelPoints, curveWidth, curveColor, isDisp, curveDashType) {
|
if (pixelPoints == null || pixelPoints.length < 3) {
|
return;
|
}
|
if (curveElementName == null) {
|
return;
|
}
|
var pathValue = transBezierCurveToPath(pixelPoints);
|
if (pathValue == null || pathValue == undefined)
|
return;
|
//有时会报错,加上这个就没事 tangxu 20151122
|
if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) {
|
return;
|
}
|
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorH,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (curveWidth != null) {
|
style["stroke-width"] = curveWidth;
|
}
|
if (curveColor != null) {
|
style["stroke"] = curveColor;
|
}
|
if (curveDashType != null) {
|
style["stroke-dasharray"] = curveDashType;//'10, 10';//'10, 10, 5, 5'
|
}
|
//console.log(curveElementName,pathValue)
|
//绘制
|
m_svg.createPath(curveElementName, pathValue.join(''), {
|
"id": curveElementName
|
}, style);
|
//是否显示
|
if (isDisp != null && !isDisp) {
|
document.getElementById(curveElementName).style.display = 'none';
|
}
|
|
//绘制定义点
|
/*pixelPoints.forEach(pixel_pt => {
|
// console.log(pixel_pt)
|
var attr_pt = {
|
"cx": pixel_pt.X,
|
"cy": pixel_pt.Y,
|
"r": 2
|
}
|
var style_pt = {
|
"stroke-width": "2px",
|
"stroke": curveColor,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
|
|
m_svg.createCircle(null, attr_pt, style_pt);
|
});*/
|
|
|
return pixelPoints;
|
};
|
//绘制直线
|
var createLineQH = function (curveElementName, point1, point2, curveWidth, curveColor, objTag) {
|
if (point1 == null || point2 == null) {
|
return;
|
}
|
if (curveElementName == null) {
|
return;
|
}
|
var x1 = getPixelValueQ(point1.X);
|
var y1 = getPixelValueH(point1.Y);
|
|
|
var x2 = getPixelValueQ(point2.X);
|
var y2 = getPixelValueH(point2.Y);
|
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorH,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (curveWidth != null) {
|
style["stroke-width"] = curveWidth;
|
}
|
if (curveColor != null) {
|
style["stroke"] = curveColor;
|
}
|
var temp = "M x1 y1 L x2 y2";
|
var pathValue = temp.replace("x1", x1).replace("y1", y1).replace("x2", x2).replace("y2", y2);
|
if (objTag == null)
|
m_svg.createPath(curveElementName, pathValue, null, style);
|
else
|
m_svg.createPath(curveElementName, pathValue, { "tag": objTag }, style);
|
};
|
//绘制点
|
var createPointQH = function (curveElementName, point, circleSize, circleColor) {
|
if (point == null) {
|
return;
|
}
|
if (curveElementName == null) {
|
return;
|
}
|
|
var xPixel = getPixelValueQ(point.X);
|
var yPixel = getPixelValueH(point.Y);
|
|
var attr = {
|
"cx": xPixel,
|
"cy": yPixel,
|
"r": 2
|
}
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorH,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (circleSize != null) {
|
attr.r = circleSize;
|
}
|
if (circleColor != null) {
|
style["stroke"] = circleColor;
|
}
|
|
m_svg.createCircle(curveElementName, attr, style);
|
};
|
//绘制文字 textAnchor 文字对齐 start | middle | end
|
var drawTextByQH = function (curveElementName, text, point, textSize, textColor, offsetPixelX, offsetPixelY, textAnchor) {
|
if (!text) {
|
return;
|
}
|
if (!point) {
|
return;
|
}
|
|
var xPixel = getPixelValueQ(point.X);
|
var yPixel = getPixelValueH(point.Y);
|
if (offsetPixelX != null) {
|
xPixel += offsetPixelX;
|
}
|
if (offsetPixelY != null) {
|
yPixel -= offsetPixelY;
|
}
|
|
var textStyle = "stroke-width:1px; ";//font-weight:bold; fill-opacity:0.9;
|
if (textColor != null) {
|
textStyle += " fill:" + textColor + ";";
|
}
|
else {
|
textStyle += " fill:#000000;";
|
}
|
if (textSize != null) {
|
textStyle += " font-size:" + textSize + "px;"
|
} else {
|
textStyle += " font-size:12px;";
|
}
|
if (textAnchor != null) {
|
textStyle += " text-anchor:" + textAnchor + ";";
|
}
|
if (curveElementName == null) {
|
return m_svg.createText({
|
"opacity": 0.5,
|
"y": yPixel,
|
"x": xPixel
|
}, textStyle, text);
|
}
|
else {
|
return m_svg.createText({
|
"id": curveElementName,
|
"opacity": 0.5,
|
"y": yPixel,
|
"x": xPixel
|
}, textStyle, text);
|
}
|
};
|
//转速文字
|
var drawSpeedTextByQH = function (curveElementName, speed, point, textColor) {
|
|
if (!point) {
|
return;
|
}
|
|
var xPixel = getPixelValueQ(point.X) + 12;
|
var yPixel = getPixelValueH(point.Y) + 8;
|
|
var textStyle = "font-size:13px;text-anchor:start; font-weight:bold; ";//加粗 fill-opacity:0.9 stroke-width:1px;
|
textStyle += " fill:" + textColor + ";";
|
|
var text = speed + " rpm";
|
return m_svg.createText({
|
"id": curveElementName,
|
"opacity": 0.5,
|
"y": yPixel,
|
"x": xPixel
|
}, textStyle, text);
|
|
};
|
var drawSpeedTextByQP = function (curveElementName, speed, point, textColor) {
|
|
if (!point) {
|
return;
|
}
|
|
var xPixel = getPixelValueQ(point.X) + 11;
|
var yPixel = getPixelValueP(point.Y) + 4;
|
|
var textStyle = "font-size:13px;text-anchor:start;font-weight:bold;";//加粗 stroke-width:1px; fill-opacity:0.9
|
textStyle += " fill:" + textColor + ";";
|
|
var text = speed + " rpm";
|
return m_svg.createText({
|
"id": curveElementName,
|
"opacity": 0.5,
|
"y": yPixel,
|
"x": xPixel
|
}, textStyle, text);
|
|
};
|
//绘制设计点
|
var drawDesignPoint = function () {
|
if (m_chartObject.DesignPoint4StdUnit == null)
|
return;
|
var defaultDp = m_chartObject.DesignPoint4StdUnit;
|
|
var DispStyleType = m_displayStyle.DesignPointDispType;
|
if (DispStyleType == 2) {//倒三角
|
|
var xPixel = getPixelValueQ(defaultDp.X);
|
var yPixel = getPixelValueH(defaultDp.Y);
|
|
var xTri = m_chartSize.DiagramWidth / 20;
|
var yTri = xTri / 2;
|
var style = {
|
"stroke-width": "2px",
|
"stroke": "red",
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 18
|
};
|
//if (curveWidth != null) {
|
// style["stroke-width"] = curveWidth;
|
//}
|
//if (curveColor != null) {
|
// style["stroke"] = curveColor;
|
//}
|
|
|
var temp = "M x1 y1 L x2 y2";
|
var pathValue = temp.replace("x1", xPixel).replace("y1", yPixel).replace("x2", (xPixel - xTri)).replace("y2", yPixel);
|
m_svg.createPath("DesignPointWater1", pathValue, {
|
//"class": "DesignPoint1",
|
"tag": "DesignPoint1"
|
}, style);
|
pathValue = temp.replace("x1", xPixel).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri));
|
m_svg.createPath("DesignPointWater2", pathValue, {
|
//"class": "DesignPoint1",
|
"tag": "DesignPoint1"
|
}, style);
|
pathValue = temp.replace("x1", xPixel - xTri).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri));
|
m_svg.createPath("DesignPointWater3", pathValue, {
|
//"class": "DesignPoint1",
|
"tag": "DesignPoint1"
|
}, style);
|
|
|
//m_svg.createPath(objName, pathValue.join(''), {
|
// "id": objName
|
//}, style);
|
|
pathValue = temp.replace("x1", xPixel - xTri / 3).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri / 3));
|
m_svg.createPath("DesignPointWater4", pathValue, {
|
//"class": "DesignPoint1",
|
"tag": "DesignPoint1"
|
}, style);
|
|
pathValue = temp.replace("x1", xPixel - xTri * 2 / 3).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri * 2 / 3));
|
m_svg.createPath("DesignPointWater5", pathValue, {
|
//"class": "DesignPoint1",
|
"tag": "DesignPoint1"
|
}, style);
|
|
}
|
else {//十字线
|
var x = defaultDp.X;
|
var y = defaultDp.Y;
|
var point1 = { X: x, Y: y * m_designPointTolerance[2] };
|
var point2 = { X: x, Y: y * m_designPointTolerance[3] };
|
createLineQH("DesignPointWater1", point1, point2, 3, "red", "DesignPoint1");
|
|
point1 = { X: x * m_designPointTolerance[0], Y: y };
|
point2 = { X: x * m_designPointTolerance[1], Y: y };
|
createLineQH("DesignPointWater2", point1, point2, 3, "red", "DesignPoint1");
|
}
|
|
};
|
|
//绘制曲线(流量效率)
|
var createCurveQE = function (curveElementName, points, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (points == null) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
var isForceZeroPt = true;
|
if (curveElementName == "RegionBlodCurveQE_Allow")
|
isForceZeroPt = false;
|
if (curveElementName == "PerferBlodCurveQE_Allow")
|
isForceZeroPt = false;
|
|
var pixelPoints = [];
|
for (var v = 0; v < points.length; v++) {
|
if (isForceZeroPt && v == 0 && points[0].X < 10) {//强制归零
|
points[0].X = 0;
|
points[0].Y = 0;
|
}
|
var pt = points[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueE(pt.Y);
|
pixelPoints.push({ "X": x, "Y": y });
|
}
|
|
return createCurveQE_pixel(curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType);
|
};
|
//绘制曲线(流量效率) : 像素点
|
var createCurveQE_pixel = function (curveElementName, pixelPoints, curveWidth, curveColor, isDisp, curveDashType) {
|
if (pixelPoints == null || pixelPoints.length < 3) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
var pathValue = transBezierCurveToPath(pixelPoints);
|
if (pathValue == null || pathValue == undefined)
|
return null;
|
//有时会报错,加上这个就没事 tangxu 20151122
|
if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) {
|
return null;
|
}
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorE,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (curveWidth != null) {
|
style["stroke-width"] = curveWidth;
|
}
|
if (curveColor != null) {
|
style["stroke"] = curveColor;
|
}
|
|
if (curveDashType != null) {
|
style["stroke-dasharray"] = curveDashType;//'10, 10';//'10, 10, 5, 5'
|
}
|
|
m_svg.createPath(curveElementName, pathValue.join(''), {
|
"id": curveElementName
|
}, style);
|
if (isDisp != null && !isDisp) {
|
document.getElementById(curveElementName).style.display = 'none';
|
}
|
return pixelPoints;
|
};
|
//绘制曲线(流量功率)
|
var createCurveQP = function (curveElementName, points, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (points == null) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
|
var pixelPoints = [];
|
for (var v = 0; v < points.length; v++) {
|
var pt = points[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueP(pt.Y);
|
pixelPoints.push({ "X": x, "Y": y });
|
}
|
return createCurveQP_pixel(curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType);
|
};
|
//绘制曲线(流量功率) : 像素点
|
var createCurveQP_pixel = function (curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (pixelPoints == null || pixelPoints.length < 3) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
var pathValue = transBezierCurveToPath(pixelPoints);
|
if (pathValue == null || pathValue == undefined)
|
return null;
|
//有时会报错,加上这个就没事 tangxu 20151122
|
if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) {
|
return null;
|
}
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorP,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (curveWidth != null) {
|
style["stroke-width"] = curveWidth;
|
}
|
if (curveColor != null) {
|
style["stroke"] = curveColor;
|
}
|
//m_svg.createPath(curveElementName, pathValue.join(''), {
|
// "id": curveElementName
|
//}, style);
|
if (curveDashType != null) {
|
style["stroke-dasharray"] = curveDashType;//'10, 10';//'10, 10, 5, 5'
|
}
|
|
m_svg.createPath(curveElementName, pathValue.join(''), {
|
"id": curveElementName
|
}, style);
|
if (curveIsDisp != null && !curveIsDisp) {
|
document.getElementById(curveElementName).style.display = 'none';
|
}
|
|
return pixelPoints;
|
};
|
//绘制曲线(流量汽蚀)
|
var createCurveNPSH = function (curveElementName, points, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (points == null || m_coordinatePara.SpaceNPSH < 0.02) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
|
var pixelPoints = [];
|
for (var v = 0; v < points.length; v++) {
|
var pt = points[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueNPSH(pt.Y);
|
pixelPoints.push({ "X": x, "Y": y });
|
}
|
|
return createCurveNPSH_pixel(curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType);
|
};
|
//绘制曲线(流量功率) : 像素点
|
var createCurveNPSH_pixel = function (curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType) {
|
if (pixelPoints == null || pixelPoints.length < 3) {
|
return null;
|
}
|
if (curveElementName == null) {
|
return null;
|
}
|
var pathValue = transBezierCurveToPath(pixelPoints);
|
if (pathValue == null || pathValue == undefined)
|
return;
|
//有时会报错,加上这个就没事 tangxu 20151122
|
if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) {
|
return;
|
}
|
var style = {
|
"stroke-width": "2px",
|
"stroke": m_displayStyle.ColorNPSH,
|
"fill": "none",
|
"fill-opacity": "0.5",
|
//"stroke-dasharray":"5 3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
if (curveWidth != null) {
|
style["stroke-width"] = curveWidth;
|
}
|
if (curveColor != null) {
|
style["stroke"] = curveColor;
|
}
|
if (curveDashType != null) {
|
style["stroke-dasharray"] = curveDashType;//'10, 10';//'10, 10, 5, 5'
|
}
|
m_svg.createPath(curveElementName, pathValue.join(''), {
|
"id": curveElementName
|
}, style);
|
if (curveIsDisp != null && !curveIsDisp) {
|
document.getElementById(curveElementName).style.display = 'none';
|
}
|
};
|
//清理
|
var ClearCurveElement = function () {
|
|
|
|
|
};
|
|
|
|
|
//绘制等效线
|
var drawEquepEtaCurveList = function () {
|
//
|
if (m_chartObject.EqualParaCurvesE != null) {
|
for (var i = 0; i < m_chartObject.EqualParaCurvesE.length; i++) {
|
var points = m_chartObject.EqualParaCurvesE[i].PointInfo;
|
if (points.length >= 4) { //曲线
|
createCurveQH("EqualParaCurvesE" + i, points, 1, m_displayStyle.ColorEqualParaCurvesE);
|
drawTextByQH("EqualParaCurvesEText" + i, m_chartObject.EqualParaCurvesE[i].CurvePara + "%", points[0], m_displayStyle.EqualCurveSize, m_displayStyle.ColorEqualParaCurvesE, 2, 6, "middle");
|
} else if (points.length == 2 || points.length == 3) { //直线
|
createLineQH("EqualParaCurvesE" + i, points[0], points[1], 1, m_displayStyle.ColorEqualParaCurvesE);
|
drawTextByQH("EqualParaCurvesEText" + i, m_chartObject.EqualParaCurvesE[i].CurvePara + "%", points[0], m_displayStyle.EqualCurveSize, m_displayStyle.ColorEqualParaCurvesE, 2, 6, "middle");
|
}
|
else if (points.length == 1) {
|
createPointQH("EqualParaCurvesE" + i, points[0], 3, m_displayStyle.ColorEqualParaCurvesE);
|
drawTextByQH("EqualParaCurvesEText" + i, m_chartObject.EqualParaCurvesE[i].CurvePara + "%", points[0], m_displayStyle.EqualCurveSize, m_displayStyle.ColorEqualParaCurvesE, 2, 6, "middle");
|
}
|
}
|
}
|
};
|
|
|
//绘制水印(文字)
|
var drawTextWaterMark = function (text) {
|
if (!text) {
|
return;
|
}
|
|
var logoStyle = "-webkit-transform: rotate(5deg);-moz-transform: rotate(5deg);transform: rotate(15deg);fill:#000000;fill-opacity:0.6;font-weight:bold;stroke-width:1px;font-size:16px;z-index:0";
|
|
var w = 30;
|
var h = 80;
|
var isDrawSecond = true;
|
var left = (m_chartSize.DiagramRight - m_chartSize.DiagramLeft - text.length * w) / 2;
|
|
for (var i = 0; i < text.length; i++) {
|
m_svg.createText({
|
"opacity": 0.5,
|
"y": m_chartSize.SpaceTop + h + i * 10,
|
"x": m_chartSize.DiagramLeft + left + i * w
|
}, logoStyle, text[i], 0, "WaterMarkText1");
|
|
if (isDrawSecond) {
|
var endHeight = h + text.length * 10;//: h + text.length * 10 - 80;
|
m_svg.createText({
|
"opacity": 0.5,
|
"y": m_chartSize.UpDiagram.Bottom - endHeight + i * 10,
|
"x": m_chartSize.DiagramLeft + left + i * w
|
}, logoStyle, text[i], 0, "WaterMarkText1")
|
}
|
}
|
};
|
|
//绘制水印(图片)
|
var drawLogoWaterMark = function () {
|
var watermark_img_url = "/static/img/watermark/default.png";
|
|
var img_watermark = new Image()
|
img_watermark.src = watermark_img_url;
|
img_watermark.onload = function () {
|
|
var watermark_image_width_real = img_watermark.width
|
var watermark_image_height_real = img_watermark.height;
|
|
var ratio_byHeight = m_chartSize.TotalHeight * 0.2 / watermark_image_height_real;
|
var ratio_byWidth = m_chartSize.TotalWidth * 0.2 / watermark_image_width_real;
|
|
var ratio_waterMark = Math.min(ratio_byHeight, ratio_byWidth);
|
|
var watermark_image_width = watermark_image_width_real * ratio_waterMark;
|
var watermark_image_height = watermark_image_height_real * ratio_waterMark;
|
|
var logoStyle = "-webkit-transform: rotate(5deg);-moz-transform: rotate(5deg);transform: rotate(15deg);fill:#000000;fill-opacity:0.6;font-weight:bold;stroke-width:1px;font-size:16px;z-index:0";
|
var logoPosi1 = {
|
"opacity": 0.8,
|
"y": m_chartSize.TotalHeight * 1 / 4 - watermark_image_height / 2,
|
"x": m_chartSize.TotalWidth * 1 / 4 - watermark_image_width / 2,
|
"width": watermark_image_width,
|
"height": watermark_image_height
|
}
|
m_svg.createImage(logoPosi1, logoStyle, "WaterMarkImage2", watermark_img_url);
|
|
var logoPosi2 = {
|
"opacity": 0.8,
|
"y": m_chartSize.TotalHeight * 3 / 4 - watermark_image_height / 2,
|
"x": m_chartSize.TotalWidth * 1 / 4 - watermark_image_width / 2,
|
"width": watermark_image_width,
|
"height": watermark_image_height
|
}
|
m_svg.createImage(logoPosi2, logoStyle, "WaterMarkImage2", watermark_img_url);
|
|
|
var logoPosi3 = {
|
"opacity": 0.8,
|
"y": m_chartSize.TotalHeight * 1 / 4 - watermark_image_height / 2,
|
"x": m_chartSize.TotalWidth * 3 / 4 - watermark_image_width / 2,
|
"width": watermark_image_width,
|
"height": watermark_image_height
|
}
|
m_svg.createImage(logoPosi3, logoStyle, "WaterMarkImage3", watermark_img_url);
|
|
var logoPosi4 = {
|
"opacity": 0.8,
|
"y": m_chartSize.TotalHeight * 3 / 4 - watermark_image_height / 2,
|
"x": m_chartSize.TotalWidth * 3 / 4 - watermark_image_width / 2,
|
"width": watermark_image_width,
|
"height": watermark_image_height
|
}
|
m_svg.createImage(logoPosi4, logoStyle, "WaterMarkImage4", watermark_img_url);
|
}
|
};
|
//产生装置曲线
|
var drawEquipmentCurve = function () {
|
var equipmentCurveElement = document.getElementById("EquipmentCurve");
|
if (equipmentCurveElement) {
|
equipmentCurveElement.remove();
|
}
|
if (m_chartObject.EquipmentSectPt == null)
|
return;
|
var pointNumber = 20;
|
var EquipmentCurve = [];
|
var space = m_chartObject.EquipmentSectPt.X / (pointNumber - 1);
|
var k = (m_chartObject.EquipmentSectPt.Y - m_equipZeroH) / (m_chartObject.EquipmentSectPt.X * m_chartObject.EquipmentSectPt.X);
|
for (var i = 0; i < pointNumber; i++) {
|
var pt = {};
|
pt.X = space * i;
|
pt.Y = m_equipZeroH + k * pt.X * pt.X;
|
EquipmentCurve.push(pt);
|
}
|
createCurveQH("EquipmentCurve", EquipmentCurve, 1, m_displayStyle.ColorEquipment, m_displayStyle.isDispEquipmentCurve);
|
};
|
//查询查询竖直指导线
|
var drawQueryIndicatVertLine = function () {
|
|
if (document.getElementById("infoDv4VerticalLine")) {
|
var infoDiv = document.getElementById("infoDv4VerticalLine");
|
if (infoDiv) {
|
infoDiv.parentNode.removeChild(infoDiv);
|
}
|
}
|
|
//先创建用于放置查询信息的Div
|
var htmlDiv = "<lable style='font-size:7px'>" + getTranslateString("流量") + "</label>";
|
var infoDiv = document.createElement('div');
|
infoDiv.id = 'infoDv4VerticalLine';
|
infoDiv.style.position = 'relative';
|
infoDiv.style.color = 'gray';
|
infoDiv.style.fontSize = '9px';
|
infoDiv.style.textAlign = 'left';
|
infoDiv.style.width = '120px';
|
infoDiv.style.left = (m_chartSize.DiagramRight - 125) + 'px';
|
infoDiv.style.top = (12 - m_chartSize.TotalHeight) + 'px';
|
infoDiv.innerHTML = htmlDiv;
|
infoDiv.style.display = 'none';
|
document.getElementById(m_divChartName).appendChild(infoDiv);
|
|
m_infoDv4VerticalLine = document.getElementById("infoDv4VerticalLine");
|
|
|
var attr4verticalLine = {
|
"stroke": "rgb(136 136 221)",
|
"stroke-width": "5",
|
"fill": "none",
|
"zIndex": 100,
|
"stroke-dasharray": "10 3",
|
"cursor": 'pointer',
|
"stroke-opacity": '1',
|
"shape-rendering": "geometricPrecision",
|
};
|
|
var xStartValuePixel = (m_chartSize.DiagramLeft + m_chartSize.DiagramRight) / 2; // 开始位置
|
|
|
//创建竖直线
|
var pathValue1 = [];
|
var vertialLinePathName1 = "verticalLine1";
|
pathValue1.push("M ", xStartValuePixel, " ", m_chartSize.UpDiagram.Up, " L ", xStartValuePixel, " ", m_chartSize.DownDiagram.Bottom);
|
m_svg.createPath(vertialLinePathName1, pathValue1.join(''), {
|
id: vertialLinePathName1
|
}, attr4verticalLine, null);
|
m_queryInfoIndicatorLineV = document.getElementById(vertialLinePathName1);
|
|
|
|
|
|
drawQueryDataInfo(xStartValuePixel);
|
|
|
var isMoveVerticalLine = false;
|
//m_svg.getPathByName("verticalLine")
|
|
m_queryInfoIndicatorLineV.mousedown(function (e) {
|
isMoveVerticalLine = true;
|
//WebApp.stopDefault(e);
|
e.preventDefault();
|
});
|
|
|
document.addEventListener('mousemove', function (e) {
|
|
if (isMoveVerticalLine) {
|
var svg_root = m_svg.getRootNode();
|
var svg = document.querySelector(svg_root);
|
|
var e = window.event || e;
|
if (e.clientX - svg.offset().left > m_chartSize.DiagramLeft &&
|
m_chartSize.DiagramRight + svg.offset().left - e.clientX > 0 &&
|
e.clientY - svg.offset().top > m_chartSize.DiagramTop &&
|
m_chartSize.DiagramBottom + svg.offset().top - e.clientY > 0) {
|
//当前鼠标位置 x的像素
|
var xPixel = parseFloat(e.clientX - svg.offset().left);
|
//
|
drawQueryDataInfo(xPixel);
|
//修改位置
|
if (m_queryInfoIndicatorLineV) {
|
var pathValue1 = [];
|
pathValue1.push("M ", xPixel, " ", m_chartSize.UpDiagram.Up, " L ", xPixel, " ", m_chartSize.DownDiagram.Bottom);
|
m_queryInfoIndicatorLineV.attr("d", pathValue1.join(''));
|
}
|
}
|
}
|
})
|
document.addEventListener('mouseup', function (e) {
|
if (isMoveVerticalLine) {
|
isMoveVerticalLine = false;
|
}
|
});
|
|
|
//设置显示
|
setQueryIndicatVertLineVisible(m_dispVerticalLine);
|
};
|
//获取x在curve的(X Y)点值 (像素点)
|
var getBezierPointY = function (curve, x) {
|
if (curve == null)
|
return null;
|
var iPtCount = curve.length;
|
|
if (x < curve[0].Point0.X - 1) {
|
return null;
|
}
|
if (x > curve[iPtCount - 1].Point3.X + 1) {
|
return null;
|
}
|
|
for (var i = 0; i < iPtCount; i++) {
|
if (x == curve[i].Point0.X) {
|
return {
|
X: curve[i].Point0.X, Y: curve[i].Point0.Y
|
};
|
}
|
if (x == curve[i].Point3.X) {
|
return {
|
X: curve[i].Point3.X, Y: curve[i].Point3.Y
|
};
|
}
|
if (x > curve[i].Point0.X && x < curve[i].Point3.X) {
|
var ptBizer = curve[i];
|
//
|
try {
|
|
var minDis = Math.abs(ptBizer.Point3.X - ptBizer.Point0.X);
|
var sectY = null;
|
var sectX = null;
|
for (var uu = 0; uu <= 1; uu = uu + 0.05) {
|
var x0 = ptBizer.Point0.X * uu * uu * uu;
|
var x1 = 3 * ptBizer.Point1.X * uu * uu * (1 - uu);
|
var x2 = 3 * ptBizer.Point2.X * uu * (1 - uu) * (1 - uu);
|
var x3 = ptBizer.Point3.X * (1 - uu) * (1 - uu) * (1 - uu);
|
|
var curveX = x0 + x1 + x2 + x3;
|
if (Math.abs(curveX - x) < minDis) {
|
var y0 = ptBizer.Point0.Y * uu * uu * uu;
|
var y1 = 3 * ptBizer.Point1.Y * uu * uu * (1 - uu);
|
var y2 = 3 * ptBizer.Point2.Y * uu * (1 - uu) * (1 - uu);
|
var y3 = ptBizer.Point3.Y * (1 - uu) * (1 - uu) * (1 - uu);
|
minDis = Math.abs(curveX - x);
|
sectY = y0 + y1 + y2 + y3;
|
sectX = curveX;
|
}
|
}
|
//
|
if (sectY != null && sectX != null) {
|
return {
|
X: sectX, Y: sectY
|
};
|
}
|
}
|
catch (ex) {
|
//alert(ex.message);
|
console.log("getBezierPointY error", curve, x)
|
return null;
|
}
|
}
|
}
|
|
if (x > curve[iPtCount - 1].Point3.X - 1 && x < curve[iPtCount - 1].Point3.X + 5) {
|
return {
|
X: curve[iPtCount - 1].Point3.X, Y: curve[iPtCount - 1].Point3.Y
|
};
|
}
|
|
return null;
|
};
|
//获取x在curve的(X Y)点值 (像素点)
|
var getBezierPointX = function (curve, y) {
|
if (curve == null)
|
return null;
|
var iPtCount = curve.length;
|
|
if (y < curve[0].Point0.Y && y < curve[iPtCount - 1].Point3.Y) {
|
return null;
|
}
|
if (y > curve[0].Point0.Y && y > curve[iPtCount - 1].Point3.Y) {
|
return null;
|
}
|
|
for (var i = 0; i < iPtCount; i++) {
|
var ptBizer = curve[i];
|
|
if (y < ptBizer.Point0.Y && y < ptBizer.Point3.Y) {
|
continue;
|
}
|
if (y > ptBizer.Point0.Y && y > ptBizer.Point3.Y) {
|
continue;
|
}
|
|
//
|
try {
|
var minDis = Math.abs(ptBizer.Point3.Y - ptBizer.Point0.Y);
|
|
var sectY = null;
|
var sectX = null;
|
for (var uu = 0; uu <= 1; uu = uu + 0.05) {
|
var x0 = ptBizer.Point0.X * uu * uu * uu;
|
var x1 = 3 * ptBizer.Point1.X * uu * uu * (1 - uu);
|
var x2 = 3 * ptBizer.Point2.X * uu * (1 - uu) * (1 - uu);
|
var x3 = ptBizer.Point3.X * (1 - uu) * (1 - uu) * (1 - uu);
|
|
var y0 = ptBizer.Point0.Y * uu * uu * uu;
|
var y1 = 3 * ptBizer.Point1.Y * uu * uu * (1 - uu);
|
var y2 = 3 * ptBizer.Point2.Y * uu * (1 - uu) * (1 - uu);
|
var y3 = ptBizer.Point3.Y * (1 - uu) * (1 - uu) * (1 - uu);
|
|
var curveX = x0 + x1 + x2 + x3;
|
var curveY = y0 + y1 + y2 + y3;
|
|
if (Math.abs(curveY - y) < minDis) {
|
minDis = Math.abs(curveY - y);
|
sectY = curveY
|
sectX = curveX;
|
}
|
}
|
//
|
if (sectY != null && sectX != null) {
|
return {
|
X: sectX, Y: sectY
|
};
|
}
|
}
|
catch (ex) {
|
//alert(ex.message);
|
return null;
|
}
|
}
|
|
return null;
|
};
|
//绘制/显示 参数查询信息
|
var drawQueryDataInfo = function (xPixel) {//x的像素
|
if (xPixel == null)
|
return;
|
if (m_maxSpeedCurve == null)
|
return;
|
if (m_maxSpeedCurve.PixelQH == null)
|
return;
|
//流量
|
//console.log(m_coordinatePara,m_chartSize, xPixel);
|
let flow_stdUnit = getActualValueQ(xPixel);
|
if (flow_stdUnit == null)
|
return;
|
//console.log(flow_stdUnit);
|
if (flow_stdUnit < 0.1)
|
return;
|
|
var flow_info = {};
|
flow_info.text = getTranslateString("流量");
|
flow_info.value = UnitHelper.getDispValueQ(UnitHelper.ConvertQ_fromM3H(m_unit.Q, flow_stdUnit));
|
flow_info.unit = UnitHelper.GetUnitNameQ(m_unit.Q);
|
if (flow_info.value == null || flow_info.value == "")
|
return;
|
// console.log(flow_info);
|
|
//扬程
|
var head_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQH, xPixel);
|
if (head_pixel_pt == null)
|
return;
|
var head_stdUnit = getActualValueH(head_pixel_pt.Y);
|
var head_info = {};
|
head_info.text = getTranslateString("扬程");
|
head_info.unit = UnitHelper.GetUnitNameH(m_unit.H);
|
head_info.value = UnitHelper.getDispValueH(UnitHelper.ConvertH_fromM(m_unit.H, head_stdUnit));
|
|
//效率
|
var eff_info = {};
|
eff_info.value = "";
|
if (m_isDispCurveQE) {
|
var eta_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel);
|
|
if (eta_pixel_pt != null) {
|
var eta_stdUnit = getActualValueE(eta_pixel_pt.Y);
|
|
eff_info.text = getTranslateString("效率");
|
eff_info.value = parseFloat(eta_stdUnit.toFixed(1));
|
eff_info.unit = "%";
|
}
|
}
|
|
//功率
|
var power_info = {};
|
power_info.value = "";
|
var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel);
|
if (power_pixel_pt != null) {
|
var power_stdUnit = getActualValueP(power_pixel_pt.Y);
|
power_info.text = getTranslateString("功率");
|
power_info.value = UnitHelper.getDispValueP(UnitHelper.ConvertP_fromKW(m_unit.P, power_stdUnit));
|
power_info.unit = UnitHelper.GetUnitNameP(m_unit.P);
|
}
|
|
|
var npsh_info = {};//汽蚀
|
npsh_info.text = getTranslateString("汽蚀");
|
npsh_info.value = '';
|
npsh_info.unit = "m";
|
|
if (m_maxSpeedCurve.PixelNPSH != null && m_isHaveNpsh) {
|
var npsh_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelNPSH, xPixel);
|
//console.log(npsh_pixel_pt)
|
if (npsh_pixel_pt != null) {
|
var npsh_stdUnit = getActualValueNPSH(npsh_pixel_pt.Y);
|
npsh_info.value = UnitHelper.formatToFixed(parseFloat(npsh_stdUnit), 1);
|
}
|
}
|
|
var tip_html = "";
|
var flow_html = flow_info.text + ": " + flow_info.value + " " + flow_info.unit;
|
tip_html = flow_html;
|
//console.log("flow_info",flow_info);
|
|
var head_html = head_info.text + ": " + head_info.value + " " + head_info.unit;
|
tip_html += "</br>" + head_html;
|
//console.log("head_info",head_info);
|
|
if (eff_info.value != "") {
|
var eff_html = eff_info.text + ": " + eff_info.value + " " + eff_info.unit;
|
tip_html += "</br>" + eff_html;
|
}
|
|
if (power_info.value != "") {
|
var power_html = power_info.text + ": " + power_info.value + " " + power_info.unit;
|
tip_html += "</br>" + power_html;
|
}
|
|
if (npsh_info.value != "") {
|
var npsh_html = npsh_info.text + ": " + npsh_info.value + " " + npsh_info.unit;
|
tip_html += "</br>" + npsh_html;
|
}
|
|
m_infoDv4VerticalLine.show().html(tip_html);
|
|
|
|
//获取查询曲线查询得到的数据 给参数查询使用
|
if (onChangeQueryDataCb != null) {
|
onChangeQueryDataCb({
|
Q: flow_info,
|
H: head_info,
|
E: eff_info,
|
P: power_info,
|
NPSH: npsh_info
|
})
|
}
|
|
};
|
//根据流量获取点
|
var getGrpPointInWrkCurveByFlow = function (flow_stdUnit) {
|
if (flow_stdUnit == null)
|
return null;
|
if (flow_stdUnit < 0.1)
|
return null;
|
if (m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQH)
|
return null;
|
|
//var UnitHelper.ConvertQ_fromM3H(m_unit.Q, flow_stdUnit)
|
var xPixel = getPixelValueQ(flow_stdUnit);
|
|
//扬程
|
var head_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQH, xPixel);
|
if (head_pixel_pt == null)
|
return;
|
var head_stdUnit = getActualValueH(head_pixel_pt.Y);
|
|
//效率
|
var eta_stdUnit = 0;
|
if (m_isDispCurveQE) {
|
var eta_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel);
|
if (eta_pixel_pt != null) {
|
eta_stdUnit = getActualValueE(eta_pixel_pt.Y);
|
eta_stdUnit = parseFloat(eta_stdUnit.toFixed(1));
|
}
|
}
|
|
//功率
|
var power_stdUnit = 0;
|
var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel);
|
if (power_pixel_pt != null) {
|
power_stdUnit = getActualValueP(power_pixel_pt.Y);
|
}
|
|
|
var npsh_stdUnit = 0;
|
if (m_maxSpeedCurve.PixelNPSH != null) {
|
var npsh_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelNPSH, xPixel);
|
if (npsh_pixel_pt != null) {
|
npsh_stdUnit = getActualValueNPSH(npsh_pixel_pt.Y);
|
}
|
}
|
|
var grp_pt = {};
|
grp_pt.Q = flow_stdUnit;
|
grp_pt.H = head_stdUnit;
|
grp_pt.E = eta_stdUnit;
|
grp_pt.P = power_stdUnit;
|
grp_pt.NPSH = npsh_stdUnit;
|
|
return grp_pt;
|
};
|
//查询线
|
var m_infoDv4VerticalLine;
|
var m_queryInfoIndicatorLineV;
|
var m_dispVerticalLine = false;
|
var onChangeQueryDataCb = null;//查询外部回调
|
//设置是否显示
|
var setQueryIndicatVertLineVisible = function (disp) {
|
m_dispVerticalLine = disp;
|
if (disp) {
|
m_infoDv4VerticalLine.show();
|
m_queryInfoIndicatorLineV.show();
|
}
|
else {
|
m_infoDv4VerticalLine.hide();
|
m_queryInfoIndicatorLineV.hide();
|
}
|
};
|
//绘制图表(所有曲线)
|
var drawDiagramCurve = function () {
|
var curveWidth = 2;
|
var maxCurveQHElement = document.getElementById("MaxCurveQH");
|
if (maxCurveQHElement) {
|
maxCurveQHElement.remove();
|
}
|
|
var maxCurveQPElement = document.getElementById("MaxCurveQP");
|
if (maxCurveQPElement) {
|
maxCurveQPElement.remove();
|
}
|
|
var maxCurveQHTextElement = document.getElementById("MaxCurveQHText");
|
if (maxCurveQHTextElement) {
|
maxCurveQHTextElement.remove();
|
}
|
|
var maxCurveQPTextElement = document.getElementById("MaxCurveQPText");
|
if (maxCurveQPTextElement) {
|
maxCurveQPTextElement.remove();
|
}
|
|
if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) {
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
var id = m_simuSpeedCurves[i].id;
|
var curveQHElement = document.getElementById("SimuCurveQH" + id);
|
if (curveQHElement) {
|
curveQHElement.remove();
|
}
|
|
var curveQPElement = document.getElementById("SimuCurveQP" + id);
|
if (curveQPElement) {
|
curveQPElement.remove();
|
}
|
|
var curveQHTextElement = document.getElementById("SimuCurveQHText" + id);
|
if (curveQHTextElement) {
|
curveQHTextElement.remove();
|
}
|
|
var curveQPTextElement = document.getElementById("SimuCurveQPText" + id);
|
if (curveQPTextElement) {
|
curveQPTextElement.remove();
|
}
|
}
|
}
|
|
//
|
m_maxSpeedCurve.color = "#003a6c";
|
|
var curveMaxPathQH = createCurveQH("MaxCurveQH", m_maxSpeedCurve.RealQH, curveWidth, m_maxSpeedCurve.color);
|
var pointsQH = m_maxSpeedCurve.RealQH;
|
drawSpeedTextByQH("MaxCurveQHText", m_maxSpeedCurve.speed, pointsQH[pointsQH.length - 1], m_maxSpeedCurve.color);
|
|
|
//var curveMaxPathQE = createCurveQE("MaxCurveQE", m_maxSpeedCurve.RealQE, curveWidth, m_maxSpeedCurve.color);
|
var curveMaxPathQP = createCurveQP("MaxCurveQP", m_maxSpeedCurve.RealQP, curveWidth, m_maxSpeedCurve.color);
|
var pointsQP = m_maxSpeedCurve.RealQP;
|
drawSpeedTextByQP("MaxCurveQPText", m_maxSpeedCurve.speed, pointsQP[pointsQP.length - 1], m_maxSpeedCurve.color);
|
|
|
//
|
if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) {
|
m_simuSpeedCurves.forEach(element => {
|
drawSimuSpeedCurve(element);
|
});
|
}
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
|
|
|
//设计点
|
//drawDesignPoint();
|
|
|
|
|
//绘制水印
|
drawLogoWaterMark();
|
|
|
//装置曲线
|
//drawEquipmentCurve();
|
|
//查询指示线
|
//drawQueryIndicatVertLine();
|
|
//
|
//createMouseTipInfo();
|
}
|
//通知外部
|
var noticeCurveChanged = function () {
|
|
if (onChangeSpeedListCb != null) {
|
var list_speed_color = [];
|
m_simuSpeedCurves.forEach(element => {
|
list_speed_color.push({
|
id: element.id,
|
speed: element.speed,
|
color: element.color
|
})
|
});
|
onChangeSpeedListCb(list_speed_color);
|
}
|
}
|
//检查并刷新图表
|
var refreshDiagram = function () {
|
|
//console.log(m_coordinatePara)
|
|
drawDiagramCurve();
|
|
checkCoordRange();
|
|
//console.log(m_coordinatePara)
|
};
|
//检查坐标范围是否超过曲线范围
|
var checkCoordRange = function () {
|
var last_simu_curve = m_simuSpeedCurves[m_simuSpeedCurves.length - 1];
|
var curve_min_h = last_simu_curve.RealQH[m_maxSpeedCurve.RealQH.length - 1].Y;
|
var curve_min_p = last_simu_curve.RealQP[0].Y;
|
var isNeedRefresh = false;
|
for (var i = 0; i < 10; i++) {
|
|
var coord_min_h = m_coordinatePara.DispMinH - m_coordinatePara.SpaceH * i;
|
if (coord_min_h < 0)
|
break;
|
if (curve_min_h < coord_min_h)
|
continue;
|
|
if (i > 0) {
|
m_coordinatePara.StartLineNoH = m_coordinatePara.StartLineNoH - i;
|
m_coordinatePara.DispMinH = m_coordinatePara.DispMinH - m_coordinatePara.SpaceH * i;
|
isNeedRefresh = true;
|
}
|
break;
|
}
|
|
for (var i = 0; i < 10; i++) {
|
|
var coord_min_p = m_coordinatePara.DispMinP - m_coordinatePara.SpaceP * i;
|
if (coord_min_p < 0)
|
break;
|
if (curve_min_p < coord_min_p)
|
continue;
|
|
if (i > 0) {
|
m_coordinatePara.StartLineNoP = m_coordinatePara.StartLineNoP - i;
|
m_coordinatePara.DispMinP = m_coordinatePara.DispMinP - m_coordinatePara.SpaceP * i;
|
isNeedRefresh = true;
|
}
|
break;
|
}
|
if (isNeedRefresh) {
|
document.getElementById(m_divChartName).innerHTML = '';
|
|
//初始化面板尺寸
|
initialPanelSize();
|
|
drawDiagramPanel();
|
|
drawDiagramCurve();
|
}
|
}
|
//添加速度
|
var drawSimuSpeedCurve = function (simuCurve) {
|
//console.log(simuCurve)
|
var speed = simuCurve.speed;
|
if (speed < 10)
|
return;
|
|
//console.log(m_maxSpeedCurve.RealQH)
|
var simuCurveQH = [];
|
var rated_speed = m_maxSpeedCurve.speed;
|
m_maxSpeedCurve.RealQH.forEach(pt => {
|
var simu_pt = {};
|
simu_pt.X = pt.X * speed / rated_speed;
|
simu_pt.Y = pt.Y * speed * speed / (rated_speed * rated_speed);
|
simuCurveQH.push(simu_pt);
|
});
|
simuCurve.RealQH = simuCurveQH;
|
|
|
var simuCurveQP = [];
|
m_maxSpeedCurve.RealQP.forEach(pt => {
|
var simu_pt = {};
|
simu_pt.X = pt.X * speed / rated_speed;
|
simu_pt.Y = pt.Y * speed * speed * speed / (rated_speed * rated_speed * rated_speed);
|
simuCurveQP.push(simu_pt);
|
});
|
simuCurve.RealQP = simuCurveQP;
|
|
var curveWidth = 2;
|
if (simuCurve.curveWidth)
|
curveWidth = simuCurve.curveWidth;
|
|
var curveColor = simuCurve.color;
|
var curve_id = simuCurve.id;
|
|
var curveQHElement = document.getElementById("SimuCurveQH" + curve_id);
|
if (curveQHElement) {
|
curveQHElement.remove();
|
}
|
|
var curveQPElement = document.getElementById("SimuCurveQP" + curve_id);
|
if (curveQPElement) {
|
curveQPElement.remove();
|
}
|
|
var curveQHTextElement = document.getElementById("SimuCurveQHText" + curve_id);
|
if (curveQHTextElement) {
|
curveQHTextElement.remove();
|
}
|
|
var curveQPTextElement = document.getElementById("SimuCurveQPText" + curve_id);
|
if (curveQPTextElement) {
|
curveQPTextElement.remove();
|
}
|
|
var int_speed = Math.round(speed) ;
|
|
var curvePathQH = createCurveQH("SimuCurveQH" + curve_id, simuCurveQH, curveWidth, curveColor);
|
drawSpeedTextByQH("SimuCurveQHText" + curve_id, int_speed, simuCurveQH[simuCurveQH.length - 1], curveColor);
|
|
var curvePathQP = createCurveQP("SimuCurveQP" + curve_id, simuCurveQP, curveWidth, curveColor);
|
drawSpeedTextByQP("SimuCurveQPText" + curve_id, int_speed, simuCurveQP[simuCurveQP.length - 1], curveColor);
|
};
|
//
|
var createGridLineDiagram_Whole = function () {
|
if (m_coordinatePara == null) {
|
return;
|
}
|
|
var attr = {
|
"stroke": m_displayStyle.ColorGridLine,
|
"stroke-width": "1",
|
"fill": "none",
|
"zIndex": 10
|
};
|
|
//产生网格线竖直方向
|
for (var i = 0; i <= m_coordinatePara.GridNumberX; i++) {
|
var distance = m_chartSize.SpaceGridX * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.SpaceTop, " L ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.UpDiagram.Bottom);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
}
|
|
//产生网格线水平方向
|
for (var i = 0; i <= m_coordinatePara.GridNumberY; i++) {
|
var distance = m_chartSize.UpDiagram.SpaceGridY * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft, " ", m_chartSize.SpaceTop + distance, " L ", m_chartSize.DiagramRight, " ", m_chartSize.SpaceTop + distance);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
}
|
|
|
};
|
//绘制面板(分离)
|
var createGridLineDiagram_TwoPanel = function () {
|
if (m_coordinatePara == null) {
|
return;
|
}
|
|
var attr = {
|
"stroke": m_displayStyle.ColorGridLine,
|
"stroke-width": "1",
|
"fill": "none",
|
"zIndex": 10
|
};
|
|
//产生网格线竖直方向
|
for (var i = 0; i <= m_coordinatePara.GridNumberX; i++) {
|
var distance = m_chartSize.SpaceGridX * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.UpDiagram.Up, " L ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.UpDiagram.Bottom);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
|
//console.log(m_chartSize.DiagramLeft + distance , m_chartSize.UpDiagram.Up, m_chartSize.DiagramLeft + distance, m_chartSize.UpDiagram.Bottom)
|
}
|
|
|
|
for (var i = 0; i <= m_coordinatePara.GridNumberX; i++) {
|
var distance = m_chartSize.SpaceGridX * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.DownDiagram.Up, " L ", m_chartSize.DiagramLeft + distance, " ", m_chartSize.DownDiagram.Bottom);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
}
|
|
//产生网格线水平方向
|
for (var i = 0; i <= m_chartSize.UpDiagram.GridNumberY; i++) {
|
var distance = m_chartSize.UpDiagram.SpaceGridY * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft, " ", m_chartSize.UpDiagram.Up + distance, " L ", m_chartSize.DiagramRight, " ", m_chartSize.UpDiagram.Up + distance);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
}
|
|
for (var i = 0; i <= m_chartSize.DownDiagram.GridNumberY; i++) {
|
var distance = m_chartSize.DownDiagram.SpaceGridY * i;
|
var valueTemp = [];
|
valueTemp.push("M ", m_chartSize.DiagramLeft, " ", m_chartSize.DownDiagram.Up + distance, " L ", m_chartSize.DiagramRight, " ", m_chartSize.DownDiagram.Up + distance);
|
m_svg.createPath(null, valueTemp.join(''), attr, null);
|
}
|
};
|
//转成Bezier曲线模型
|
var transBezierCurveModel = function (pixelPoints) {
|
if (pixelPoints == null || pixelPoints.length < 4)
|
return null;
|
|
var iPointCout = pixelPoints.length;
|
var a = 0.09;
|
var b = 0.09;
|
var controlPoint = [];
|
|
for (var i = 0; i < iPointCout - 1; i++) {
|
var bezier = {};
|
bezier.Point0 = pixelPoints[i];
|
if (i == 0) {
|
var x1 = pixelPoints[i].X + a * (pixelPoints[i + 1].X - pixelPoints[i].X);
|
var y1 = pixelPoints[i].Y + a * (pixelPoints[i + 1].Y - pixelPoints[i].Y);
|
bezier.Point1 = {
|
"X": x1,
|
"Y": y1
|
};
|
}
|
else {
|
var x1 = pixelPoints[i].X + a * (pixelPoints[i + 1].X - pixelPoints[i - 1].X);
|
var y1 = pixelPoints[i].Y + a * (pixelPoints[i + 1].Y - pixelPoints[i - 1].Y);
|
bezier.Point1 = {
|
"X": x1,
|
"Y": y1
|
}
|
}
|
|
if (i == iPointCout - 2) {
|
var x2 = pixelPoints[i + 1].X - b * (pixelPoints[i + 1].X - pixelPoints[i].X);
|
var y2 = pixelPoints[i + 1].Y - b * (pixelPoints[i + 1].Y - pixelPoints[i].Y);
|
bezier.Point2 = {
|
"X": x2,
|
"Y": y2
|
}
|
}
|
else {
|
var x2 = pixelPoints[i + 1].X - b * (pixelPoints[i + 2].X - pixelPoints[i].X);
|
var y2 = pixelPoints[i + 1].Y - b * (pixelPoints[i + 2].Y - pixelPoints[i].Y);
|
bezier.Point2 = {
|
"X": x2,
|
"Y": y2
|
}
|
}
|
|
bezier.Point3 = pixelPoints[i + 1];
|
controlPoint.push(bezier);
|
}
|
return controlPoint;
|
};
|
|
//转成曲线路径
|
var transBezierCurveToPath = function (pixelPoints) {
|
var bezierCurveValue = transBezierCurveModel(pixelPoints);
|
if (bezierCurveValue == null) {
|
return;
|
}
|
var pathValue = [];
|
for (var i = 0; i < bezierCurveValue.length; i++) {
|
var b_pt = bezierCurveValue[i];
|
if (i == 0) {
|
pathValue.push("M ", b_pt.Point0.X, " ", b_pt.Point0.Y);
|
pathValue.push(" C ", b_pt.Point1.X, " ", b_pt.Point1.Y, " ",
|
b_pt.Point2.X, " ", b_pt.Point2.Y, " ", b_pt.Point3.X, " ", b_pt.Point3.Y);
|
}
|
else {
|
pathValue.push(" L ", b_pt.Point0.X, " ", b_pt.Point0.Y);
|
pathValue.push(" C ", b_pt.Point1.X, " ", b_pt.Point1.Y, " ",
|
b_pt.Point2.X, " ", b_pt.Point2.Y, " ", b_pt.Point3.X, " ", b_pt.Point3.Y);
|
}
|
if (i == bezierCurveValue.length - 1) {
|
pathValue.push(" L ", b_pt.Point3.X, " ", b_pt.Point3.Y);
|
}
|
}
|
return pathValue;
|
};
|
|
//返回标准单位下的值
|
var getActualValueQ = function (pixelValue) {
|
var actualMinValue = m_coordinatePara.DispMinQ;
|
var actualMaxValue = m_coordinatePara.DispMaxQ;
|
var pixelMinValue = m_chartSize.DiagramLeft;
|
var pixelMaxValue = m_chartSize.DiagramRight;
|
return (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue;
|
};
|
var getActualValueH = function (pixelValue) {
|
var actualMinValue = m_coordinatePara.DispMinH;
|
var actualMaxValue = m_coordinatePara.DispMaxH;
|
var pixelMinValue = m_chartSize.PanelH.Bottom;
|
var pixelMaxValue = m_chartSize.PanelH.Up;
|
|
var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue;
|
//console.log("getActualValueH", actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue);
|
|
return actualValue;
|
};
|
var getActualValueE = function (pixelValue) {
|
var actualMinValue = m_coordinatePara.DispMinE;
|
var actualMaxValue = m_coordinatePara.DispMaxE;
|
var pixelMinValue = m_chartSize.PanelE.Bottom;
|
var pixelMaxValue = m_chartSize.PanelE.Up;
|
|
var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue;
|
//console.log("getActualValueE",actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue);
|
|
return actualValue;
|
};
|
var getActualValueP = function (pixelValue) {
|
var actualMinValue = m_coordinatePara.DispMinP;
|
var actualMaxValue = m_coordinatePara.DispMaxP;
|
var pixelMinValue = m_chartSize.PanelP.Bottom;
|
var pixelMaxValue = m_chartSize.PanelP.Up;
|
return (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue;
|
};
|
var getActualValueNPSH = function (pixelValue) {
|
var actualMinValue = m_coordinatePara.DispMinNPSH;
|
var actualMaxValue = m_coordinatePara.DispMaxNPSH;
|
var pixelMinValue = m_chartSize.PanelNPSH.Bottom;
|
var pixelMaxValue = m_chartSize.PanelNPSH.Up;
|
var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue;
|
// console.log("getActualValueNPSH",actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue);
|
return actualValue;
|
};
|
|
// actualValue 是标准单位下的值
|
var getPixelValueQ = function (actualValue) {
|
var actualMinValue = m_coordinatePara.DispMinQ;
|
var actualMaxValue = m_coordinatePara.DispMaxQ;
|
var pixelMinValue = m_chartSize.DiagramLeft;
|
var pixelMaxValue = m_chartSize.DiagramRight;
|
|
return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue;
|
};
|
var getPixelValueH = function (actualValue) {
|
|
var actualMinValue = m_coordinatePara.DispMinH;
|
var actualMaxValue = m_coordinatePara.DispMaxH;
|
var pixelMinValue = m_chartSize.PanelH.Bottom;
|
var pixelMaxValue = m_chartSize.PanelH.Up;
|
|
if (actualMaxValue == actualMinValue)
|
return actualMinValue;
|
|
var v = (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue;
|
//console.log("getPixelValueH",actualValue,v, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue);
|
return v
|
};
|
var getPixelValueE = function (actualValue) {
|
var actualMinValue = m_coordinatePara.DispMinE;
|
var actualMaxValue = m_coordinatePara.DispMaxE;
|
var pixelMinValue = m_chartSize.PanelE.Bottom;
|
var pixelMaxValue = m_chartSize.PanelE.Up;
|
if (actualMaxValue == actualMinValue)
|
return actualMinValue;
|
|
return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue;
|
};
|
var getPixelValueP = function (actualValue) {
|
var actualMinValue = m_coordinatePara.DispMinP;
|
var actualMaxValue = m_coordinatePara.DispMaxP;
|
var pixelMinValue = m_chartSize.PanelP.Bottom;
|
var pixelMaxValue = m_chartSize.PanelP.Up;
|
if (actualMaxValue == actualMinValue)
|
return actualMinValue;
|
|
return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue;
|
};
|
var getPixelValueNPSH = function (actualValue) {
|
var actualMinValue = m_coordinatePara.DispMinNPSH;
|
var actualMaxValue = m_coordinatePara.DispMaxNPSH;
|
var pixelMinValue = m_chartSize.PanelNPSH.Bottom;
|
var pixelMaxValue = m_chartSize.PanelNPSH.Up;
|
if (actualMaxValue == actualMinValue)
|
return actualMinValue;
|
|
return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue;
|
};
|
|
|
|
|
|
/** ----------------对外函数-------------------- **/
|
|
//设置设计点公差
|
this.SetUnit = function (unitQ, unitH, unitP,unitNPSH) {
|
m_unit.Q = unitQ;
|
m_unit.H = unitH;
|
m_unit.P = unitP;
|
if(unitNPSH > 0){
|
m_unit.NPSH = unitNPSH;
|
}
|
else{
|
m_unit.NPSH = 0;
|
}
|
};
|
//设置是否是单色显示
|
this.setMonorColor = function (isMonorColor) {
|
document.getElementById(m_divChartName).innerHTML = '';
|
setObjectColor(isMonorColor);
|
if (!initialSvg())
|
return;
|
|
drawDiagramPanel();
|
|
refreshDiagram();
|
};
|
//设置是否是单色显示
|
this.setWrkCurveInfo = function (curve) {
|
console.log(curve);
|
if (curve == null)
|
return;
|
//console.log(curve, 2992);
|
// drawDiagramPanel();
|
|
if (m_maxSpeedCurve == null)
|
return;
|
m_maxSpeedCurve.RealQH = curve.RealQH;
|
m_maxSpeedCurve.RealQE = curve.RealQE;
|
m_maxSpeedCurve.RealQP = curve.RealQP;
|
m_maxSpeedCurve.RealNPSH = curve.RealNPSH;
|
|
|
if (curve.RealNPSH == null) {
|
m_isHaveNpsh = false;
|
}
|
else {
|
m_isHaveNpsh = true;
|
}
|
//
|
refreshDiagram();
|
};
|
//添加转速
|
this.AddSpeedCurve = function (speed) {
|
speed = parseInt(speed);
|
if (speed < 10)
|
return null;
|
if (m_simuSpeedCurves == null)
|
m_simuSpeedCurves = [];
|
var isFind = false;
|
m_simuSpeedCurves.forEach(element => {
|
//console.log(element,speed)
|
if (speed == element.speed)
|
isFind = true;
|
});
|
if (isFind)
|
return null;
|
|
//获取没有用过的颜色
|
var curveColor = "#000000";
|
for (var c = 0; c < m_colorArray.length; c++) {
|
var isHaveColor = false;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
if (m_colorArray[c] == m_simuSpeedCurves[i].color) {
|
isHaveColor = true;
|
break;
|
}
|
}
|
if (!isHaveColor) {
|
curveColor = m_colorArray[c];
|
break;
|
}
|
}
|
|
m_curveMaxId++;
|
var speedItem = {
|
id: m_curveMaxId,
|
speed: speed,
|
color: curveColor,
|
curveWidth: 2
|
};
|
m_simuSpeedCurves.push(speedItem);
|
|
drawSimuSpeedCurve(speedItem);
|
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
|
return speedItem.color;
|
};
|
//修改转速
|
this.editSpeedById = function (id, speed) {
|
var speedItem = null;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
if (id == m_simuSpeedCurves[i].id) {
|
speedItem = m_simuSpeedCurves[i];
|
break;
|
}
|
}
|
if (speedItem == null)
|
return;
|
|
var origin_speed = speedItem.speed;
|
if (Math.abs(origin_speed - speed) < 2)
|
return;
|
|
speedItem.speed = speed;
|
|
|
|
drawSimuSpeedCurve(speedItem)
|
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
};
|
//修改颜色
|
this.editColorById = function (id, color) {
|
|
var speedItem = null;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
if (id == m_simuSpeedCurves[i].id) {
|
speedItem = m_simuSpeedCurves[i];
|
break;
|
}
|
}
|
if (speedItem == null)
|
return;
|
|
speedItem.color = color;
|
document.getElementById("SimuCurveQH" + speedItem.id).style.stroke = color;
|
|
document.getElementById("SimuCurveQP" + speedItem.id).style.stroke = color;
|
|
document.getElementById("SimuCurveQHText" + speedItem.id).style.fill = color;
|
|
document.getElementById("SimuCurveQPText" + speedItem.id).style.fill = color;
|
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
};
|
//删除转速
|
this.deleteCurveById = function (id) {
|
var index = -1;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
if (id == m_simuSpeedCurves[i].id) {
|
index = i;
|
break;
|
}
|
}
|
if (index < 0)
|
return;
|
|
m_simuSpeedCurves.splice(index, 1)
|
var curveQHElement = document.getElementById("SimuCurveQH" + id);
|
if (curveQHElement) {
|
curveQHElement.remove();
|
}
|
|
var curveQPElement = document.getElementById("SimuCurveQP" + id);
|
if (curveQPElement) {
|
curveQPElement.remove();
|
}
|
|
var curveQHTextElement = document.getElementById("SimuCurveQHText" + id);
|
if (curveQHTextElement) {
|
curveQHTextElement.remove();
|
}
|
|
var curveQPTextElement = document.getElementById("SimuCurveQPText" + id);
|
if (curveQPTextElement) {
|
curveQPTextElement.remove();
|
}
|
};
|
//设置容器
|
this.setContainerDiv = function (divChartName, divWidth, divHeight) {
|
m_divChartName = divChartName;
|
|
if (m_chartSize == null) {
|
m_chartSize = {};
|
}
|
|
if (divWidth != null) {
|
m_chartSize.TotalWidth = divWidth;
|
}
|
else {
|
m_chartSize.TotalWidth = document.getElementById(divChartName).clientWidth;
|
}
|
|
if (divHeight != null) {
|
m_chartSize.TotalHeight = divHeight;
|
}
|
else {
|
m_chartSize.TotalHeight = document.getElementById(divChartName).clientHeight;
|
}
|
//console.log(m_divChartName, m_chartSize.TotalWidth,m_chartSize.TotalHeight)
|
};
|
//设置语言
|
this.setLocalizationType = function (localizationType) {
|
m_localizationType = localizationType;
|
//console.log("localizationType:"+localizationType)
|
};
|
//设置工具提示栏
|
this.setToolTipName = function (toolTipName) {
|
m_toolTipContent = document.getElementById(toolTipName);
|
};
|
//获取查询曲线查询得到的数据 给参数查询使用
|
this.setChangeQueryDataCb = function (cb) {
|
onChangeQueryDataCb = cb;
|
};
|
//设置修改了列表,通知外部的回调
|
this.setChangeSpeedListCb = function (cb) {
|
onChangeSpeedListCb = cb;
|
};
|
//
|
this.setQueryIndicatVertLineVisible = function (isVisible) {
|
setQueryIndicatVertLineVisible(isVisible);
|
};
|
this.getQueryIndicatVertLineVisible = function () {
|
return m_dispVerticalLine;
|
};
|
|
//初始化图表(入口)
|
this.initialChart = function (ChartFullInfo, displayStyle) {
|
if (!m_divChartName)
|
return;
|
//console.log("initialChart ChartFullInfo", ChartFullInfo)
|
//清空
|
document.getElementById(m_divChartName).innerHTML = '';
|
|
if (ChartFullInfo.ChartObjectDict == null)
|
return;
|
if (ChartFullInfo.ChartObjectDict.Coordinate == null)
|
return;
|
|
m_designPointTolerance = PointToleranceConfig.GetDefaultTolerancePara();
|
|
|
//
|
m_pumpInfo = ChartFullInfo.BaseInfo;
|
|
m_maxSpeedCurve = {};
|
m_maxSpeedCurve.speed = m_pumpInfo.Ratedn;
|
//console.log("m_pumpInfo", m_pumpInfo)
|
|
m_chartPointPara = ChartFullInfo.ChartPointPara;
|
m_chartSetting = ChartFullInfo.SettingInfo;
|
m_chartObject = ChartFullInfo.ChartObjectDict;
|
|
//克隆一下,坐标和性能曲线的不一定一致,会修改
|
var objString_Coordinate = JSON.stringify(ChartFullInfo.ChartObjectDict.Coordinate);
|
m_coordinatePara = JSON.parse(objString_Coordinate);
|
|
|
this.SetUnit(//设置单位
|
m_chartSetting.UnitQ,
|
m_chartSetting.UnitH,
|
m_chartSetting.UnitP,
|
m_chartSetting.UnitNPSH );
|
|
//初始化速度列表
|
var simuSpeedList = [];
|
if (ChartFullInfo.MultiSpeedValues != null) {
|
var sss = ChartFullInfo.MultiSpeedValues.split(",");
|
sss.forEach(element => {
|
simuSpeedList.push(Math.round(parseFloat(element)));
|
});
|
}
|
else {
|
simuSpeedList.push(m_maxSpeedCurve.speed * 0.9);
|
simuSpeedList.push(m_maxSpeedCurve.speed * 0.8);
|
simuSpeedList.push(m_maxSpeedCurve.speed * 0.7);
|
simuSpeedList.push(m_maxSpeedCurve.speed * 0.6);
|
simuSpeedList.push(m_maxSpeedCurve.speed * 0.5);
|
}
|
|
m_simuSpeedCurves = [];
|
simuSpeedList.forEach((speed, indx) => {
|
//console.log(indx, speed)
|
m_curveMaxId++;
|
m_simuSpeedCurves.push({
|
speed: speed,
|
id: m_curveMaxId,
|
color: m_colorArray[indx],
|
curveWidth: 2
|
});
|
});
|
|
|
|
//初始化显示设置
|
initialDispStyle(displayStyle, m_chartSetting);
|
|
m_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two;
|
|
//初始化面板尺寸
|
initialPanelSize();
|
|
drawDiagramPanel();
|
|
|
|
return this;
|
};
|
|
//根据流量计算功率
|
this.calcPowerByFlow = function (flow, unit) {
|
if (flow == null || m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQP == null)
|
return null;
|
var flow_stdUnit = UnitHelper.ConvertQ_toM3H(unit, flow);
|
if (flow_stdUnit < 0.1)
|
return null;
|
//console.log("flow_stdUnit", flow_stdUnit, unit, flow)
|
var xPixel = getPixelValueQ(flow_stdUnit);
|
var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel);
|
if (power_pixel_pt != null) {
|
var power = getActualValueP(power_pixel_pt.Y);
|
// console.log("flow_power", flow_stdUnit, power.toFixed(2) )
|
return power.toFixed(2);
|
}
|
else {
|
return null;
|
}
|
};
|
//根据流量计算效率
|
this.calcEtaByFlow = function (flow, unit) {
|
if (flow == null || m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQE == null)
|
return null;
|
var flow_stdUnit = UnitHelper.ConvertQ_toM3H(unit, flow);
|
if (flow_stdUnit < 0.1)
|
return null;
|
//console.log("flow_stdUnit", flow_stdUnit, unit, flow)
|
var xPixel = getPixelValueQ(flow_stdUnit);
|
var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel);
|
if (power_pixel_pt != null) {
|
var power = getActualValueE(power_pixel_pt.Y);
|
//console.log("flow_power", power.toFixed(2) )
|
return power.toFixed(2);
|
}
|
else {
|
return null;
|
}
|
};
|
//设置水印图片路径
|
this.setWatermarkImageUrl = function(img_path){
|
|
};
|
//重绘图表大小
|
this.Resize = function (widht, height) {
|
if (widht && widht > 0)
|
m_chartSize.TotalWidth = widht;
|
if (height && height > 0)
|
m_chartSize.TotalHeight = height;
|
|
document.getElementById(m_divChartName).innerHTML = '';
|
|
//初始化面板
|
initialPanelSize();
|
|
|
drawDiagramPanel();
|
|
refreshDiagram();
|
};
|
};
|
|
export default MultiSpeedChartDiagram
|