From 535b58e4c95067474181f69f6bbb82ca8469b55e Mon Sep 17 00:00:00 2001 From: tanghaolin <1723298894@qq.com> Date: 星期五, 07 三月 2025 12:09:47 +0800 Subject: [PATCH] 修改泵详细界面 --- src/components/Chart/js/MultiSpeedChartDiagram.js | 7114 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 4,210 insertions(+), 2,904 deletions(-) diff --git a/src/components/Chart/js/MultiSpeedChartDiagram.js b/src/components/Chart/js/MultiSpeedChartDiagram.js index 296b698..3f10059 100644 --- a/src/components/Chart/js/MultiSpeedChartDiagram.js +++ b/src/components/Chart/js/MultiSpeedChartDiagram.js @@ -1,1218 +1,2112 @@ -锘縤mport svgObject from "./svgOjbect" -import ConstParas from "@/utils/constParas.js" -import UnitHelper from "@/utils/unit.js" -import PointToleranceConfig from "./PointToleranceConfig.js" +锘縤mport 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_svg; - var m_unit = { Q: 1, H: 0, P: 1,NPSH:0 };//鍔熺巼銆佹祦閲忋�佹壃绋嬪崟浣嶉泦鍚� - var m_divChartName;//瀹瑰櫒DIV鍚嶇О - var m_chartSize;//鍥捐〃灏哄 - var m_localizationType;//璇█绫诲瀷 - var m_toolTipContent;//鍐呭鎻愮ずDIV瀹瑰櫒 - var m_equipZeroH = 0; + var m_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_pumpInfo;//鍩烘湰淇℃伅 - var m_chartPointPara; - var m_chartObject; - var m_coordinatePara;//鍧愭爣 + var m_maxSpeedCurve; + var m_simuSpeedCurves; + var onChangeSpeedListCb; //淇敼浜嗗垪琛ㄩ�氱煡澶栭儴 - var m_maxSpeedCurve; - var m_simuSpeedCurves; - var onChangeSpeedListCb;//淇敼浜嗗垪琛ㄩ�氱煡澶栭儴 + var m_spectrumShape = null; //鍨嬭氨 - var m_chartSetting;//璁剧疆 - var m_displayStyle;//鏄剧ず璁剧疆 + 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_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two; + var m_designPointTolerance = [0.91, 1.09, 0.95, 1.05]; //璁捐鐐瑰叕宸� - var m_isDispCurveQE = false;//鏄惁鏄剧ず鏁堢巼 - var m_isDispCurveNPSH = false;//鏄惁鏄剧ず鏁堢巼 - var m_isHaveNpsh = false;//鏄惁鏄剧ず姹借殌 - var m_colorArray = ["#426ab3", "#b2d235", "#840228", "#33a3dc", "#cd9a5b", "#96582a", "#f58220", "#f47920", "#f391a9", "#ed1941", "#f47a55", "#224b8f", "#2a5caa", "#9b95c9", "#f0dc70"]; - - - var m_designPointTolerance = [0.91, 1.09, 0.95, 1.05];//璁捐鐐瑰叕宸� - - //璁剧疆棰滆壊 - var setObjectColor = function (isMonorColor) { - m_displayStyle.IsMonoColor = isMonorColor; - if (m_displayStyle.IsMonoColor) { - m_displayStyle.ColorH = "#000000"; - m_displayStyle.ColorE = "#000000"; - m_displayStyle.ColorP = "#000000"; - m_displayStyle.ColorNPSH = "#000000"; - m_displayStyle.ColorEquipment = "#000000"; - m_displayStyle.ColorEqualParaCurvesE = "#000000"; - m_displayStyle.ColorSpectrumFill = "#f2eada"; - m_displayStyle.ColorGridLine = "#cccccc" - } - else { - m_displayStyle.ColorH = "#000000"; - m_displayStyle.ColorE = "#000000"; - m_displayStyle.ColorP = "#000000"; - m_displayStyle.ColorNPSH = "#000000"; - m_displayStyle.ColorEquipment = "#013317"; - m_displayStyle.ColorEqualParaCurvesE = "#402db7"; - m_displayStyle.ColorSpectrumFill = "Aquamarine"; - m_displayStyle.ColorGridLine = "#cccccc"; - } - }; - - var m_curveMaxId = 1; - - //鍒濆鍖栨樉绀鸿缃� - var initialDispStyle = function (displayStyle, chartSetting) { - if (displayStyle != null) { - m_displayStyle = displayStyle; - } - else { - m_displayStyle = {}; - m_displayStyle.IsMonoColor = false; - m_displayStyle.IsDispSpectrum = false;//榛樿涓嶆樉绀哄瀷璋� - m_displayStyle.DesignPointDispType = 0;//璁捐鐐规樉绀烘柟寮�(eDesignPointDispType) Cross 0 LeftDownTriangle 2 - } - - - //console.log(m_displayStyle) - - m_isHaveNpsh = true; - if (m_chartObject != null && m_chartObject.MaxWaterCurveNPSH == null) - m_isHaveNpsh = false; - - m_displayStyle.FeatCurveSize = 10; - m_displayStyle.EqualCurveSize = 9; - if (m_displayStyle.IsDispCurveLabel == null) - m_displayStyle.IsDispCurveLabel = true; - - m_displayStyle.isDrawWaterMark = true; - m_displayStyle.isDispEquipmentCurve = false; - //鏄惁鏄剧ず瀛愬埢搴� - m_displayStyle.isDispMiniTick = true; - m_displayStyle.isRotateLabelX = false; - m_displayStyle.isAxisIntervalX = false; - m_displayStyle.MiniTickNumber = 4; - - - setObjectColor(m_displayStyle.IsMonoColor); - }; - // - var initialSvg = function () { - if (m_divChartName == null) { - return false; - } - // - var m_svgID = "MultiSpeedCurveSvg";//鏆傛椂涓嶇煡閬撳仛鍟ョ敤 - m_svg = new svgObject().init(m_divChartName, m_chartSize.TotalWidth, m_chartSize.TotalHeight, svgClick, svgMove, m_svgID); - - return true; + //璁剧疆棰滆壊 + var 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"; } - //鍒濆鍖栭潰鏉垮昂瀵� - var initialPanelSize = function () { - if (!initialSvg()) - return; + m_displayStyle.SpectrumColor = "LightSkyBlue"; + }; - if (m_coordinatePara == null) - return; + //鍒濆鍖栨樉绀鸿缃� + 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 + } - if (m_chartSize == null) { - m_chartSize = {}; - m_chartSize.TotalWidth = document.getElementById(m_divChartName).clientWidth; - m_chartSize.TotalHeight = document.getElementById(m_divChartName).clientHeight; + //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++; } - if (m_chartSize.TotalHeight < 500) - m_chartSize.TotalHeight = 500; + isNeedRefresh = true; + } + } - 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 (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) { - space_left = 80; + attrAxisTitleP.x = attrAxisTitleP.x - 5; } - if (m_localizationType >= 2) { - space_left = 75; - space_right = 75; + 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 + ); + } - m_chartSize.SpaceTop = space_top; - m_chartSize.SpaceRight = space_right; - m_chartSize.SpaceBottom = space_bottom; - m_chartSize.SpaceLeft = space_left; + // + for ( + var i = m_coordinatePara.StartLineNoP; + i <= m_coordinatePara.EndLineNoP; + i++ + ) { + var content = UnitHelper.valueFormat( + m_coordinatePara.MinP + i * m_coordinatePara.SpaceP + ); - 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; + content = UnitHelper.formatToFixed( + parseFloat(UnitHelper.ConvertP(UnitHelper.P.KW, m_unit.P, content)), + 1 + ); - m_chartSize.DiagramWidth = m_chartSize.TotalWidth - space_left - space_right; - m_chartSize.DiagramHeight = m_chartSize.TotalHeight - space_top - space_bottom; + 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); - m_chartSize.SpaceGridX = m_chartSize.DiagramWidth / m_coordinatePara.GridNumberX; - - if (m_chartDiagramPanelStyle == ConstParas.ChartDiagramPanelStyle.Whole) { - - m_chartSize.UpDiagram = {}; - m_chartSize.UpDiagram.Up = space_top; - m_chartSize.UpDiagram.Bottom = m_chartSize.TotalHeight - space_bottom; - m_chartSize.UpDiagram.SpaceGridY = m_chartSize.DiagramHeight / m_coordinatePara.GridNumberY; - m_chartSize.UpDiagram.GridNumberY = m_coordinatePara.GridNumberY; - - m_chartSize.DownDiagram = {};//涓�鏍� - m_chartSize.DownDiagram.Up = space_top; - m_chartSize.DownDiagram.Bottom = m_chartSize.TotalHeight - space_bottom; - m_chartSize.DownDiagram.SpaceGridY = m_chartSize.DiagramHeight / m_coordinatePara.GridNumberY; - m_chartSize.DownDiagram.GridNumberY = m_coordinatePara.GridNumberY; - - - m_chartSize.PanelH = {}; - m_chartSize.PanelH.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoH; - m_chartSize.PanelH.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoH; - - m_chartSize.PanelE = {}; - m_chartSize.PanelE.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoE; - m_chartSize.PanelE.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoE; - - m_chartSize.PanelP = {}; - m_chartSize.PanelP.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoP; - m_chartSize.PanelP.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoP; - - m_chartSize.PanelNPSH = {}; - m_chartSize.PanelNPSH.Bottom = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.StartLineNoNPSH; - m_chartSize.PanelNPSH.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * m_coordinatePara.EndLineNoNPSH; - - //console.log(m_chartSize) - //鎶婇棿闅欏紕灏忕偣 - var areaAttr = { - x: space_left, - y: space_top, - width: m_chartSize.DiagramWidth, - height: m_chartSize.DiagramHeight - }; - - var areaStyle = { - "stroke-width": "1px", - "stroke": "#cccccc", - "fill": "#ffffff", - "fill-opacity": "0.5", - "zIndex:": 5 - }; - - // - m_svg.createArea(areaAttr, areaStyle); - } - else { - var panel_space = 35; - m_chartSize.PanelSpace = panel_space; - - var grid_num_h = m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH; - var grid_num_e = m_coordinatePara.EndLineNoE - m_coordinatePara.StartLineNoE; - - var grid_num_up = Math.max(grid_num_h, grid_num_e); - grid_num_up = grid_num_up + 2;//澶氫袱鏉� - if (!m_isDispCurveQE) { - grid_num_up = m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH; - } - //console.log(grid_num_up, grid_num_h, grid_num_e) ; - var grid_num_NPSH = m_coordinatePara.EndLineNoNPSH - m_coordinatePara.StartLineNoNPSH; - var grid_num_p = m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP; - var grid_num_down = Math.max(grid_num_NPSH, grid_num_p) + 1; - - - m_chartSize.UpDiagram = {}; - m_chartSize.UpDiagram.Up = space_top; - m_chartSize.UpDiagram.SpaceGridY = (m_chartSize.DiagramHeight - panel_space) / (grid_num_up + grid_num_down); - m_chartSize.UpDiagram.Bottom = space_top + grid_num_up * m_chartSize.UpDiagram.SpaceGridY; - m_chartSize.UpDiagram.GridNumberY = grid_num_up; - - - m_chartSize.DownDiagram = {}; - m_chartSize.DownDiagram.Up = m_chartSize.UpDiagram.Bottom + panel_space; - m_chartSize.DownDiagram.SpaceGridY = (m_chartSize.DiagramHeight - panel_space) / (grid_num_up + grid_num_down); - m_chartSize.DownDiagram.Bottom = m_chartSize.TotalHeight - space_bottom; - m_chartSize.DownDiagram.GridNumberY = grid_num_down; - - - - m_chartSize.PanelH = {}; - m_chartSize.PanelH.Bottom = m_chartSize.UpDiagram.Up + m_chartSize.UpDiagram.SpaceGridY * grid_num_h; - m_chartSize.PanelH.Up = m_chartSize.UpDiagram.Up; - - m_chartSize.PanelE = {}; - m_chartSize.PanelE.Bottom = m_chartSize.UpDiagram.Bottom; - m_chartSize.PanelE.Up = m_chartSize.UpDiagram.Bottom - m_chartSize.UpDiagram.SpaceGridY * grid_num_e; - - m_chartSize.PanelP = {}; - m_chartSize.PanelP.Up = m_chartSize.DownDiagram.Up; - m_chartSize.PanelP.Bottom = m_chartSize.DownDiagram.Up + m_chartSize.DownDiagram.SpaceGridY * grid_num_p; - - - m_chartSize.PanelNPSH = {}; - m_chartSize.PanelNPSH.Bottom = m_chartSize.DownDiagram.Bottom; - m_chartSize.PanelNPSH.Up = m_chartSize.DownDiagram.Bottom - m_chartSize.DownDiagram.SpaceGridY * grid_num_NPSH; - - //console.log(m_chartSize) - } - }; - // - var getSvgObjByName = function (objName) { - return m_svg.getPathByName(objName); - }; - //浠g爜涓存椂娉ㄩ噴 - var svgClick = function (e) { - - }; - // - var svgMove = function (e) { - //alert("svgMove"); - }; - - //缈昏瘧 - var getTranslateString = function (cn) { - if (m_localizationType == 0) - return cn; - if(m_localizationType == 6){//ko - if (cn == "娴侀噺") - return "鞙犽焿"; - else if (cn == "鍘嬪姏") - return "鞎曤牓氚涬嫟"; - else if (cn == "鎵▼") - return "鞏戩爼"; - else if (cn == "鏁堢巼") - return "須湪靹�"; - else if (cn == "鍔熺巼") - return "韺岇泴"; - } - if(m_localizationType == 8){//es - if (cn == "娴侀噺") - return "Caudal"; - else if (cn == "鍘嬪姏") - return "Presi贸n"; - else if (cn == "鎵▼") - return "Cabezal"; - else if (cn == "鏁堢巼") - return "Eficiencia"; - else if (cn == "鍔熺巼") - return "Potencia"; - } - if(m_localizationType == 5){//ru - if (cn == "娴侀噺") - return "锌芯褌芯泻"; - else if (cn == "鍘嬪姏") - return "写邪胁谢械薪懈械"; - else if (cn == "鎵▼") - return "薪邪锌芯褉"; - else if (cn == "鏁堢巼") - return "褝褎褎械泻褌懈胁薪芯褋褌褜"; - else if (cn == "鍔熺巼") - return "屑芯褖薪芯褋褌褜聽"; - } - if (cn == "娴侀噺") - return "Flow"; - else if (cn == "鍘嬪姏") - return "Press"; - else if (cn == "鎵▼") - return "Head"; - else if (cn == "鏁堢巼") - return "Eta"; - else if (cn == "鍔熺巼") - return "Power"; - else if (cn == "姹借殌") - return "NPSHr"; - else - return cn; - }; - //缁樺埗x鍧愭爣(鍚爣棰�) - var createXAxis = function (bottom_posi, title_space) { - if (m_coordinatePara == null) { - return; - } - - //鍒诲害绾� - var attrAxisTickX = { - "stroke": "black", - "stroke-width": "1", - "fill": "none", - "zIndex": 10 + //鏂囧瓧 + var attrAxisLabelP = { + opacity: 1, + x: m_chartSize.DiagramLeft - 10, + y: posiY_grid + 5, + "text-anchor": "end", }; - //鍒诲害闀垮害 - var minTickLength = 4; - var tickLength = 6; + m_svg.createText(attrAxisLabelP, styleAxisLabelP, content); - //鍒诲害鏂囧瓧 - 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 = new Array(); - 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 = new Array(); - valueMini.push("M ", pois_minTick, " ", bottom_posi, " L ", pois_minTick, " ", bottom_posi + minTickLength); - m_svg.createPath(null, valueMini.join(''), attrAxisTickX, null); - } - } + //瀛愬埢搴︾嚎 + 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 (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; + //姹借殌 + if ( + m_isHaveNpsh && + m_coordinatePara.EndLineNoNPSH > m_coordinatePara.StartLineNoNPSH + ) { + //鍒诲害绾� + var attrAxisTickNPSH = { + stroke: m_displayStyle.ColorNPSH, + "stroke-width": "1", + fill: "none", + }; - let unit_name = UnitHelper.GetUnitNameQ(m_unit.Q); - m_svg.createText(attrAxisTitleX, styleAxisTitleX, getTranslateString("娴侀噺") + " (" + unit_name + ")"); + //鍒诲害鏂囧瓧 + 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; + } - }; - //缁樺埗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.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 + ); + } } - - //鍒诲害闀垮害 - 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 = new Array(); - valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid); - m_svg.createPath(null, valueMain.join(''), attrAxisTickH, null); - - //鏂囧瓧 - var attrAxisLabelH = { - "opacity": 1, - "x": m_chartSize.DiagramLeft - 10, - "y": posiY_grid + 5, - "text-anchor": "end" - }; - var content = UnitHelper.valueFormat(m_coordinatePara.MinH + i * m_coordinatePara.SpaceH); - m_svg.createText(attrAxisLabelH, styleAxisLabelH, content); - - //瀛愬埢搴︾嚎 - if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoH) { - for (var j = 1; j <= m_displayStyle.MiniTickNumber; j++) { - var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / (m_displayStyle.MiniTickNumber + 1); - var valueMini = new Array(); - valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick); - m_svg.createPath(null, valueMini.join(''), attrAxisTickH, null); - } - } - } + } else { + var content = "Head (" + unit_h_name + ")"; + if (m_unit.H == UnitHelper.H.MPa) { + content = "Press (MPa)"; } - - - //鏁堢巼 - 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 = new Array(); - 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 = new Array(); - 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_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 + ); + } - //鍔熺巼 - if (m_coordinatePara.EndLineNoP > m_coordinatePara.StartLineNoP) { - //鍒诲害绾� - var attrAxisTickP = { - "stroke": m_displayStyle.ColorP, - "stroke-width": "1", - "fill": "none" - }; + // + for ( + var i = 0; + i <= m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH; + i++ + ) { + var posiY_grid = + m_chartSize.PanelH.Bottom - m_chartSize.UpDiagram.SpaceGridY * i; - let unit_p_name = UnitHelper.GetUnitNameP(m_unit.P); + //涓诲埢搴� + 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 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 + ";"; + //鏂囧瓧 + 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_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 = new Array(); - 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 = new Array(); - 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_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, "鐜�"); - //姹借殌 - if (m_isHaveNpsh && m_coordinatePara.EndLineNoNPSH > m_coordinatePara.StartLineNoNPSH) { - //鍒诲害绾� - var attrAxisTickNPSH = { - "stroke": m_displayStyle.ColorNPSH, - "stroke-width": "1", - "fill": "none" - }; + 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 + ); + } - //鍒诲害鏂囧瓧 - 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 + ";"; + // + 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 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); - } + //鏂囧瓧 + 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; - // - 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 = new Array(); - valueMain.push("M ", m_chartSize.DiagramRight, " ", posiY_grid, " L ", m_chartSize.DiagramRight + tickLength, " ", posiY_grid); - m_svg.createPath(null, valueMain.join(''), attrAxisTickNPSH, null); + var content = UnitHelper.valueFormat(axis_e); + m_svg.createText(attrAxisLabelE, styleAxisLabelE, content); - //鏂囧瓧 - 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 = new Array(); - valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick); - m_svg.createPath(null, valueMini.join(''), attrAxisTickNPSH, null); - } - } - } + //瀛愬埢搴︾嚎 + 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); + } } - }; - //缁樺埗Y鍧愭爣(鍚爣棰�) - var createYAxis_TwoPanel = function () { - if (m_coordinatePara == null) { - return; + } + } + + //鍔熺巼 + 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, "鐜�"); - //鍒诲害闀垮害 - 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 = new Array(); - valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid); - m_svg.createPath(null, valueMain.join(''), attrAxisTickH, null); - - //鏂囧瓧 - var attrAxisLabelH = { - "opacity": 1, - "x": m_chartSize.DiagramLeft - 10, - "y": posiY_grid + 5, - "text-anchor": "end" - }; - var axis_h = UnitHelper.ConvertH_fromM(m_unit.H,m_coordinatePara.MinH + (i + m_coordinatePara.StartLineNoH) * m_coordinatePara.SpaceH); - if(axis_h < -0.01) - continue; - var content = UnitHelper.valueFormat(axis_h); - m_svg.createText(attrAxisLabelH, styleAxisLabelH, content); - - //瀛愬埢搴︾嚎 - if (m_displayStyle.isDispMiniTick && i != (m_coordinatePara.EndLineNoH - m_coordinatePara.StartLineNoH)) { - for (var j = 1; j <= m_displayStyle.MiniTickNumber; j++) { - var pois_minTick = posiY_grid - m_chartSize.UpDiagram.SpaceGridY * j / (m_displayStyle.MiniTickNumber + 1); - var valueMini = new Array(); - valueMini.push("M ", m_chartSize.DiagramLeft, " ", pois_minTick, " L ", m_chartSize.DiagramLeft - minTickLength, " ", pois_minTick); - m_svg.createPath(null, valueMini.join(''), attrAxisTickH, null); - } - } - } + 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); - //鏁堢巼 - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - valueMain.push("M ", m_chartSize.DiagramLeft, " ", posiY_grid, " L ", m_chartSize.DiagramLeft - tickLength, " ", posiY_grid); - m_svg.createPath(null, valueMain.join(''), attrAxisTickP, null); - - //鏂囧瓧 - var attrAxisLabelP = { - "opacity": 1, - "x": m_chartSize.DiagramLeft - 10, - "y": posiY_grid + 5, - "text-anchor": "end" - }; - var aixs_p = UnitHelper.ConvertP_fromKW(m_unit.P,m_coordinatePara.MinP + (i + m_coordinatePara.StartLineNoP) * m_coordinatePara.SpaceP); - aixs_p = UnitHelper.getDispValueP(aixs_p); - if (aixs_p < -0.01) - continue; - var content = aixs_p.toString(); - m_svg.createText(attrAxisLabelP, styleAxisLabelP, content); - - //瀛愬埢搴︾嚎 - if (m_displayStyle.isDispMiniTick && i != m_coordinatePara.EndLineNoP - && i != (m_coordinatePara.EndLineNoP - m_coordinatePara.StartLineNoP)) { - for (var j = 1; j < m_displayStyle.MiniTickNumber; j++) { - var pois_minTick = posiY_grid - m_chartSize.DownDiagram.SpaceGridY * j / m_displayStyle.MiniTickNumber; - var valueMini = new Array(); - 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 = new Array(); - 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 = new Array(); - valueMini.push("M ", m_chartSize.DiagramRight, " ", pois_minTick, " L ", m_chartSize.DiagramRight + minTickLength, " ", pois_minTick); - m_svg.createPath(null, valueMini.join(''), attrAxisTickNPSH, null); - } - } - } - } - }; - //缁樺埗闈㈡澘 - var drawDiagramPanel = function () { - if (m_chartDiagramPanelStyle == ConstParas.ChartDiagramPanelStyle.Whole) { - //缁樺埗缃戞牸绾� - createGridLineDiagram_Whole(); - - //缁樺埗X鍧愭爣 - createXAxis(m_chartSize.DownDiagram.Bottom, 40); - - //缁樺埗Y鍧愭爣 - createYAxis_Whole(); - } - else { - //缁樺埗缃戞牸绾� - createGridLineDiagram_TwoPanel(); - - //缁樺埗X鍧愭爣 - createXAxis(m_chartSize.UpDiagram.Bottom, 0); - createXAxis(m_chartSize.DownDiagram.Bottom, 40); - - //缁樺埗Y鍧愭爣 - createYAxis_TwoPanel(); - } - }; - //浜х敓瑁呯疆鏇茬嚎 - var drawEquipmentCurve = function () { - $("#EquipmentCurve").remove(); - if (m_chartObject.EquipmentSectPt == null) - return; - var pointNumber = 20; - var EquipmentCurve = []; - var space = m_chartObject.EquipmentSectPt.X / (pointNumber - 1); - var k = (m_chartObject.EquipmentSectPt.Y - m_equipZeroH) / (m_chartObject.EquipmentSectPt.X * m_chartObject.EquipmentSectPt.X); - for (var i = 0; i < pointNumber; i++) { - var pt = {}; - pt.X = space * i; - pt.Y = m_equipZeroH + k * pt.X * pt.X; - EquipmentCurve.push(pt); - } - createCurveQH("EquipmentCurve", EquipmentCurve, 1, m_displayStyle.ColorEquipment, m_displayStyle.isDispEquipmentCurve); - }; - - - - //缁樺埗鏇茬嚎(娴侀噺鎵▼) - var createCurveQH = function (curveElementName, curvePoints, curveWidth, curveColor, curveIsDisp, curveDashType) { - if (curvePoints == null) { - return; - } - if (curveElementName == null) { - return; - } - - var pixelPoints = new Array(); - for (var v = 0; v < curvePoints.length; v++) { - var pt = curvePoints[v]; - var x = getPixelValueQ(pt.X); - var y = getPixelValueH(pt.Y); - pixelPoints.push({ "X": x, "Y": y }); - } - - return createCurveQH_pixel(curveElementName, pixelPoints, curveWidth, curveColor, curveIsDisp, curveDashType); - }; - //缁樺埗鏇茬嚎(娴侀噺鎵▼) : 鍍忕礌鐐� - var createCurveQH_pixel = function (curveElementName, pixelPoints, curveWidth, curveColor, isDisp, curveDashType) { - if (pixelPoints == null || pixelPoints.length < 3) { - return; - } - if (curveElementName == null) { - return; - } - var pathValue = transBezierCurveToPath(pixelPoints); - if (pathValue == null || pathValue == undefined) - return; - //鏈夋椂浼氭姤閿欙紝鍔犱笂杩欎釜灏辨病浜� tangxu 20151122 - if (pathValue.toString().indexOf("M ,NaN, ,NaN") == 0) { - return; + //鏂囧瓧 + var attrAxisLabelP = { + opacity: 1, + x: m_chartSize.DiagramLeft - 10, + y: posiY_grid + 5, + "text-anchor": "end", }; - var style = { - "stroke-width": "2px", - "stroke": m_displayStyle.ColorH, - "fill": "none", - "fill-opacity": "0.5", - //"stroke-dasharray":"5 3", - "shape-rendering": "geometricPrecision", - "zIndex:": 7 - }; - if (curveWidth != null) { - style["stroke-width"] = curveWidth; - } - if (curveColor != null) { - style["stroke"] = curveColor; - } - if (curveDashType != null) { - style["stroke-dasharray"] = curveDashType;//'10, 10';//'10, 10, 5, 5' - } - //console.log(curveElementName,pathValue) - //缁樺埗 - m_svg.createPath(curveElementName, pathValue.join(''), { - "id": curveElementName - }, style); - //鏄惁鏄剧ず - if (isDisp != null && !isDisp) { - $("#" + curveElementName).hide(); - } + 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); - //缁樺埗瀹氫箟鐐� - /*pixelPoints.forEach(pixel_pt => { + //瀛愬埢搴︾嚎 + 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, @@ -1232,1817 +2126,2229 @@ 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); - return pixelPoints; + 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, }; - //缁樺埗鐩寸嚎 - var createLineQH = function (curveElementName, point1, point2, curveWidth, curveColor, objTag) { - if (point1 == null || point2 == null) { - return; + 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" + ); } - if (curveElementName == null) { - return; - } - var x1 = getPixelValueQ(point1.X); - var y1 = getPixelValueH(point1.Y); + } + } + }; + //缁樺埗姘村嵃(鏂囧瓧) + var drawTextWaterMark = function (text) { + if (!text) { + return; + } - var x2 = getPixelValueQ(point2.X); - var y2 = getPixelValueH(point2.Y); + 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 style = { - "stroke-width": "2px", - "stroke": m_displayStyle.ColorH, - "fill": "none", - "fill-opacity": "0.5", - //"stroke-dasharray":"5 3", - "shape-rendering": "geometricPrecision", - "zIndex:": 7 + 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鍦╟urve鐨�(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 (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 (x == curve[i].Point3.X) { + return { + X: curve[i].Point3.X, + Y: curve[i].Point3.Y, }; - if (circleSize != null) { - attr.r = circleSize; - } - if (circleColor != null) { - style["stroke"] = circleColor; - } - - m_svg.createCircle(curveElementName, attr, style); - }; - //缁樺埗鏂囧瓧 textAnchor 鏂囧瓧瀵归綈 start | middle | end - var drawTextByQH = function (curveElementName, text, point, textSize, textColor, offsetPixelX, offsetPixelY, textAnchor) { - if (!text) { - return; - } - if (!point) { - return; - } - - var xPixel = getPixelValueQ(point.X); - var yPixel = getPixelValueH(point.Y); - if (offsetPixelX != null) { - xPixel += offsetPixelX; - } - if (offsetPixelY != null) { - yPixel -= offsetPixelY; - } - - var textStyle = "stroke-width:1px; ";//font-weight:bold; fill-opacity:0.9; - if (textColor != null) { - textStyle += " fill:" + textColor + ";"; - } - else { - textStyle += " fill:#000000;"; - } - if (textSize != null) { - textStyle += " font-size:" + textSize + "px;" - } else { - textStyle += " font-size:12px;"; - } - if (textAnchor != null) { - textStyle += " text-anchor:" + textAnchor + ";"; - } - if (curveElementName == null) { - return m_svg.createText({ - "opacity": 0.5, - "y": yPixel, - "x": xPixel - }, textStyle, text); - } - else { - return m_svg.createText({ - "id": curveElementName, - "opacity": 0.5, - "y": yPixel, - "x": xPixel - }, textStyle, text); - } - }; - //杞�熸枃瀛� - var drawSpeedTextByQH = function (curveElementName, speed, point, textColor) { - - if (!point) { - return; - } - - var xPixel = getPixelValueQ(point.X) + 12; - var yPixel = getPixelValueH(point.Y) + 8; - - var textStyle = "font-size:13px;text-anchor:start; font-weight:bold; ";//鍔犵矖 fill-opacity:0.9 stroke-width:1px; - textStyle += " fill:" + textColor + ";"; - - var text = speed + " rpm"; - return m_svg.createText({ - "id": curveElementName, - "opacity": 0.5, - "y": yPixel, - "x": xPixel - }, textStyle, text); - - }; - var drawSpeedTextByQP = function (curveElementName, speed, point, textColor) { - - if (!point) { - return; - } - - var xPixel = getPixelValueQ(point.X) + 11; - var yPixel = getPixelValueP(point.Y) + 4; - - var textStyle = "font-size:13px;text-anchor:start;font-weight:bold;";//鍔犵矖 stroke-width:1px; fill-opacity:0.9 - textStyle += " fill:" + textColor + ";"; - - var text = speed + " rpm"; - return m_svg.createText({ - "id": curveElementName, - "opacity": 0.5, - "y": yPixel, - "x": xPixel - }, textStyle, text); - - }; - //缁樺埗璁捐鐐� - var drawDesignPoint = function () { - if (m_chartObject.DesignPoint4StdUnit == null) - return; - var defaultDp = m_chartObject.DesignPoint4StdUnit; - - var DispStyleType = m_displayStyle.DesignPointDispType; - if (DispStyleType == 2) {//鍊掍笁瑙� - - var xPixel = getPixelValueQ(defaultDp.X); - var yPixel = getPixelValueH(defaultDp.Y); - - var xTri = m_chartSize.DiagramWidth / 20; - var yTri = xTri / 2; - var style = { - "stroke-width": "2px", - "stroke": "red", - "fill": "none", - "fill-opacity": "0.5", - //"stroke-dasharray":"5 3", - "shape-rendering": "geometricPrecision", - "zIndex:": 18 - }; - //if (curveWidth != null) { - // style["stroke-width"] = curveWidth; - //} - //if (curveColor != null) { - // style["stroke"] = curveColor; - //} - - - var temp = "M x1 y1 L x2 y2"; - var pathValue = temp.replace("x1", xPixel).replace("y1", yPixel).replace("x2", (xPixel - xTri)).replace("y2", yPixel); - m_svg.createPath("DesignPointWater1", pathValue, { - //"class": "DesignPoint1", - "tag": "DesignPoint1" - }, style); - pathValue = temp.replace("x1", xPixel).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri)); - m_svg.createPath("DesignPointWater2", pathValue, { - //"class": "DesignPoint1", - "tag": "DesignPoint1" - }, style); - pathValue = temp.replace("x1", xPixel - xTri).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri)); - m_svg.createPath("DesignPointWater3", pathValue, { - //"class": "DesignPoint1", - "tag": "DesignPoint1" - }, style); - - - //m_svg.createPath(objName, pathValue.join(''), { - // "id": objName - //}, style); - - pathValue = temp.replace("x1", xPixel - xTri / 3).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri / 3)); - m_svg.createPath("DesignPointWater4", pathValue, { - //"class": "DesignPoint1", - "tag": "DesignPoint1" - }, style); - - pathValue = temp.replace("x1", xPixel - xTri * 2 / 3).replace("y1", yPixel).replace("x2", xPixel).replace("y2", (yPixel + yTri * 2 / 3)); - m_svg.createPath("DesignPointWater5", pathValue, { - //"class": "DesignPoint1", - "tag": "DesignPoint1" - }, style); - - } - else {//鍗佸瓧绾� - var x = defaultDp.X; - var y = defaultDp.Y; - var point1 = { X: x, Y: y * m_designPointTolerance[2] }; - var point2 = { X: x, Y: y * m_designPointTolerance[3] }; - createLineQH("DesignPointWater1", point1, point2, 3, "red", "DesignPoint1"); - - point1 = { X: x * m_designPointTolerance[0], Y: y }; - point2 = { X: x * m_designPointTolerance[1], Y: y }; - createLineQH("DesignPointWater2", point1, point2, 3, "red", "DesignPoint1"); - } - - }; - - //缁樺埗鏇茬嚎(娴侀噺鏁堢巼) - var createCurveQE = function (curveElementName, points, curveWidth, curveColor, curveIsDisp, curveDashType) { - if (points == null) { - return null; - } - if (curveElementName == null) { - return null; - } - var isForceZeroPt = true; - if (curveElementName == "RegionBlodCurveQE_Allow") - isForceZeroPt = false; - if (curveElementName == "PerferBlodCurveQE_Allow") - isForceZeroPt = false; - - var pixelPoints = new Array(); - 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) { - $("#" + curveElementName).hide(); - } - return pixelPoints; - }; - //缁樺埗鏇茬嚎(娴侀噺鍔熺巼) - var createCurveQP = function (curveElementName, points, curveWidth, curveColor, curveIsDisp, curveDashType) { - if (points == null) { - return null; - } - if (curveElementName == null) { - return null; - } - - var pixelPoints = new Array(); - 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) { - $("#" + curveElementName).hide(); - } - - 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 = new Array(); - 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) { - $("#" + curveElementName).hide(); - } - }; - //娓呯悊 - var ClearCurveElement = function () { - - - - - }; - - - - - //缁樺埗绛夋晥绾� - var drawEquepEtaCurveList = function () { + } + if (x > curve[i].Point0.X && x < curve[i].Point3.X) { + var ptBizer = curve[i]; // - 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"); - } + 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; } - } - }; - - - //缁樺埗姘村嵃(鏂囧瓧) - var drawTextWaterMark = function (text) { - if (!text) { - return; - } - - var logoStyle = "-webkit-transform: rotate(5deg);-moz-transform: rotate(5deg);transform: rotate(15deg);fill:#000000;fill-opacity:0.6;font-weight:bold;stroke-width:1px;font-size:16px;z-index:0"; - - var w = 30; - var h = 80; - var isDrawSecond = true; - var left = (m_chartSize.DiagramRight - m_chartSize.DiagramLeft - text.length * w) / 2; - - for (var i = 0; i < text.length; i++) { - m_svg.createText({ - "opacity": 0.5, - "y": m_chartSize.SpaceTop + h + i * 10, - "x": m_chartSize.DiagramLeft + left + i * w - }, logoStyle, text[i], 0, "WaterMarkText1"); - - if (isDrawSecond) { - var endHeight = h + text.length * 10;//: h + text.length * 10 - 80; - m_svg.createText({ - "opacity": 0.5, - "y": m_chartSize.UpDiagram.Bottom - endHeight + i * 10, - "x": m_chartSize.DiagramLeft + left + i * w - }, logoStyle, text[i], 0, "WaterMarkText1") - } - } - }; - - //缁樺埗姘村嵃(鍥剧墖) - var drawLogoWaterMark = function () { - var watermark_img_url = "/static/img/watermark/default.png"; - - var img_watermark = new Image() - img_watermark.src = watermark_img_url; - img_watermark.onload = function () { - - var watermark_image_width_real = img_watermark.width - var watermark_image_height_real = img_watermark.height; - - var ratio_byHeight = m_chartSize.TotalHeight * 0.2 / watermark_image_height_real; - var ratio_byWidth = m_chartSize.TotalWidth * 0.2 / watermark_image_width_real; - - var ratio_waterMark = Math.min(ratio_byHeight, ratio_byWidth); - - var watermark_image_width = watermark_image_width_real * ratio_waterMark; - var watermark_image_height = watermark_image_height_real * ratio_waterMark; - - var logoStyle = "-webkit-transform: rotate(5deg);-moz-transform: rotate(5deg);transform: rotate(15deg);fill:#000000;fill-opacity:0.6;font-weight:bold;stroke-width:1px;font-size:16px;z-index:0"; - var logoPosi1 = { - "opacity": 0.8, - "y": m_chartSize.TotalHeight * 1 / 4 - watermark_image_height / 2, - "x": m_chartSize.TotalWidth * 1 / 4 - watermark_image_width / 2, - "width": watermark_image_width, - "height": watermark_image_height - } - m_svg.createImage(logoPosi1, logoStyle, "WaterMarkImage2", watermark_img_url); - - var logoPosi2 = { - "opacity": 0.8, - "y": m_chartSize.TotalHeight * 3 / 4 - watermark_image_height / 2, - "x": m_chartSize.TotalWidth * 1 / 4 - watermark_image_width / 2, - "width": watermark_image_width, - "height": watermark_image_height - } - m_svg.createImage(logoPosi2, logoStyle, "WaterMarkImage2", watermark_img_url); - - - var logoPosi3 = { - "opacity": 0.8, - "y": m_chartSize.TotalHeight * 1 / 4 - watermark_image_height / 2, - "x": m_chartSize.TotalWidth * 3 / 4 - watermark_image_width / 2, - "width": watermark_image_width, - "height": watermark_image_height - } - m_svg.createImage(logoPosi3, logoStyle, "WaterMarkImage3", watermark_img_url); - - var logoPosi4 = { - "opacity": 0.8, - "y": m_chartSize.TotalHeight * 3 / 4 - watermark_image_height / 2, - "x": m_chartSize.TotalWidth * 3 / 4 - watermark_image_width / 2, - "width": watermark_image_width, - "height": watermark_image_height - } - m_svg.createImage(logoPosi4, logoStyle, "WaterMarkImage4", watermark_img_url); - } - }; - //浜х敓瑁呯疆鏇茬嚎 - var drawEquipmentCurve = function () { - $("#EquipmentCurve").remove(); - if (m_chartObject.EquipmentSectPt == null) - return; - var pointNumber = 20; - var EquipmentCurve = []; - var space = m_chartObject.EquipmentSectPt.X / (pointNumber - 1); - var k = (m_chartObject.EquipmentSectPt.Y - m_equipZeroH) / (m_chartObject.EquipmentSectPt.X * m_chartObject.EquipmentSectPt.X); - for (var i = 0; i < pointNumber; i++) { - var pt = {}; - pt.X = space * i; - pt.Y = m_equipZeroH + k * pt.X * pt.X; - EquipmentCurve.push(pt); - } - createCurveQH("EquipmentCurve", EquipmentCurve, 1, m_displayStyle.ColorEquipment, m_displayStyle.isDispEquipmentCurve); - }; - //鏌ヨ鏌ヨ绔栫洿鎸囧绾� - var drawQueryIndicatVertLine = function () { - - if ($("#infoDv4VerticalLine").is("div")) { - $("#infoDv4VerticalLine").remove(); - } - - //鍏堝垱寤虹敤浜庢斁缃煡璇俊鎭殑Div - var htmlDiv = "<lable style='font-size:7px'>" + getTranslateString("娴侀噺") + "</label>"; - $("#" + m_divChartName).append($("<div id='infoDv4VerticalLine'></div>").css({ - "position": "relative",//relative absolute - "color": "gray", - "font-size": "9px", - //"font-family": "Times New Roman", - //"font-weight": "bold", - "text-align": "left", - "width": "120px", - "left": (m_chartSize.DiagramRight - 125).toString() + "px", - "top": (12 - m_chartSize.TotalHeight).toString() + "px",// + m_divChartName + "px" - }).html(htmlDiv).hide()); - - m_infoDv4VerticalLine = $("#infoDv4VerticalLine"); - - - var attr4verticalLine = { - "stroke": "rgb(136 136 221)", - "stroke-width": "5", - "fill": "none", - "zIndex": 100, - "stroke-dasharray": "10 3", - "cursor": 'pointer', - "stroke-opacity": '1', - "shape-rendering": "geometricPrecision", - }; - - var xStartValuePixel = (m_chartSize.DiagramLeft + m_chartSize.DiagramRight) / 2; // 寮�濮嬩綅缃� - - - //鍒涘缓绔栫洿绾� - var pathValue1 = new Array(); - var vertialLinePathName1 = "verticalLine1"; - pathValue1.push("M ", xStartValuePixel, " ", m_chartSize.UpDiagram.Up, " L ", xStartValuePixel, " ", m_chartSize.DownDiagram.Bottom); - m_svg.createPath(vertialLinePathName1, pathValue1.join(''), { - id: vertialLinePathName1 - }, attr4verticalLine, null); - m_queryInfoIndicatorLineV = $(getSvgObjByName(vertialLinePathName1)); - - - - - - drawQueryDataInfo(xStartValuePixel); - - - var isMoveVerticalLine = false; - //m_svg.getPathByName("verticalLine") - - m_queryInfoIndicatorLineV.mousedown(function (e) { - isMoveVerticalLine = true; - //WebApp.stopDefault(e); - e.preventDefault(); - }); - - - $(document).mousemove(function (e) { - - if (isMoveVerticalLine) { - var svg_root = m_svg.getRootNode(); - var svg = $(svg_root); - - var e = window.event || e; - if (e.clientX - svg.offset().left > m_chartSize.DiagramLeft && - m_chartSize.DiagramRight + svg.offset().left - e.clientX > 0 && - e.clientY - svg.offset().top > m_chartSize.DiagramTop && - m_chartSize.DiagramBottom + svg.offset().top - e.clientY > 0) { - //褰撳墠榧犳爣浣嶇疆 x鐨勫儚绱� - var xPixel = parseFloat(e.clientX - svg.offset().left); - // - drawQueryDataInfo(xPixel); - //淇敼浣嶇疆 - if (m_queryInfoIndicatorLineV) { - var pathValue1 = new Array(); - pathValue1.push("M ", xPixel, " ", m_chartSize.UpDiagram.Up, " L ", xPixel, " ", m_chartSize.DownDiagram.Bottom); - m_queryInfoIndicatorLineV.attr("d", pathValue1.join('')); - } - } - } - }).mouseup(function (e) { - if (isMoveVerticalLine) { - isMoveVerticalLine = false; - } - }); - - - //璁剧疆鏄剧ず - setQueryIndicatVertLineVisible(m_dispVerticalLine); - }; - //鑾峰彇x鍦╟urve鐨�(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) { + } + // + if (sectY != null && sectX != null) { return { - X: curve[iPtCount - 1].Point3.X, Y: curve[iPtCount - 1].Point3.Y + 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鍦╟urve鐨�(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; - }; - //鑾峰彇x鍦╟urve鐨�(X Y)鐐瑰�� (鍍忕礌鐐�) - var getBezierPointX = function (curve, y) { - if (curve == null) - return null; - var iPtCount = curve.length; - - if (y < curve[0].Point0.Y && y < curve[iPtCount - 1].Point3.Y) { - return null; - } - if (y > curve[0].Point0.Y && y > curve[iPtCount - 1].Point3.Y) { - return null; - } - - for (var i = 0; i < iPtCount; i++) { - var ptBizer = curve[i]; - - if (y < ptBizer.Point0.Y && y < ptBizer.Point3.Y) { - continue; - } - if (y > ptBizer.Point0.Y && y > ptBizer.Point3.Y) { - continue; - } - - // - try { - var minDis = Math.abs(ptBizer.Point3.Y - ptBizer.Point0.Y); - - var sectY = null; - var sectX = null; - for (var uu = 0; uu <= 1; uu = uu + 0.05) { - var x0 = ptBizer.Point0.X * uu * uu * uu; - var x1 = 3 * ptBizer.Point1.X * uu * uu * (1 - uu); - var x2 = 3 * ptBizer.Point2.X * uu * (1 - uu) * (1 - uu); - var x3 = ptBizer.Point3.X * (1 - uu) * (1 - uu) * (1 - uu); - - var y0 = ptBizer.Point0.Y * uu * uu * uu; - var y1 = 3 * ptBizer.Point1.Y * uu * uu * (1 - uu); - var y2 = 3 * ptBizer.Point2.Y * uu * (1 - uu) * (1 - uu); - var y3 = ptBizer.Point3.Y * (1 - uu) * (1 - uu) * (1 - uu); - - var curveX = x0 + x1 + x2 + x3; - var curveY = y0 + y1 + y2 + y3; - - if (Math.abs(curveY - y) < minDis) { - minDis = Math.abs(curveY - y); - sectY = curveY - sectX = curveX; - } - } - // - if (sectY != null && sectX != null) { - return { - X: sectX, Y: sectY - }; - } - } - catch (ex) { - //alert(ex.message); - return null; - } - } - - return null; - }; - //缁樺埗/鏄剧ず 鍙傛暟鏌ヨ淇℃伅 - var drawQueryDataInfo = function (xPixel) {//x鐨勫儚绱� - if (xPixel == null) - return; - if (m_maxSpeedCurve == null) - return; - if (m_maxSpeedCurve.PixelQH == null) - return; - //娴侀噺 - //console.log(m_coordinatePara,m_chartSize, xPixel); - let flow_stdUnit = getActualValueQ(xPixel); - if (flow_stdUnit == null) - return; - //console.log(flow_stdUnit); - if (flow_stdUnit < 0.1) - return; - - var flow_info = {}; - flow_info.text = getTranslateString("娴侀噺"); - flow_info.value = UnitHelper.getDispValueQ(UnitHelper.ConvertQ_fromM3H(m_unit.Q, flow_stdUnit)); - flow_info.unit = UnitHelper.GetUnitNameQ(m_unit.Q); - if (flow_info.value == null || flow_info.value == "") - return; - // console.log(flow_info); - - //鎵▼ - var head_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQH, xPixel); - if (head_pixel_pt == null) - return; - var head_stdUnit = getActualValueH(head_pixel_pt.Y); - var head_info = {}; - head_info.text = getTranslateString("鎵▼"); - head_info.unit = UnitHelper.GetUnitNameH(m_unit.H); - head_info.value = UnitHelper.getDispValueH(UnitHelper.ConvertH_fromM(m_unit.H, head_stdUnit)); - - //鏁堢巼 - var eff_info = {}; - eff_info.value = ""; - if (m_isDispCurveQE) { - var eta_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel); - - if (eta_pixel_pt != null) { - var eta_stdUnit = getActualValueE(eta_pixel_pt.Y); - - eff_info.text = getTranslateString("鏁堢巼"); - eff_info.value = parseFloat(eta_stdUnit.toFixed(1)); - eff_info.unit = "%"; - } - } - - //鍔熺巼 - var power_info = {}; - power_info.value = ""; - var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel); - if (power_pixel_pt != null) { - var power_stdUnit = getActualValueP(power_pixel_pt.Y); - power_info.text = getTranslateString("鍔熺巼"); - power_info.value = UnitHelper.getDispValueP(UnitHelper.ConvertP_fromKW(m_unit.P, power_stdUnit)); - power_info.unit = UnitHelper.GetUnitNameP(m_unit.P); - } - - - var npsh_info = {};//姹借殌 - npsh_info.text = getTranslateString("姹借殌"); - npsh_info.value = ''; - npsh_info.unit = "m"; - - if (m_maxSpeedCurve.PixelNPSH != null && m_isHaveNpsh) { - var npsh_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelNPSH, xPixel); - //console.log(npsh_pixel_pt) - if (npsh_pixel_pt != null) { - var npsh_stdUnit = getActualValueNPSH(npsh_pixel_pt.Y); - npsh_info.value = UnitHelper.formatToFixed(parseFloat(npsh_stdUnit), 1); - } - } - - var tip_html = ""; - var flow_html = flow_info.text + ": " + flow_info.value + " " + flow_info.unit; - tip_html = flow_html; - //console.log("flow_info",flow_info); - - var head_html = head_info.text + ": " + head_info.value + " " + head_info.unit; - tip_html += "</br>" + head_html; - //console.log("head_info",head_info); - - if (eff_info.value != "") { - var eff_html = eff_info.text + ": " + eff_info.value + " " + eff_info.unit; - tip_html += "</br>" + eff_html; - } - - if (power_info.value != "") { - var power_html = power_info.text + ": " + power_info.value + " " + power_info.unit; - tip_html += "</br>" + power_html; - } - - if (npsh_info.value != "") { - var npsh_html = npsh_info.text + ": " + npsh_info.value + " " + npsh_info.unit; - tip_html += "</br>" + npsh_html; - } - - m_infoDv4VerticalLine.show().html(tip_html); - - - - //鑾峰彇鏌ヨ鏇茬嚎鏌ヨ寰楀埌鐨勬暟鎹� 缁欏弬鏁版煡璇娇鐢� - if (onChangeQueryDataCb != null) { - onChangeQueryDataCb({ - Q: flow_info, - H: head_info, - E: eff_info, - P: power_info, - NPSH: npsh_info - }) - } - - }; - //鏍规嵁娴侀噺鑾峰彇鐐� - var getGrpPointInWrkCurveByFlow = function (flow_stdUnit) { - if (flow_stdUnit == null) - return null; - if (flow_stdUnit < 0.1) - return null; - if (m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQH) - return null; - - //var UnitHelper.ConvertQ_fromM3H(m_unit.Q, flow_stdUnit) - var xPixel = getPixelValueQ(flow_stdUnit); - - //鎵▼ - var head_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQH, xPixel); - if (head_pixel_pt == null) - return; - var head_stdUnit = getActualValueH(head_pixel_pt.Y); - - //鏁堢巼 - var eta_stdUnit = 0; - if (m_isDispCurveQE) { - var eta_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel); - if (eta_pixel_pt != null) { - eta_stdUnit = getActualValueE(eta_pixel_pt.Y); - eta_stdUnit = parseFloat(eta_stdUnit.toFixed(1)); - } - } - - //鍔熺巼 - var power_stdUnit = 0; - var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel); - if (power_pixel_pt != null) { - power_stdUnit = getActualValueP(power_pixel_pt.Y); - } - - - var npsh_stdUnit = 0; - if (m_maxSpeedCurve.PixelNPSH != null) { - var npsh_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelNPSH, xPixel); - if (npsh_pixel_pt != null) { - npsh_stdUnit = getActualValueNPSH(npsh_pixel_pt.Y); - } - } - - var grp_pt = {}; - grp_pt.Q = flow_stdUnit; - grp_pt.H = head_stdUnit; - grp_pt.E = eta_stdUnit; - grp_pt.P = power_stdUnit; - grp_pt.NPSH = npsh_stdUnit; - - return grp_pt; - }; - //鏌ヨ绾� - var m_infoDv4VerticalLine; - var m_queryInfoIndicatorLineV; - var m_dispVerticalLine = false; - var onChangeQueryDataCb = null;//鏌ヨ澶栭儴鍥炶皟 - //璁剧疆鏄惁鏄剧ず - var setQueryIndicatVertLineVisible = function (disp) { - m_dispVerticalLine = disp; - if (disp) { - m_infoDv4VerticalLine.show(); - m_queryInfoIndicatorLineV.show(); - } - else { - m_infoDv4VerticalLine.hide(); - m_queryInfoIndicatorLineV.hide(); - } - }; - //缁樺埗鍥捐〃(鎵�鏈夋洸绾�) - var drawDiagramCurve = function () { - var curveWidth = 2; - - $("#MaxCurveQH").remove(); - //$("#MaxCurveQE").remove(); - $("#MaxCurveQP").remove(); - $("#MaxCurveQHText").remove(); - //$("#MaxCurveQEText").remove(); - $("#MaxCurveQPText").remove(); - - if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) { - for (var i = 0; i < m_simuSpeedCurves.length; i++) { - var id = m_simuSpeedCurves[i].id; - $("#SimuCurveQH" + id).remove(); - //$("#SimuCurveQE"+id).remove(); - $("#SimuCurveQP" + id).remove(); - - $("#SimuCurveQHText" + id).remove(); - //$("#SimuCurveQEText"+id).remove(); - $("#SimuCurveQPText" + id).remove(); - } - } - - // - m_maxSpeedCurve.color = "#003a6c"; - var curveMaxPathQH = createCurveQH("MaxCurveQH", m_maxSpeedCurve.RealQH, curveWidth, m_maxSpeedCurve.color); - var pointsQH = m_maxSpeedCurve.RealQH; - drawSpeedTextByQH("MaxCurveQHText", m_maxSpeedCurve.speed, pointsQH[pointsQH.length - 1], m_maxSpeedCurve.color); - - - //var curveMaxPathQE = createCurveQE("MaxCurveQE", m_maxSpeedCurve.RealQE, curveWidth, m_maxSpeedCurve.color); - var curveMaxPathQP = createCurveQP("MaxCurveQP", m_maxSpeedCurve.RealQP, curveWidth, m_maxSpeedCurve.color); - var pointsQP = m_maxSpeedCurve.RealQP; - drawSpeedTextByQP("MaxCurveQPText", m_maxSpeedCurve.speed, pointsQP[pointsQP.length - 1], m_maxSpeedCurve.color); - - - // - if (m_simuSpeedCurves != null && m_simuSpeedCurves.length > 0) { - m_simuSpeedCurves.forEach(element => { - drawSimuSpeedCurve(element); - }); - } - //閫氱煡澶栭儴 鏇茬嚎淇敼浜� - noticeCurveChanged(); - - - - //璁捐鐐� - //drawDesignPoint(); - - - - - //缁樺埗姘村嵃 - drawLogoWaterMark(); - - - //瑁呯疆鏇茬嚎 - //drawEquipmentCurve(); - - //鏌ヨ鎸囩ず绾� - //drawQueryIndicatVertLine(); - - // - //createMouseTipInfo(); + } } - //閫氱煡澶栭儴 - var noticeCurveChanged = function () { - if (onChangeSpeedListCb != null) { - var list_speed_color = []; - m_simuSpeedCurves.forEach(element => { - list_speed_color.push({ - id: element.id, - speed: element.speed, - color: element.color - }) - }); - onChangeSpeedListCb(list_speed_color); - } - } - //妫�鏌ュ苟鍒锋柊鍥捐〃 - var refreshDiagram = function () { + return null; + }; + //缁樺埗鏌ヨ绔栫洿鎸囧绾� + var drawQueryIndicatVertLine = function (xStartValuePixel, index) { - //console.log(m_coordinatePara) + var obj_divChart = document.getElementById(m_divChartName); - drawDiagramCurve(); - - checkCoordRange(); - - //console.log(m_coordinatePara) + 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", }; - //妫�鏌ュ潗鏍囪寖鍥存槸鍚﹁秴杩囨洸绾胯寖鍥� - var checkCoordRange = function () { - var last_simu_curve = m_simuSpeedCurves[m_simuSpeedCurves.length - 1]; - var curve_min_h = last_simu_curve.RealQH[m_maxSpeedCurve.RealQH.length - 1].Y; - var curve_min_p = last_simu_curve.RealQP[0].Y; - var isNeedRefresh = false; - for (var i = 0; i < 10; i++) { - var coord_min_h = m_coordinatePara.DispMinH - m_coordinatePara.SpaceH * i; - if (coord_min_h < 0) - break; - if (curve_min_h < coord_min_h) - continue; + // 浣嶇疆 + if (xStartValuePixel == null || xStartValuePixel < 1) + xStartValuePixel = (m_chartSize.DiagramLeft + m_chartSize.DiagramRight) / 2; - if (i > 0) { - m_coordinatePara.StartLineNoH = m_coordinatePara.StartLineNoH - i; - m_coordinatePara.DispMinH = m_coordinatePara.DispMinH - m_coordinatePara.SpaceH * i; - isNeedRefresh = true; - } - break; - } + var vertialLinePathName1 = "verticalLine1multispeed"; + removeElementById(vertialLinePathName1); - for (var i = 0; i < 10; i++) { - - var coord_min_p = m_coordinatePara.DispMinP - m_coordinatePara.SpaceP * i; - if (coord_min_p < 0) - break; - if (curve_min_p < coord_min_p) - continue; - - if (i > 0) { - m_coordinatePara.StartLineNoP = m_coordinatePara.StartLineNoP - i; - m_coordinatePara.DispMinP = m_coordinatePara.DispMinP - m_coordinatePara.SpaceP * i; - isNeedRefresh = true; - } - break; - } - if (isNeedRefresh) { - $("#" + m_divChartName).empty(); - - //鍒濆鍖栭潰鏉垮昂瀵� - initialPanelSize(); - - drawDiagramPanel(); - - drawDiagramCurve(); - } - } - //娣诲姞閫熷害 - var drawSimuSpeedCurve = function (simuCurve) { - //console.log(simuCurve) - var speed = simuCurve.speed; - if (speed < 10) - return; - - //console.log(m_maxSpeedCurve.RealQH) - var simuCurveQH = []; - var rated_speed = m_maxSpeedCurve.speed; - m_maxSpeedCurve.RealQH.forEach(pt => { - var simu_pt = {}; - simu_pt.X = pt.X * speed / rated_speed; - simu_pt.Y = pt.Y * speed * speed / (rated_speed * rated_speed); - simuCurveQH.push(simu_pt); - }); - simuCurve.RealQH = simuCurveQH; + //鍒涘缓绔栫洿绾� + var 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); - 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; + drawQueryDataInfoByPixel(xStartValuePixel, 1); + //drawQueryDataInfoByPixel(xStartValuePixel, 2); - var curveWidth = 2; - if (simuCurve.curveWidth) - curveWidth = simuCurve.curveWidth; + var isMoveVerticalLine1 = false; - var curveColor = simuCurve.color; - var curve_id = simuCurve.id; - - $("#SimuCurveQH" + curve_id).remove(); - //$("#SimuCurveQE"+i).remove(); - $("#SimuCurveQP" + curve_id).remove(); - - $("#SimuCurveQHText" + curve_id).remove(); - //$("#SimuCurveQEText"+i).remove(); - $("#SimuCurveQPText" + curve_id).remove(); - - var int_speed = Math.round(speed) ; - - var curvePathQH = createCurveQH("SimuCurveQH" + curve_id, simuCurveQH, curveWidth, curveColor); - drawSpeedTextByQH("SimuCurveQHText" + curve_id, int_speed, simuCurveQH[simuCurveQH.length - 1], curveColor); - - var curvePathQP = createCurveQP("SimuCurveQP" + curve_id, simuCurveQP, curveWidth, curveColor); - drawSpeedTextByQP("SimuCurveQPText" + curve_id, int_speed, simuCurveQP[simuCurveQP.length - 1], curveColor); - }; // - var createGridLineDiagram_Whole = function () { - if (m_coordinatePara == null) { - return; + var 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('')); } + } - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - 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 = new Array(); - - 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; + // 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('')); + // } + // } }; - //杞垚鏇茬嚎璺緞 - var transBezierCurveToPath = function (pixelPoints) { - var bezierCurveValue = transBezierCurveModel(pixelPoints); - if (bezierCurveValue == null) { - return; - } - var pathValue = new Array(); - for (var i = 0; i < bezierCurveValue.length; i++) { - var b_pt = bezierCurveValue[i]; - if (i == 0) { - pathValue.push("M ", b_pt.Point0.X, " ", b_pt.Point0.Y); - pathValue.push(" C ", b_pt.Point1.X, " ", b_pt.Point1.Y, " ", - b_pt.Point2.X, " ", b_pt.Point2.Y, " ", b_pt.Point3.X, " ", b_pt.Point3.Y); - } - else { - pathValue.push(" L ", b_pt.Point0.X, " ", b_pt.Point0.Y); - pathValue.push(" C ", b_pt.Point1.X, " ", b_pt.Point1.Y, " ", - b_pt.Point2.X, " ", b_pt.Point2.Y, " ", b_pt.Point3.X, " ", b_pt.Point3.Y); - } - if (i == bezierCurveValue.length - 1) { - pathValue.push(" L ", b_pt.Point3.X, " ", b_pt.Point3.Y); - } - } - return pathValue; - }; - - //杩斿洖鏍囧噯鍗曚綅涓嬬殑鍊� - var getActualValueQ = function (pixelValue) { - var actualMinValue = m_coordinatePara.DispMinQ; - var actualMaxValue = m_coordinatePara.DispMaxQ; - var pixelMinValue = m_chartSize.DiagramLeft; - var pixelMaxValue = m_chartSize.DiagramRight; - return (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue; - }; - var getActualValueH = function (pixelValue) { - var actualMinValue = m_coordinatePara.DispMinH; - var actualMaxValue = m_coordinatePara.DispMaxH; - var pixelMinValue = m_chartSize.PanelH.Bottom; - var pixelMaxValue = m_chartSize.PanelH.Up; - - var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue; - //console.log("getActualValueH", actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue); - - return actualValue; - }; - var getActualValueE = function (pixelValue) { - var actualMinValue = m_coordinatePara.DispMinE; - var actualMaxValue = m_coordinatePara.DispMaxE; - var pixelMinValue = m_chartSize.PanelE.Bottom; - var pixelMaxValue = m_chartSize.PanelE.Up; - - var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue; - //console.log("getActualValueE",actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue); - - return actualValue; - }; - var getActualValueP = function (pixelValue) { - var actualMinValue = m_coordinatePara.DispMinP; - var actualMaxValue = m_coordinatePara.DispMaxP; - var pixelMinValue = m_chartSize.PanelP.Bottom; - var pixelMaxValue = m_chartSize.PanelP.Up; - return (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue; - }; - var getActualValueNPSH = function (pixelValue) { - var actualMinValue = m_coordinatePara.DispMinNPSH; - var actualMaxValue = m_coordinatePara.DispMaxNPSH; - var pixelMinValue = m_chartSize.PanelNPSH.Bottom; - var pixelMaxValue = m_chartSize.PanelNPSH.Up; - var actualValue = (pixelValue - pixelMinValue) / (pixelMaxValue - pixelMinValue) * (actualMaxValue - actualMinValue) + actualMinValue; - // console.log("getActualValueNPSH",actualValue, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue); - return actualValue; - }; - - // actualValue 鏄爣鍑嗗崟浣嶄笅鐨勫�� - var getPixelValueQ = function (actualValue) { - var actualMinValue = m_coordinatePara.DispMinQ; - var actualMaxValue = m_coordinatePara.DispMaxQ; - var pixelMinValue = m_chartSize.DiagramLeft; - var pixelMaxValue = m_chartSize.DiagramRight; - - return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue; - }; - var getPixelValueH = function (actualValue) { - - var actualMinValue = m_coordinatePara.DispMinH; - var actualMaxValue = m_coordinatePara.DispMaxH; - var pixelMinValue = m_chartSize.PanelH.Bottom; - var pixelMaxValue = m_chartSize.PanelH.Up; - - if (actualMaxValue == actualMinValue) - return actualMinValue; - - var v = (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue; - //console.log("getPixelValueH",actualValue,v, actualMinValue,actualMaxValue,pixelMinValue,pixelMaxValue); - return v - }; - var getPixelValueE = function (actualValue) { - var actualMinValue = m_coordinatePara.DispMinE; - var actualMaxValue = m_coordinatePara.DispMaxE; - var pixelMinValue = m_chartSize.PanelE.Bottom; - var pixelMaxValue = m_chartSize.PanelE.Up; - if (actualMaxValue == actualMinValue) - return actualMinValue; - - return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue; - }; - var getPixelValueP = function (actualValue) { - var actualMinValue = m_coordinatePara.DispMinP; - var actualMaxValue = m_coordinatePara.DispMaxP; - var pixelMinValue = m_chartSize.PanelP.Bottom; - var pixelMaxValue = m_chartSize.PanelP.Up; - if (actualMaxValue == actualMinValue) - return actualMinValue; - - return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue; - }; - var getPixelValueNPSH = function (actualValue) { - var actualMinValue = m_coordinatePara.DispMinNPSH; - var actualMaxValue = m_coordinatePara.DispMaxNPSH; - var pixelMinValue = m_chartSize.PanelNPSH.Bottom; - var pixelMaxValue = m_chartSize.PanelNPSH.Up; - if (actualMaxValue == actualMinValue) - return actualMinValue; - - return (actualValue - actualMinValue) / (actualMaxValue - actualMinValue) * (pixelMaxValue - pixelMinValue) + pixelMinValue; + 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; - //璁剧疆璁捐鐐瑰叕宸� - 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) { - $("#" + m_divChartName).empty(); - setObjectColor(isMonorColor); - if (!initialSvg()) - return; + 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); - drawDiagramPanel(); + query_pt2.speed = simu_curve.speed; + query_pt2.hz = simu_curve.hz; + query_pt_list.push(query_pt2); - refreshDiagram(); - }; - //璁剧疆鏄惁鏄崟鑹叉樉绀� - this.setWrkCurveInfo = function (curve) { - if (curve == null) - return; - //console.log(curve, 2992); - // drawDiagramPanel(); + } + } - if (m_maxSpeedCurve == null) - return; - m_maxSpeedCurve.RealQH = curve.RealQH; - m_maxSpeedCurve.RealQE = curve.RealQE; - m_maxSpeedCurve.RealQP = curve.RealQP; - m_maxSpeedCurve.RealNPSH = curve.RealNPSH; - - - if (curve.RealNPSH == null) { - m_isHaveNpsh = false; - } - else { - m_isHaveNpsh = true; - } - // - refreshDiagram(); - }; - //娣诲姞杞�� - this.AddSpeedCurve = function (speed) { - speed = parseInt(speed); - if (speed < 10) - return null; - if (m_simuSpeedCurves == null) - m_simuSpeedCurves = []; - var isFind = false; - m_simuSpeedCurves.forEach(element => { - //console.log(element,speed) - if (speed == element.speed) - isFind = true; - }); - if (isFind) - return null; - - //鑾峰彇娌℃湁鐢ㄨ繃鐨勯鑹� - var curveColor = "#000000"; - for (var c = 0; c < m_colorArray.length; c++) { - var isHaveColor = false; - for (var i = 0; i < m_simuSpeedCurves.length; i++) { - if (m_colorArray[c] == m_simuSpeedCurves[i].color) { - isHaveColor = true; - break; - } - } - if (!isHaveColor) { - curveColor = m_colorArray[c]; - break; - } - } - - m_curveMaxId++; - var speedItem = { - id: m_curveMaxId, - speed: speed, - color: curveColor, - curveWidth: 2 - }; - m_simuSpeedCurves.push(speedItem); - - drawSimuSpeedCurve(speedItem); - - //閫氱煡澶栭儴 鏇茬嚎淇敼浜� - noticeCurveChanged(); - - return speedItem.color; - }; - //淇敼杞�� - this.editSpeedById = function (id, speed) { - var speedItem = null; - for (var i = 0; i < m_simuSpeedCurves.length; i++) { - if (id == m_simuSpeedCurves[i].id) { - speedItem = m_simuSpeedCurves[i]; - break; - } - } - if (speedItem == null) - return; - - var origin_speed = speedItem.speed; - if (Math.abs(origin_speed - speed) < 2) - return; - - speedItem.speed = speed; - - - - drawSimuSpeedCurve(speedItem) - - //閫氱煡澶栭儴 鏇茬嚎淇敼浜� - noticeCurveChanged(); - }; - //淇敼棰滆壊 - this.editColorById = function (id, color) { - - var speedItem = null; - for (var i = 0; i < m_simuSpeedCurves.length; i++) { - if (id == m_simuSpeedCurves[i].id) { - speedItem = m_simuSpeedCurves[i]; - break; - } - } - if (speedItem == null) - return; - - speedItem.color = color; - $("#SimuCurveQH" + speedItem.id).css("stroke", color); - //$("#SimuCurveQE"+i).remove(); - $("#SimuCurveQP" + speedItem.id).css("stroke", color); - - $("#SimuCurveQHText" + speedItem.id).css("fill", color); - //$("#SimuCurveQEText"+i).remove(); - $("#SimuCurveQPText" + speedItem.id).css("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) - $("#SimuCurveQH" + id).remove(); - //$("#SimuCurveQE"+i).remove(); - $("#SimuCurveQP" + id).remove(); - - $("#SimuCurveQHText" + id).remove(); - //$("#SimuCurveQEText"+i).remove(); - $("#SimuCurveQPText" + id).remove(); - }; - //璁剧疆瀹瑰櫒 - this.setContainerDiv = function (divChartName, divWidth, divHeight) { - m_divChartName = divChartName; - - if (m_chartSize == null) { - m_chartSize = {}; - } - - if (divWidth != null) { - m_chartSize.TotalWidth = divWidth; - } - else { - m_chartSize.TotalWidth = document.getElementById(divChartName).clientWidth; - } - - if (divHeight != null) { - m_chartSize.TotalHeight = divHeight; - } - else { - m_chartSize.TotalHeight = document.getElementById(divChartName).clientHeight; - } - //console.log(m_divChartName, m_chartSize.TotalWidth,m_chartSize.TotalHeight) - }; - //璁剧疆璇█ - this.setLocalizationType = function (localizationType) { - m_localizationType = localizationType; - //console.log("localizationType:"+localizationType) - }; - //璁剧疆宸ュ叿鎻愮ず鏍� - this.setToolTipName = function (toolTipName) { - m_toolTipContent = $("#" + toolTipName); - }; //鑾峰彇鏌ヨ鏇茬嚎鏌ヨ寰楀埌鐨勬暟鎹� 缁欏弬鏁版煡璇娇鐢� - this.setChangeQueryDataCb = function (cb) { - onChangeQueryDataCb = cb; - }; - //璁剧疆淇敼浜嗗垪琛�,閫氱煡澶栭儴鐨勫洖璋� - this.setChangeSpeedListCb = function (cb) { - onChangeSpeedListCb = cb; - }; + 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); + } + } + // - this.setQueryIndicatVertLineVisible = function (isVisible) { - setQueryIndicatVertLineVisible(isVisible); - }; - this.getQueryIndicatVertLineVisible = function () { - return m_dispVerticalLine; - }; - - //鍒濆鍖栧浘琛�(鍏ュ彛) - this.initialChart = function (ChartFullInfo, displayStyle) { - if (!m_divChartName) - return; - //console.log("initialChart ChartFullInfo", ChartFullInfo) - //娓呯┖ - $("#" + m_divChartName).empty(); - - if (ChartFullInfo.ChartObjectDict == null) - return; - if (ChartFullInfo.ChartObjectDict.Coordinate == null) - return; - - m_designPointTolerance = PointToleranceConfig.GetDefaultTolerancePara(); + 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); - // - m_pumpInfo = ChartFullInfo.BaseInfo; - - m_maxSpeedCurve = {}; - m_maxSpeedCurve.speed = m_pumpInfo.Ratedn; - //console.log("m_pumpInfo", m_pumpInfo) - - m_chartPointPara = ChartFullInfo.ChartPointPara; - m_chartSetting = ChartFullInfo.SettingInfo; - m_chartObject = ChartFullInfo.ChartObjectDict; - - //鍏嬮殕涓�涓�,鍧愭爣鍜屾�ц兘鏇茬嚎鐨勪笉涓�瀹氫竴鑷�,浼氫慨鏀� - var objString_Coordinate = JSON.stringify(ChartFullInfo.ChartObjectDict.Coordinate); - m_coordinatePara = JSON.parse(objString_Coordinate); + 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); - this.SetUnit(//璁剧疆鍗曚綅 - m_chartSetting.UnitQ, - m_chartSetting.UnitH, - m_chartSetting.UnitP, - m_chartSetting.UnitNPSH ); - //鍒濆鍖栭�熷害鍒楄〃 - var simuSpeedList = []; - if (ChartFullInfo.MultiSpeedValues != null) { - var sss = ChartFullInfo.MultiSpeedValues.split(","); - sss.forEach(element => { - simuSpeedList.push(Math.round(parseFloat(element))); - }); - } - else { - simuSpeedList.push(m_maxSpeedCurve.speed * 0.9); - simuSpeedList.push(m_maxSpeedCurve.speed * 0.8); - simuSpeedList.push(m_maxSpeedCurve.speed * 0.7); - simuSpeedList.push(m_maxSpeedCurve.speed * 0.6); - simuSpeedList.push(m_maxSpeedCurve.speed * 0.5); - } + 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); + } - m_simuSpeedCurves = []; - simuSpeedList.forEach((speed, indx) => { - //console.log(indx, speed) - m_curveMaxId++; - m_simuSpeedCurves.push({ - speed: speed, - id: m_curveMaxId, - color: m_colorArray[indx], - curveWidth: 2 - }); + + + // + 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; - //鍒濆鍖栨樉绀鸿缃� - initialDispStyle(displayStyle, m_chartSetting); + 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; - m_chartDiagramPanelStyle = ConstParas.ChartDiagramPanelStyle.Two; - - //鍒濆鍖栭潰鏉垮昂瀵� - initialPanelSize(); - - drawDiagramPanel(); - - - - return this; - }; - - //鏍规嵁娴侀噺璁$畻鍔熺巼 - this.calcPowerByFlow = function (flow, unit) { - if (flow == null || m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQP == null) - return null; - var flow_stdUnit = UnitHelper.ConvertQ_toM3H(unit, flow); - if (flow_stdUnit < 0.1) - return null; - //console.log("flow_stdUnit", flow_stdUnit, unit, flow) - var xPixel = getPixelValueQ(flow_stdUnit); - var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQP, xPixel); - if (power_pixel_pt != null) { - var power = getActualValueP(power_pixel_pt.Y); - // console.log("flow_power", flow_stdUnit, power.toFixed(2) ) - return power.toFixed(2); + 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; } - else { - return null; - } + } + 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, }; - //鏍规嵁娴侀噺璁$畻鏁堢巼 - this.calcEtaByFlow = function (flow, unit) { - if (flow == null || m_maxSpeedCurve == null || m_maxSpeedCurve.PixelQE == null) - return null; - var flow_stdUnit = UnitHelper.ConvertQ_toM3H(unit, flow); - if (flow_stdUnit < 0.1) - return null; - //console.log("flow_stdUnit", flow_stdUnit, unit, flow) - var xPixel = getPixelValueQ(flow_stdUnit); - var power_pixel_pt = getBezierPointY(m_maxSpeedCurve.PixelQE, xPixel); - if (power_pixel_pt != null) { - var power = getActualValueE(power_pixel_pt.Y); - //console.log("flow_power", power.toFixed(2) ) - return power.toFixed(2); - } - else { - return null; - } + + //浜х敓缃戞牸绾跨珫鐩存柟鍚� + 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, }; - //璁剧疆姘村嵃鍥剧墖璺緞 - this.setWatermarkImageUrl = function(img_path){ + //浜х敓缃戞牸绾跨珫鐩存柟鍚� + 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 }; - //閲嶇粯鍥捐〃澶у皬 - this.Resize = function (widht, height) { - if (widht && widht > 0) - m_chartSize.TotalWidth = widht; - if (height && height > 0) - m_chartSize.TotalHeight = height; + m_simuSpeedCurves.push(speedItem); - $("#" + m_divChartName).empty(); + sortSimuSpeedCurves(); - //鍒濆鍖栭潰鏉� - initialPanelSize(); + 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) {//涓婇潰鐨凱ixel Y 瓒婂皬 , 涓嬮潰鐨� Pixel 灏� + return this.AddSpeedCurve(speed + 1, { Q: flow_stdUnit, H: r_h }); + } + } - drawDiagramPanel(); + 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); + }; - refreshDiagram(); - }; + //淇敼杞�� + 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; + } + }; + //杞寲鎴恗3h娴侀噺 + 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 \ No newline at end of file +export default MultiSpeedChartDiagram; -- Gitblit v1.9.3