import svgObject from "./svgOjbect";
|
import ConstParas from "@/utils/constParas.js";
|
import UnitHelper from "@/utils/unit.js";
|
import PointToleranceConfig from "./PointToleranceConfig.js";
|
import languageHelper from "@/utils/languageHelper.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_isDispCurveSpeed = true;
|
var m_isDispCurveHz = false;
|
var m_pumpInfo; //基本信息
|
var m_chartPointPara;
|
var m_chartObject;
|
var m_coordinatePara; //坐标
|
|
var m_maxSpeedCurve;
|
var m_simuSpeedCurves;
|
var onChangeSpeedListCb; //修改了列表通知外部
|
|
var m_spectrumShape = null; //型谱
|
|
var m_chartSetting; //设置
|
var m_displayStyle; //显示设置
|
var m_queryLinePixel = 0;
|
|
var m_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two;
|
//
|
var m_dispVerticalLine1 = false;//查询线 是否显示
|
var onChangeQueryDataCb = null;//查询外部回调
|
|
var m_isDispCurveQE = false; //是否显示效率
|
var m_isDispCurveNPSH = false; //是否显示效率
|
var m_isHaveNpsh = false; //是否显示汽蚀
|
var m_colorArray = [
|
"#6A5ACD",
|
"#7B68EE",
|
"#8470FF",
|
"#1E90FF",
|
"#00BFFF",
|
"#800080",
|
"#87CEFA",
|
"#f391a9",
|
"#8B4513",
|
"#ed1941",
|
"#f47a55",
|
"#224b8f",
|
"#2a5caa",
|
"#9b95c9",
|
"#f0dc70",
|
];
|
var m_curveMaxId = 1;
|
|
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.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.ColorGridLine = "#cccccc";
|
}
|
m_displayStyle.SpectrumColor = "LightSkyBlue";
|
};
|
|
//初始化显示设置
|
var initialDispStyle = function (displayStyle, chartSetting) {
|
if (displayStyle != null) {
|
m_displayStyle = displayStyle;
|
} else {
|
m_displayStyle = {};
|
m_displayStyle.IsMonoColor = false;
|
m_displayStyle.IsDispSpectrum = true; //默认显示型谱
|
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);
|
if (m_coordinatePara.DislocationNumUp > 0)
|
grid_num_up = grid_num_up + m_coordinatePara.DislocationNumUp;
|
else 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 = grid_num_p;
|
|
if (m_isDispCurveNPSH) {
|
grid_num_down =
|
Math.max(grid_num_NPSH, grid_num_p) +
|
m_coordinatePara.DislocationNumDown;
|
}
|
|
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;
|
}
|
};
|
//检查坐标范围是否超过曲线范围
|
var checkCoordinate = function () {
|
if (m_maxSpeedCurve == null || m_maxSpeedCurve.RealQH == null)
|
return false;
|
if (m_coordinatePara == null)
|
return false;
|
//检查最大值
|
var curve_max_q = m_maxSpeedCurve.RealQH[m_maxSpeedCurve.RealQH.length - 1].X;
|
var curve_max_h = m_maxSpeedCurve.RealQH[0].Y;
|
var curve_max_p = m_maxSpeedCurve.RealQP[m_maxSpeedCurve.RealQP.length - 1].Y;
|
var isNeedRefresh = false;
|
var dist_head = m_coordinatePara.SpaceH / 2;
|
var dist_pwer = m_coordinatePara.SpaceP / 5;
|
for (var i = 0; i < 10; i++) {
|
|
if (curve_max_h < m_coordinatePara.DispMaxH - m_coordinatePara.SpaceH - dist_head) {
|
m_coordinatePara.DispMaxH = m_coordinatePara.DispMaxH - m_coordinatePara.SpaceH;
|
m_coordinatePara.EndLineNoH = m_coordinatePara.EndLineNoH - 1;
|
isNeedRefresh = true;
|
|
continue;
|
}
|
|
break;
|
}
|
for (var i = 0; i < 5; i++) {
|
|
if (curve_max_p < m_coordinatePara.DispMaxP - m_coordinatePara.SpaceP - dist_pwer) {
|
m_coordinatePara.DispMaxP = m_coordinatePara.DispMaxP - m_coordinatePara.SpaceP;
|
m_coordinatePara.EndLineNoP = m_coordinatePara.EndLineNoP - 1;
|
isNeedRefresh = true;
|
|
continue;
|
}
|
|
break;
|
}
|
|
for (var i = 0; i < 5; i++) {
|
|
if (curve_max_q < m_coordinatePara.DispMaxQ - m_coordinatePara.SpaceQ * 2) {
|
m_coordinatePara.DispMaxQ = m_coordinatePara.DispMaxQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.GridNumberX = m_coordinatePara.GridNumberX - 1;
|
isNeedRefresh = true;
|
|
continue;
|
}
|
|
break;
|
}
|
|
if (m_simuSpeedCurves == null || m_simuSpeedCurves.length == 0)
|
return isNeedRefresh;
|
if (m_simuSpeedCurves[0].RealQH == null)
|
return isNeedRefresh;
|
|
//检查最小值
|
var curve_min_h = m_simuSpeedCurves[0].RealQH[m_simuSpeedCurves[0].RealQH.length - 1].Y;
|
var curve_min_p = m_simuSpeedCurves[0].RealQP[0].Y;
|
for (var i = 1; i < m_simuSpeedCurves.length; i++) {
|
var qh = m_simuSpeedCurves[i].RealQH;
|
var qp = m_simuSpeedCurves[i].RealQP;
|
curve_min_h = Math.min(curve_min_h, qh[qh.length - 1].Y);
|
curve_min_p = Math.min(curve_min_p, qp[0].Y);
|
}
|
if (curve_min_p < 0.1)
|
curve_min_p = 0;
|
|
|
|
|
//扬程
|
for (var i = 0; i < 30; i++) {
|
if (m_coordinatePara.DispMinH < 0) break;
|
if (curve_min_h > m_coordinatePara.DispMinH) break;
|
m_coordinatePara.StartLineNoH = m_coordinatePara.StartLineNoH - 1;
|
m_coordinatePara.DispMinH =
|
m_coordinatePara.DispMinH - m_coordinatePara.SpaceH;
|
isNeedRefresh = true;
|
}
|
|
if (
|
m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH > 12 ||
|
m_coordinatePara.StartLineNoH < 0
|
) {
|
var spaceh2 = m_coordinatePara.SpaceH * 2;
|
m_coordinatePara.StartLineNoH =
|
m_coordinatePara.EndLineNoH -
|
parseInt(
|
(m_coordinatePara.DispMaxH - m_coordinatePara.DispMinH) / spaceh2
|
) -
|
1;
|
m_coordinatePara.DispMinH =
|
m_coordinatePara.DispMaxH -
|
spaceh2 * (m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH);
|
|
m_coordinatePara.SpaceH = spaceh2;
|
isNeedRefresh = true;
|
if (
|
m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH > 10 ||
|
m_coordinatePara.StartLineNoH < 0
|
) {
|
var spaceh4 = m_coordinatePara.SpaceH * 2;
|
m_coordinatePara.StartLineNoH =
|
m_coordinatePara.EndLineNoH -
|
parseInt(
|
(m_coordinatePara.DispMaxH - m_coordinatePara.DispMinH) / spaceh4
|
) -
|
1;
|
m_coordinatePara.DispMinH =
|
m_coordinatePara.DispMaxH -
|
spaceh4 *
|
(m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH);
|
|
m_coordinatePara.SpaceH = spaceh4;
|
isNeedRefresh = true;
|
}
|
}
|
|
//扬程上部是否又多余空格
|
|
|
|
|
for (var i = 0; i < 30; i++) {
|
if (m_coordinatePara.DispMinP < 0) break;
|
if (curve_min_p > m_coordinatePara.DispMinP) break;
|
m_coordinatePara.StartLineNoP = m_coordinatePara.StartLineNoP - 1;
|
m_coordinatePara.DispMinP =
|
m_coordinatePara.DispMinP - m_coordinatePara.SpaceP;
|
m_coordinatePara.MinP = m_coordinatePara.DispMinP - m_coordinatePara.StartLineNoP * m_coordinatePara.SpaceP;
|
isNeedRefresh = true;
|
}
|
|
if (
|
m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP > 10 ||
|
m_coordinatePara.StartLineNoP < 0
|
) {
|
var spacep2 = m_coordinatePara.SpaceP * 2;
|
|
m_coordinatePara.StartLineNoP =
|
m_coordinatePara.EndLineNoP -
|
parseInt(
|
(m_coordinatePara.DispMaxP - m_coordinatePara.DispMinP) / spacep2
|
) -
|
1;
|
m_coordinatePara.DispMinP =
|
m_coordinatePara.DispMaxP -
|
spacep2 * (m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP);
|
|
m_coordinatePara.SpaceP = spacep2;
|
isNeedRefresh = true;
|
|
if (
|
m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP > 10 ||
|
m_coordinatePara.StartLineNoP < 0
|
) {
|
var spacep4 = m_coordinatePara.SpaceP * 4;
|
|
m_coordinatePara.StartLineNoP =
|
m_coordinatePara.EndLineNoP -
|
parseInt(
|
(m_coordinatePara.DispMaxP - m_coordinatePara.DispMinP) / spacep4
|
) -
|
1;
|
m_coordinatePara.DispMinP =
|
m_coordinatePara.DispMaxP -
|
spacep4 *
|
(m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP);
|
|
m_coordinatePara.SpaceP = spacep4;
|
}
|
m_coordinatePara.MinP = m_coordinatePara.DispMinP - m_coordinatePara.StartLineNoP * m_coordinatePara.SpaceP;
|
}
|
|
//
|
if (m_coordinatePara.DispMinQ > 0) {
|
var min_flow = 100000;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
var simu_curve = m_simuSpeedCurves[i];
|
if (simu_curve.RealQH == null) continue;
|
min_flow = Math.min(min_flow, simu_curve.RealQH[0].X);
|
}
|
|
if (min_flow < m_coordinatePara.DispMinQ) {
|
m_coordinatePara.DispMinQ =
|
m_coordinatePara.DispMinQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.GridNumberX++;
|
m_coordinatePara.MinQ = m_coordinatePara.MinQ - m_coordinatePara.SpaceQ;
|
if (min_flow < m_coordinatePara.DispMinQ) {
|
m_coordinatePara.DispMinQ =
|
m_coordinatePara.DispMinQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.MinQ =
|
m_coordinatePara.MinQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.GridNumberX++;
|
}
|
if (min_flow < m_coordinatePara.DispMinQ) {
|
m_coordinatePara.DispMinQ =
|
m_coordinatePara.DispMinQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.MinQ =
|
m_coordinatePara.MinQ - m_coordinatePara.SpaceQ;
|
m_coordinatePara.GridNumberX++;
|
}
|
|
isNeedRefresh = true;
|
}
|
}
|
|
// if (isNeedRefresh) {
|
// document.getElementById(m_divChartName).innerHTML = "";
|
|
// //初始化面板尺寸
|
// initialPanelSize();
|
|
// drawDiagramPanel();
|
|
// drawDiagramCurve();
|
// }
|
return isNeedRefresh;
|
};
|
//
|
var getSvgObjByName = function (objName) {
|
return m_svg.getPathByName(objName);
|
};
|
var removeElementById = function (id) {
|
var obj = document.getElementById(id);
|
if (obj != null) {
|
//console.log(id+ " is remove")
|
obj.remove();
|
}
|
};
|
var hideElementById = function (id) {
|
var obj = document.getElementById(id);
|
if (obj != null) {
|
//console.log(id+ " is remove")
|
obj.style.display = "none";
|
}
|
};
|
var showElementById = function (id) {
|
var obj = document.getElementById(id);
|
if (obj != null) {
|
obj.style.display = "";
|
}
|
};
|
//
|
var svgClick = function (e) { };
|
//
|
var svgMove = function (e) {
|
//alert("svgMove");
|
};
|
|
//翻译
|
var getTranslateString = function (cn) {
|
if (m_localizationType == 0) return cn;
|
return languageHelper.translateString(m_localizationType, 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.DispMinH +
|
(i - m_coordinatePara.StartLineNoH) * 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.DispMinH + i * 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);
|
//console.log(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 drawSpectrumShape = function () {
|
// console.log(m_spectrumShape);
|
if (m_spectrumShape == null) return;
|
removeElementById("SpectrumShape");
|
|
var pathValue = [];
|
|
var pixelPoints_Left = [];
|
var points_left = m_spectrumShape["LeftParabolaPoints"];
|
for (var v = 0; v < points_left.length; v++) {
|
var pt = points_left[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueH(pt.Y);
|
pixelPoints_Left.push({ X: x, Y: y });
|
}
|
var bezierCurve_points_Left = transBezierCurveModel(pixelPoints_Left);
|
for (var h = 0; h < bezierCurve_points_Left.length; h++) {
|
var b_pt = bezierCurve_points_Left[h];
|
if (h == 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
|
);
|
}
|
}
|
|
var pixelPoints_Top = [];
|
var points_top = m_spectrumShape["BasePoints"];
|
for (var v = 0; v < points_top.length; v++) {
|
var pt = points_top[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueH(pt.Y);
|
pixelPoints_Top.push({ X: x, Y: y });
|
}
|
var bezierCurve_points_top = transBezierCurveModel(pixelPoints_Top);
|
for (var h = 0; h < bezierCurve_points_top.length; h++) {
|
var b_pt = bezierCurve_points_top[h];
|
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
|
);
|
}
|
|
var pixelPoints_bottom = [];
|
var points_bottom = m_spectrumShape["SimularPoints"];
|
for (var v = 0; v < points_bottom.length; v++) {
|
var pt = points_bottom[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueH(pt.Y);
|
pixelPoints_bottom.push({ X: x, Y: y });
|
}
|
var bezierCurve_points_bottom = transBezierCurveModel(pixelPoints_bottom);
|
for (var h = 0; h < bezierCurve_points_bottom.length; h++) {
|
var b_pt = bezierCurve_points_bottom[h];
|
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
|
);
|
}
|
|
var pixelPoints_right = [];
|
var points_right = m_spectrumShape["RightParabolaPoints"];
|
for (var v = 0; v < points_right.length; v++) {
|
var pt = points_right[v];
|
var x = getPixelValueQ(pt.X);
|
var y = getPixelValueH(pt.Y);
|
pixelPoints_right.push({ X: x, Y: y });
|
}
|
var bezierCurve_points_right = transBezierCurveModel(pixelPoints_right);
|
for (var h = 0; h < bezierCurve_points_right.length; h++) {
|
var b_pt = bezierCurve_points_right[h];
|
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 (h == bezierCurve_points_right.length - 1) {
|
pathValue.push(" L ", b_pt.Point3.X, " ", b_pt.Point3.Y);
|
}
|
}
|
|
if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) {
|
return;
|
}
|
|
if (m_displayStyle.SpectrumColor == null)
|
m_displayStyle.SpectrumColor = "Aquamarine";
|
var style = {
|
"stroke-width": "1",
|
stroke: "none",
|
fill: m_displayStyle.SpectrumColor,
|
"stroke-opacity": "0.1",
|
"fill-opacity": "0.3",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": -1,
|
};
|
m_svg.createPath("SpectrumShape", pathValue.join(""), null, style);
|
};
|
|
//绘制曲线(流量扬程)
|
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;
|
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'
|
}
|
|
//绘制
|
m_svg.createPath(
|
curveElementName,
|
pathValue.join(""),
|
{
|
id: curveElementName,
|
},
|
style
|
);
|
//是否显示
|
if (isDisp != null && !isDisp) {
|
hideElementById(curveElementName);
|
}
|
|
//绘制定义点
|
/*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, curveInfo, point) {
|
if (!point) {
|
return;
|
}
|
|
var speed = Math.round(curveInfo.speed);
|
var hz = Math.round(curveInfo.hz, 1);
|
|
var xPixel = getPixelValueQ(point.X) + 12;
|
var yPixel = getPixelValueH(point.Y) + 8;
|
|
var textStyle = "font-size:12px;text-anchor:start;font-family:sans-serif;"; //fill-opacity:0.9 stroke-width:1px;
|
textStyle += " fill:" + curveInfo.color + ";";
|
|
if (curveInfo.type == 2) {
|
textStyle += "font-weight:bold;"; // 工作曲线 加粗
|
}
|
var text = "";
|
if (m_isDispCurveSpeed && m_isDispCurveHz) {
|
text = speed + " rpm" + "(" + hz + "HZ)";
|
} else if (m_isDispCurveSpeed && !m_isDispCurveHz) {
|
text = speed + " rpm";
|
} else if (!m_isDispCurveSpeed && m_isDispCurveHz) {
|
text = hz + " HZ";
|
} else {
|
return;
|
}
|
|
return m_svg.createText(
|
{
|
id: curveElementName,
|
opacity: 0.5,
|
y: yPixel,
|
x: xPixel,
|
},
|
textStyle,
|
text
|
);
|
};
|
var drawSpeedTextByQP = function (
|
curveElementName,
|
curveInfo,
|
point
|
) {
|
if (!point) {
|
return;
|
}
|
|
var xPixel = getPixelValueQ(point.X) + 11;
|
var yPixel = getPixelValueP(point.Y) + 4;
|
|
var textStyle = "font-size:12px;text-anchor:start;font-weight:bold;"; //加粗 stroke-width:1px; fill-opacity:0.9
|
textStyle += " fill:" + curveInfo.color + ";";
|
|
var speed = Math.round(curveInfo.speed);
|
var hz = Math.round(curveInfo.hz);
|
|
var text = "";
|
if (m_isDispCurveSpeed && m_isDispCurveHz) {
|
text = speed + " rpm" + "(" + hz + "HZ)";
|
} else if (m_isDispCurveSpeed && !m_isDispCurveHz) {
|
text = speed + " rpm";
|
} else if (!m_isDispCurveSpeed && m_isDispCurveHz) {
|
text = hz + " HZ";
|
} else {
|
return;
|
}
|
|
return m_svg.createText(
|
{
|
id: curveElementName,
|
opacity: 0.5,
|
y: yPixel,
|
x: xPixel,
|
},
|
textStyle,
|
text
|
);
|
};
|
//绘制设计点
|
var drawDesignPoint = function (dp_name, dp_color, dp_x, dp_y) {
|
if (dp_x == null || dp_y == null)
|
return;
|
|
var attr_pt = {
|
"cx": getPixelValueQ(dp_x),
|
"cy": getPixelValueH(dp_y),
|
"r": 5
|
}
|
var style_pt = {
|
"stroke-width": "2px",
|
"stroke": dp_color,
|
"fill": dp_color,
|
"fill-opacity": "0.5",
|
"shape-rendering": "geometricPrecision",
|
"zIndex:": 7
|
};
|
|
m_svg.createCircle(dp_name, attr_pt, style_pt);
|
|
|
};
|
|
//绘制曲线(流量效率)
|
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) {
|
hideElementById(curveElementName);
|
}
|
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) {
|
hideElementById(curveElementName);
|
}
|
|
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) {
|
hideElementById(curveElementName);
|
}
|
};
|
//清理
|
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.png";
|
|
removeElementById("mscWaterMarkImage1");
|
removeElementById("mscWaterMarkImage2");
|
removeElementById("mscWaterMarkImage3");
|
removeElementById("mscWaterMarkImage4");
|
|
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;
|
|
//console.log('m_chartSize',m_chartSize)//TotalHeight TotalWidth
|
var ratio_byHeight =
|
(m_chartSize.TotalHeight * 0.2) / watermark_image_height_real;
|
var ratio_byWidth =
|
(m_chartSize.TotalWidth * 0.2) / watermark_image_width_real;
|
//console.log('m_chartSize',ratio_byHeight,ratio_byWidth)//TotalHeight TotalWidth
|
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.9,
|
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,
|
"mscWaterMarkImage1",
|
watermark_img_url
|
);
|
|
var logoPosi2 = {
|
opacity: 0.9,
|
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,
|
"mscWaterMarkImage2",
|
watermark_img_url
|
);
|
|
var logoPosi3 = {
|
opacity: 0.9,
|
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,
|
"mscWaterMarkImage3",
|
watermark_img_url
|
);
|
|
var logoPosi4 = {
|
opacity: 0.9,
|
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,
|
"mscWaterMarkImage4",
|
watermark_img_url
|
);
|
};
|
};
|
|
//获取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 drawQueryIndicatVertLine = function (xStartValuePixel, index) {
|
|
var obj_divChart = document.getElementById(m_divChartName);
|
|
var attr4verticalLine1 = {
|
"stroke": "rgb(136 136 221)",
|
"stroke-width": "3",
|
"fill": "none",
|
"zIndex": 100,
|
"stroke-dasharray": "18 3",
|
"cursor": 'pointer',
|
"stroke-opacity": '1',
|
"shape-rendering": "geometricPrecision",
|
};
|
|
// 位置
|
if (xStartValuePixel == null || xStartValuePixel < 1)
|
xStartValuePixel = (m_chartSize.DiagramLeft + m_chartSize.DiagramRight) / 2;
|
|
var vertialLinePathName1 = "verticalLine1multispeed";
|
removeElementById(vertialLinePathName1);
|
|
//创建竖直线
|
var pathValue1 = [];
|
pathValue1.push("M ", xStartValuePixel, " ", m_chartSize.UpDiagram.Up, " L ", xStartValuePixel, " ", m_chartSize.DownDiagram.Bottom);
|
m_svg.createPath(vertialLinePathName1, pathValue1.join(''), {
|
id: vertialLinePathName1
|
}, attr4verticalLine1, null);
|
|
|
drawQueryDataInfoByPixel(xStartValuePixel, 1);
|
//drawQueryDataInfoByPixel(xStartValuePixel, 2);
|
|
var isMoveVerticalLine1 = false;
|
|
//
|
var objIndicatorLine1 = document.getElementById(vertialLinePathName1);
|
objIndicatorLine1.onmousedown = function (e) {
|
isMoveVerticalLine1 = true;
|
e.preventDefault();
|
}
|
|
obj_divChart.onmousemove = function (e) {
|
if (isMoveVerticalLine1 == true) {
|
e.preventDefault();
|
if (objIndicatorLine1 == null)
|
return;
|
var svg_root = m_svg.getRootNode();
|
const box = svg_root.getBoundingClientRect();
|
var top = box.top + window.scrollY - document.documentElement.clientTop;
|
var left = box.left + window.scrollX - document.documentElement.clientLeft
|
var e = window.event || e;
|
if (e.clientX - left > m_chartSize.DiagramLeft &&
|
m_chartSize.DiagramRight + left - e.clientX > 0 &&
|
e.clientY - top > m_chartSize.DiagramTop &&
|
m_chartSize.DiagramBottom + top - e.clientY > 0) {
|
//当前鼠标位置 x的像素
|
var xPixel = parseFloat(e.clientX - left);
|
//
|
drawQueryDataInfoByPixel(xPixel, 1);
|
//修改位置
|
var pathValue1 = [];
|
pathValue1.push("M ", xPixel, " ", m_chartSize.UpDiagram.Up, " L ", xPixel, " ", m_chartSize.DownDiagram.Bottom);
|
objIndicatorLine1.setAttribute('d', pathValue1.join(''));
|
}
|
}
|
|
// if (isMoveVerticalLine2 == true) {
|
// if (objIndicatorLine2 == null)
|
// return;
|
// var svg_root = m_svg.getRootNode();
|
// const box = svg_root.getBoundingClientRect();
|
// var top = box.top + window.scrollY - document.documentElement.clientTop;
|
// var left = box.left + window.scrollX - document.documentElement.clientLeft
|
// var e = window.event || e;
|
// if (e.clientX - left > m_chartSize.DiagramLeft &&
|
// m_chartSize.DiagramRight + left - e.clientX > 0 &&
|
// e.clientY - top > m_chartSize.DiagramTop &&
|
// m_chartSize.DiagramBottom + top - e.clientY > 0) {
|
// //当前鼠标位置 x的像素
|
// var xPixel = parseFloat(e.clientX - left);
|
// //
|
// // drawQueryDataInfoByPixel(xPixel, 2);
|
// // //修改位置
|
// // var pathValue1 = new Array();
|
// // pathValue1.push("M ", xPixel, " ", m_chartSize.UpDiagram.Up, " L ", xPixel, " ", m_chartSize.DownDiagram.Bottom);
|
// // objIndicatorLine2.setAttribute('d', pathValue1.join(''));
|
// }
|
// }
|
};
|
|
obj_divChart.onmouseup = function (e) {
|
if (isMoveVerticalLine1) {
|
isMoveVerticalLine1 = false;
|
e.preventDefault();
|
}
|
// if (isMoveVerticalLine2) {
|
// isMoveVerticalLine2 = false;
|
// }
|
};
|
|
|
//设置显示
|
setQueryIndicatVertLineVisible(m_dispVerticalLine1, 1);
|
};
|
//绘制/显示 参数查询信息
|
var drawQueryDataInfoByPixel = function (xPixel, index) {//x的像素
|
if (xPixel == null)
|
return;
|
if (m_maxSpeedCurve == null)
|
return;
|
if (m_maxSpeedCurve.PixelQH == null)
|
return;
|
m_queryLinePixel = xPixel;
|
//流量
|
let flow_m3h = getActualValueQ(xPixel);
|
if (flow_m3h == null)
|
return;
|
if (flow_m3h > m_maxSpeedCurve.RealQH[m_maxSpeedCurve.RealQH.length - 1].X)
|
return;
|
|
var query_pt_list = [];
|
|
var query_pt = calcQueryPtInfoByPixel(m_maxSpeedCurve, xPixel);
|
query_pt.Q = UnitHelper.getDispValueH(flow_m3h);
|
if (query_pt.H)
|
query_pt.H = UnitHelper.getDispValueH(query_pt.H);
|
if (query_pt.P)
|
query_pt.P = UnitHelper.getDispValueP(query_pt.P);
|
query_pt.speed = m_maxSpeedCurve.speed;
|
query_pt.hz = m_maxSpeedCurve.hz;
|
query_pt_list.push(query_pt);
|
|
if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) {
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
//console.log(m_simuSpeedCurves[i],xPixel)
|
var simu_curve = m_simuSpeedCurves[i];
|
if (flow_m3h > simu_curve.RealQH[simu_curve.RealQH.length - 1].X)
|
continue;
|
|
var query_pt2 = calcQueryPtInfoByPixel(simu_curve, xPixel);
|
query_pt2.Q = UnitHelper.getDispValueH(flow_m3h);
|
if (query_pt2.H)
|
query_pt2.H = UnitHelper.getDispValueH(query_pt2.H);
|
if (query_pt2.P)
|
query_pt2.P = UnitHelper.getDispValueP(query_pt2.P);
|
|
query_pt2.speed = simu_curve.speed;
|
query_pt2.hz = simu_curve.hz;
|
query_pt_list.push(query_pt2);
|
|
}
|
}
|
|
//获取查询曲线查询得到的数据 给参数查询使用
|
if (onChangeQueryDataCb != null) {
|
onChangeQueryDataCb(query_pt_list)
|
}
|
};
|
//计算 参数查询信息 ( flow_m3h 实际值 )
|
var calcQueryPtInfoByPixel = function (curve, xPixel) {
|
if (xPixel < 0.1)
|
return null;
|
|
var query_pt = {};
|
|
//扬程
|
var head_pixel_pt = getBezierPointY(curve.PixelQH, xPixel);
|
if (head_pixel_pt == null)
|
return;
|
var head_m = getActualValueH(head_pixel_pt.Y);
|
query_pt.H = head_m;
|
|
//效率
|
// var eff_info = {};
|
// eff_info.value = "";
|
// if (m_isDispCurveQE) {
|
// var eta_pixel_pt = getBezierPointY(m_wrkCurveGrp.PixelQE, xPixel);
|
// if (eta_pixel_pt != null) {
|
// var eta_std = getActualValueE(eta_pixel_pt.Y);
|
// query_pt.E = eta_std.toFixed(1);
|
// }
|
// }
|
|
//功率
|
var power_pixel_pt = getBezierPointY(curve.PixelQP, xPixel);
|
if (power_pixel_pt != null) {
|
var power_kw = getActualValueP(power_pixel_pt.Y);
|
query_pt.P = power_kw;
|
}
|
|
return query_pt;
|
};
|
//设置查询线 是否显示
|
var setQueryIndicatVertLineVisible = function (disp, index) {
|
m_dispVerticalLine1 = disp;
|
|
var objLine = document.getElementById("verticalLine1multispeed");
|
if (objLine != null) {
|
if (disp) {
|
objLine.style.display = '';
|
}
|
else {
|
objLine.style.display = 'none';
|
}
|
}
|
};
|
//设置查询线 的值
|
var setQueryIndicatValue = function (flow_m3h, index) {
|
m_dispVerticalLine1 = true;
|
setQueryIndicatVertLineVisible(m_dispVerticalLine1, 1);
|
var xStartValuePixel = getPixelValueQ(flow_m3h);
|
drawQueryIndicatVertLine(xStartValuePixel, 1);
|
};
|
//绘制图表(所有曲线)
|
var drawDiagramCurve = function () {
|
if (m_maxSpeedCurve == null) return;
|
|
|
removeElementById("MaxSpeedCurveQH");
|
removeElementById("MaxSpeedCurveQE");
|
removeElementById("MaxSpeedCurveQP");
|
|
removeElementById("MaxSpeedCurveQHText");
|
removeElementById("MaxSpeedCurveQPText");
|
|
if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) {
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
var id = m_simuSpeedCurves[i].id;
|
removeElementById("SpeedSimuCurveQH" + id);
|
removeElementById("SpeedSimuCurveQE" + id);
|
removeElementById("SpeedSimuCurveQP" + id);
|
|
removeElementById("SpeedSimuCurveQHText" + id);
|
removeElementById("SpeedSimuCurveQPText" + id);
|
}
|
}
|
|
//
|
m_maxSpeedCurve.type = 1; //0 一般 1 最大曲线 2工作曲线(变频)
|
m_maxSpeedCurve.color = "black";
|
var maxSpeed_curveWidth = 3;
|
var pixelPointsQH = createCurveQH(
|
"MaxSpeedCurveQH",
|
m_maxSpeedCurve.RealQH,
|
maxSpeed_curveWidth,
|
m_maxSpeedCurve.color
|
);
|
var pointsRealQH = m_maxSpeedCurve.RealQH;
|
if (pointsRealQH == null)
|
return;
|
drawSpeedTextByQH(
|
"MaxSpeedCurveQHText",
|
m_maxSpeedCurve,
|
pointsRealQH[pointsRealQH.length - 1]
|
);
|
m_maxSpeedCurve.PixelQH = transBezierCurveModel(pixelPointsQH);
|
|
|
var pixelPointsQP = createCurveQP(
|
"MaxSpeedCurveQP",
|
m_maxSpeedCurve.RealQP,
|
maxSpeed_curveWidth,
|
m_maxSpeedCurve.color
|
);
|
var pointsRealQP = m_maxSpeedCurve.RealQP;
|
drawSpeedTextByQP(
|
"MaxSpeedCurveQPText",
|
m_maxSpeedCurve,
|
pointsRealQP[pointsRealQP.length - 1]
|
);
|
m_maxSpeedCurve.PixelQP = transBezierCurveModel(pixelPointsQP);
|
|
|
|
if (m_isDispCurveQE) {
|
var pixelPointsQE = createCurveQE(
|
"MaxSpeedCurveQE",
|
m_maxSpeedCurve.RealQE,
|
maxSpeed_curveWidth,
|
m_maxSpeedCurve.color
|
);
|
//var pointsRealQE = m_maxSpeedCurve.RealQE;
|
// drawSpeedTextByQE(
|
// "MaxSpeedCurveQEText",
|
// m_maxSpeedCurve,
|
// pointsRealQP[pointsRealQP.length - 1]
|
// );
|
m_maxSpeedCurve.PixelQE = transBezierCurveModel(pixelPointsQE);
|
}
|
|
|
|
//
|
if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) {
|
m_simuSpeedCurves.forEach((element) => {
|
element.hz = Math.round(
|
(m_maxSpeedCurve.hz * element.speed) / m_maxSpeedCurve.speed,
|
1
|
);
|
drawSimuSpeedCurve(element);
|
});
|
}
|
|
|
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
|
|
|
//型谱
|
drawSpectrumShape();
|
|
|
|
|
//装置曲线
|
//drawEquipmentCurve();
|
|
//查询指示线
|
drawQueryIndicatVertLine();
|
|
};
|
//通知外部
|
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,
|
type: element.type,
|
});
|
});
|
onChangeSpeedListCb(list_speed_color);
|
}
|
};
|
|
//计算所有变频曲线
|
var calcAllSimuSpeedCurve = function () {
|
if (m_maxSpeedCurve == null || m_maxSpeedCurve.RealQH == null)
|
return;
|
if (m_simuSpeedCurves == null || m_simuSpeedCurves.length == 0)
|
return;
|
for (var i = 0; i < m_simuSpeedCurves.length; i++) {
|
var simuCurve = m_simuSpeedCurves[i];
|
|
var speed = simuCurve.speed;
|
if (speed < 10) continue;
|
|
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 simuCurveQE = [];
|
m_maxSpeedCurve.RealQE.forEach((pt) => {
|
var simu_pt = {};
|
simu_pt.X = (pt.X * speed) / rated_speed;
|
simu_pt.Y = pt.Y;
|
simuCurveQE.push(simu_pt);
|
});
|
simuCurve.RealQE = simuCurveQE;
|
|
|
|
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 sortSimuSpeedCurves = function () {
|
if (m_simuSpeedCurves == null || m_simuSpeedCurves.length == 0)
|
return null;
|
|
return m_simuSpeedCurves.sort((a, b) => {
|
if (a.speed < b.speed) {
|
return 1;
|
}
|
if (a.speed > b.speed) {
|
return -1;
|
}
|
return 0;
|
});
|
};
|
var newCurveColor = function (){
|
if (m_simuSpeedCurves == null || m_simuSpeedCurves.length == 0)
|
return m_colorArray[0];
|
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) {
|
return m_colorArray[c];
|
}
|
}
|
|
return "#800080";
|
};
|
//绘制曲线
|
var drawSimuSpeedCurve = function (simuCurve) {
|
if (m_maxSpeedCurve.RealQH == null)
|
return;
|
|
var speed = simuCurve.speed;
|
if (speed < 10) return;
|
|
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 simuCurveQE = [];
|
m_maxSpeedCurve.RealQE.forEach((pt) => {
|
var simu_pt = {};
|
simu_pt.X = (pt.X * speed) / rated_speed;
|
simu_pt.Y = pt.Y;
|
simuCurveQE.push(simu_pt);
|
});
|
simuCurve.RealQE = simuCurveQE;
|
|
|
|
|
|
|
|
|
var curveWidth = 2;
|
if (simuCurve.curveWidth) curveWidth = simuCurve.curveWidth;
|
|
var curveColor = simuCurve.color;
|
var curve_id = simuCurve.id;
|
|
removeElementById("SpeedSimuCurveQH" + curve_id);
|
removeElementById("SpeedSimuCurveQE" + curve_id);
|
removeElementById("SpeedSimuCurveQP" + curve_id);
|
|
removeElementById("SpeedSimuCurveQHText" + curve_id);
|
removeElementById("SpeedSimuCurveQEText" + curve_id);
|
removeElementById("SpeedSimuCurveQPText" + curve_id);
|
|
removeElementById("SpeedSimuDpQH" + curve_id);
|
|
|
var pixelPointsQH = createCurveQH(
|
"SpeedSimuCurveQH" + curve_id,
|
simuCurveQH,
|
curveWidth,
|
curveColor
|
);
|
drawSpeedTextByQH(
|
"SpeedSimuCurveQHText" + curve_id,
|
simuCurve,
|
simuCurveQH[simuCurveQH.length - 1]
|
);
|
simuCurve.PixelQH = transBezierCurveModel(pixelPointsQH);
|
|
|
|
|
var pixelPointsQP = createCurveQP(
|
"SpeedSimuCurveQP" + curve_id,
|
simuCurveQP,
|
curveWidth,
|
curveColor);
|
drawSpeedTextByQP(
|
"SpeedSimuCurveQPText" + curve_id,
|
simuCurve,
|
simuCurveQP[simuCurveQP.length - 1]
|
);
|
simuCurve.PixelQP = transBezierCurveModel(pixelPointsQP);
|
|
|
|
|
|
if (m_isDispCurveQE) {
|
var pixelPointsQE = createCurveQE(
|
"SpeedSimuCurveQE" + curve_id,
|
simuCurveQE,
|
curveWidth,
|
curveColor);
|
// drawSpeedTextByQE(
|
// "SpeedSimuCurveQEText" + curve_id,
|
// simuCurve,
|
// simuCurveQP[simuCurveQE.length - 1]
|
// );
|
simuCurve.PixelQE = transBezierCurveModel(pixelPointsQE);
|
}
|
|
|
//设计点
|
if (simuCurve.designPoint != null)
|
drawDesignPoint("SpeedSimuDpQH" + curve_id, curveColor, simuCurve.designPoint.Q, simuCurve.designPoint.H);
|
|
|
};
|
|
//
|
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;
|
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;
|
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();
|
|
drawDiagramCurve();
|
};
|
//设置工作曲线
|
this.setWrkCurveInfo = function (curve) {
|
if (curve == null) return;
|
|
if (m_maxSpeedCurve == null || curve.RealQH == 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;
|
}
|
|
//计算所有变频曲线
|
calcAllSimuSpeedCurve();
|
|
//
|
var isNeedRefresh = checkCoordinate();
|
if (isNeedRefresh) {
|
document.getElementById(m_divChartName).innerHTML = "";
|
//初始化面板尺寸
|
initialPanelSize();
|
|
//绘制水印
|
drawLogoWaterMark();
|
|
drawDiagramPanel();
|
}
|
|
//
|
drawDiagramCurve();
|
};
|
//获取列表
|
this.getSpeedCurveList = function () {
|
return m_simuSpeedCurves;
|
};
|
//添加转速
|
this.AddSpeedCurve = function (r_speed, dp) {
|
if (r_speed < 10) return null;
|
|
var i_speed = parseInt(r_speed);
|
|
if (m_simuSpeedCurves == null) m_simuSpeedCurves = [];
|
var isFind = false;
|
m_simuSpeedCurves.forEach((element) => {
|
if (i_speed == element.speed) isFind = true;
|
});
|
if (isFind) return null;
|
|
//获取没有用过的颜色
|
var curveColor = newCurveColor();
|
m_curveMaxId++;
|
var speedItem = {
|
id: m_curveMaxId,
|
speed: i_speed,
|
hz: Math.round((m_maxSpeedCurve.hz * r_speed) / m_maxSpeedCurve.speed, 1),
|
color: curveColor,
|
curveWidth: 2,
|
designPoint: dp
|
};
|
m_simuSpeedCurves.push(speedItem);
|
|
sortSimuSpeedCurves();
|
|
drawSimuSpeedCurve(speedItem);
|
|
//通知外部 曲线修改了
|
noticeCurveChanged();
|
|
if (m_dispVerticalLine1 && m_queryLinePixel > 0) {
|
drawQueryDataInfoByPixel(m_queryLinePixel);
|
}
|
return speedItem;
|
};
|
//添加转速(通过设计点)
|
this.AddSpeedCurveDp = function (r_q, r_h) {
|
if (r_q < 0.1) return null;
|
if (r_h < 0.1) return null;
|
|
var flow_stdUnit = r_q;//UnitHelper.ConvertQ_toM3H(unit, flow);
|
if (flow_stdUnit < 0.1) return null;
|
|
var xPixel = getPixelValueQ(flow_stdUnit);
|
var yPixel = getPixelValueH(r_h);
|
|
//var pathValue = transBezierCurveModel(m_maxSpeedCurve.PixelQP);
|
|
var fit_pixel_pt_max_speed = getBezierPointY(m_maxSpeedCurve.PixelQH, xPixel);
|
if (fit_pixel_pt_max_speed == null)
|
return null;
|
if (fit_pixel_pt_max_speed.Y > yPixel)
|
return null;
|
|
var rated_speed = m_maxSpeedCurve.speed;
|
|
for (var speed = m_maxSpeedCurve.speed - 1; speed >= m_maxSpeedCurve.speed * 0.6; speed = speed - 1) {
|
|
var pixelPoints = [];
|
m_maxSpeedCurve.RealQH.forEach((pt) => {
|
var simu_pt_X = (pt.X * speed) / rated_speed;
|
var simu_pt_Y = (pt.Y * speed * speed) / (rated_speed * rated_speed);
|
|
var simu_pt_Pixelx = getPixelValueQ(simu_pt_X);
|
var simu_pt_Pixely = getPixelValueH(simu_pt_Y);
|
pixelPoints.push({ X: simu_pt_Pixelx, Y: simu_pt_Pixely });
|
});
|
|
var pathValue = transBezierCurveModel(pixelPoints);
|
var sect_pixel_pt = getBezierPointY(pathValue, xPixel);
|
|
if (sect_pixel_pt != null && sect_pixel_pt.Y > yPixel) {//上面的Pixel Y 越小 , 下面的 Pixel 小
|
return this.AddSpeedCurve(speed + 1, { Q: flow_stdUnit, H: r_h });
|
}
|
}
|
|
|
return null;
|
};
|
//添加Hz
|
this.AddHzCurve = function (hz) {
|
hz = parseFloat(hz);
|
if (hz < 10) return null;
|
var r_speed = (hz * m_maxSpeedCurve.speed) / m_maxSpeedCurve.hz;
|
return this.AddSpeedCurve(r_speed, null);
|
};
|
|
//修改转速
|
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.hz = Math.round(
|
(m_maxSpeedCurve.hz * speed) / m_maxSpeedCurve.speed,
|
1
|
);
|
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;
|
|
var objCurveQH = document.getElementById("SpeedSimuCurveQH" + speedItem.id);
|
if (objCurveQH) objCurveQH.style.stroke = color;
|
|
var objCurveQP = document.getElementById("SpeedSimuCurveQP" + speedItem.id);
|
if (objCurveQP) objCurveQP.style.stroke = color;
|
|
var objTextQH = document.getElementById("SpeedSimuCurveQHText" + speedItem.id);
|
if (objTextQH) objTextQH.style.fill = color;
|
|
var objTextQP = document.getElementById("SpeedSimuCurveQPText" + speedItem.id);
|
if (objTextQP) objTextQP.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);
|
|
removeElementById("SpeedSimuCurveQH" + id);
|
removeElementById("SpeedSimuCurveQE" + id);
|
removeElementById("SpeedSimuCurveQP" + id);
|
|
removeElementById("SpeedSimuDpQH" + id);
|
|
removeElementById("SpeedSimuCurveQHText" + id);
|
//removeElementById("SpeedSimuCurveQEText"+id);
|
removeElementById("SpeedSimuCurveQPText" + id);
|
};
|
//设置容器
|
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;
|
};
|
this.setCurveLabelDispSpeed = function (isDisp) {
|
m_isDispCurveSpeed = isDisp;
|
drawDiagramCurve();
|
};
|
this.setCurveLabelDispHz = function (isDisp) {
|
m_isDispCurveHz = isDisp;
|
drawDiagramCurve();
|
};
|
this.setAxisDispEta = function (isDisp) {
|
m_isDispCurveQE = isDisp;
|
document.getElementById(m_divChartName).innerHTML = "";
|
//初始化面板
|
initialPanelSize();
|
|
//绘制水印
|
drawLogoWaterMark();
|
|
drawDiagramPanel();
|
drawDiagramCurve();
|
};
|
|
//设置工具提示栏
|
this.setToolTipName = function (toolTipName) { };
|
//获取查询曲线查询得到的数据 给参数查询使用
|
this.setChangeQueryDataCb = function (cb) {
|
onChangeQueryDataCb = cb;
|
};
|
//设置修改了列表,通知外部的回调
|
this.setChangeSpeedListCb = function (cb) {
|
onChangeSpeedListCb = cb;
|
};
|
//
|
this.setQueryIndicatVertLineVisible = function (isVisible, index) {
|
setQueryIndicatVertLineVisible(isVisible, index);
|
};
|
this.getQueryIndicatVertLineVisible = function () {
|
return m_dispVerticalLine;
|
};
|
|
//初始化图表(入口)
|
this.initialChart = function (ChartFullInfo, displayStyle) {
|
if (!m_divChartName) return;
|
//清空
|
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;
|
m_maxSpeedCurve.hz = m_pumpInfo.MotorFrequece;
|
if (m_maxSpeedCurve.hz == null || m_maxSpeedCurve.hz < 10)
|
m_maxSpeedCurve.hz = 50;
|
|
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.SeriesUnitQ,
|
m_chartSetting.SeriesUnitH,
|
m_chartSetting.SeriesUnitP,
|
m_chartSetting.SeriesUnitNPSH
|
);
|
|
//初始化速度列表
|
var speedList = [];
|
if (
|
ChartFullInfo.MultiSpeedInfo != null &&
|
ChartFullInfo.MultiSpeedInfo.SpeedItems != null
|
) {
|
speedList = ChartFullInfo.MultiSpeedInfo.SpeedItems;
|
|
//型谱
|
if (ChartFullInfo.MultiSpeedInfo.SpectrumShape != null) {
|
m_spectrumShape = ChartFullInfo.MultiSpeedInfo.SpectrumShape;
|
}
|
} else {
|
speedList.push({ Value: m_maxSpeedCurve.speed * 0.9, Type: 0 });
|
speedList.push({ Value: m_maxSpeedCurve.speed * 0.8, Type: 0 });
|
speedList.push({ Value: m_maxSpeedCurve.speed * 0.7, Type: 0 });
|
speedList.push({ Value: m_maxSpeedCurve.speed * 0.6, Type: 0 });
|
}
|
|
m_simuSpeedCurves = [];
|
|
speedList.forEach((speedItem, indx) => {
|
m_curveMaxId++;
|
m_simuSpeedCurves.push({
|
speed: speedItem.Value,
|
id: m_curveMaxId,
|
color: speedItem.Type == 2 ? "black" : newCurveColor(),
|
type: speedItem.Type,
|
curveWidth: speedItem.Type == 2 ? 3 : 1,//0 一般 1 最大曲线 2工作曲线(变频)
|
});
|
});
|
|
sortSimuSpeedCurves();
|
|
//初始化显示设置
|
initialDispStyle(displayStyle, m_chartSetting);
|
|
m_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two;
|
|
|
//初始化面板尺寸
|
initialPanelSize();
|
|
//绘制水印
|
drawLogoWaterMark();
|
|
//
|
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;
|
|
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;
|
|
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);
|
|
return power.toFixed(2);
|
} else {
|
return null;
|
}
|
};
|
//转化成m3h流量
|
this.transFlowToM3H = function (flow) {
|
return UnitHelper.ConvertQ_fromM3H(m_unit.Q, flow);
|
};
|
//设置查询值
|
this.setQueryIndicatValue = function (value, index) {
|
setQueryIndicatValue(value, index);
|
};
|
//重绘图表大小
|
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();
|
|
//绘制水印
|
drawLogoWaterMark();
|
|
drawDiagramPanel();
|
|
drawDiagramCurve();
|
};
|
};
|
|
export default MultiSpeedChartDiagram;
|