hqchart 1.1.12898 → 1.1.12905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umychart.vue.js
CHANGED
|
@@ -2308,13 +2308,19 @@ this.Canvas.beginPath();this.Canvas.moveTo(left,yFixed);this.Canvas.lineTo(right
|
|
|
2308
2308
|
{}else if(item.LineType==8||item.LineType==9)//集合竞价不画线
|
|
2309
2309
|
{}else if(item.LineType>0){if(g_JSChartResource.FrameYLineDash){this.Canvas.save();this.Canvas.setLineDash(g_JSChartResource.FrameYLineDash);//虚线
|
|
2310
2310
|
this.Canvas.beginPath();this.Canvas.moveTo(left,yFixed);this.Canvas.lineTo(right,yFixed);this.Canvas.stroke();this.Canvas.setLineDash([]);this.Canvas.restore();}else{this.Canvas.beginPath();this.Canvas.moveTo(left,yFixed);this.Canvas.lineTo(right,yFixed);this.Canvas.stroke();}}if(bChangeLineWidth){this.Canvas.lineWidth=pixelRatio;}}var yText=y;if(y>=bottom-2){this.Canvas.textBaseline='bottom';textBaseline=2;}else if(y<=top+2){this.Canvas.textBaseline='top';yText+=this.YTextTopOffset;textBaseline=0;}else{this.Canvas.textBaseline="middle";textBaseline=1;}//左边 坐标信息 间距小于10 不画坐标
|
|
2311
|
-
this.Canvas.strokeStyle=item.TextColor;this.Canvas.fillStyle=item.TextColor;if(item.Message[0]!=null&&isDrawLeft){if(item.Font!=null)this.Canvas.font=item.Font;var xText=left;if(leftExtendLine&&leftExtendLine.Width>1){var lineLength=leftExtendLine.Width;if(leftExtendLine.Color)this.Canvas.strokeStyle=leftExtendLine.Color;else this.Canvas.strokeStyle=item.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(xText,yFixed);this.Canvas.lineTo(xText-lineLength,yFixed);this.Canvas.stroke();xText-=lineLength;}rtLeft=this.GetTextTopBottom(textBaseline,yText);if(!rtPreLeft||rtLeft&&!this.IsTextTopBottomOverlap(rtLeft,rtPreLeft)){if(leftExtendText&&leftExtendText.Align===1){this.Canvas.textAlign="left";this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);}else{this.Canvas.textAlign="right";this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);rtPreLeft=rtLeft;}}}//右边 坐标信息 间距小于10 不画坐标
|
|
2311
|
+
this.Canvas.strokeStyle=item.TextColor;this.Canvas.fillStyle=item.TextColor;if(item.Message[0]!=null&&isDrawLeft){if(Array.isArray(item.Message[0])){if(this.MultiTextFormat==3){var obj={Data:item.Message[0],X:left,Y:yText,TextBaseLine:textBaseline,IsLeft:true,Item:item,TextPadding:this.YTextPadding[0]};this.DrawMultiLineText(obj);}}else{if(item.Font!=null)this.Canvas.font=item.Font;var xText=left;if(leftExtendLine&&leftExtendLine.Width>1){var lineLength=leftExtendLine.Width;if(leftExtendLine.Color)this.Canvas.strokeStyle=leftExtendLine.Color;else this.Canvas.strokeStyle=item.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(xText,yFixed);this.Canvas.lineTo(xText-lineLength,yFixed);this.Canvas.stroke();xText-=lineLength;}rtLeft=this.GetTextTopBottom(textBaseline,yText);if(!rtPreLeft||rtLeft&&!this.IsTextTopBottomOverlap(rtLeft,rtPreLeft)){if(leftExtendText&&leftExtendText.Align===1){this.Canvas.textAlign="left";this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);}else{this.Canvas.textAlign="right";this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);rtPreLeft=rtLeft;}}}}//右边 坐标信息 间距小于10 不画坐标
|
|
2312
2312
|
if(item.Message[1]!=null&&isDrawRight){if(item.Font!=null)this.Canvas.font=item.Font;var xText=right;if(item.LineType==3){var lineLength=this.ShortYLineLength*GetDevicePixelRatio();this.Canvas.beginPath();this.Canvas.moveTo(xText,yFixed);this.Canvas.lineTo(xText+lineLength,yFixed);this.Canvas.stroke();xText+=lineLength;}//右侧延长线
|
|
2313
2313
|
if(rightExtendLine&&rightExtendLine.Width>1){var lineLength=rightExtendLine.Width;if(rightExtendLine.Color)this.Canvas.strokeStyle=rightExtendLine.Color;else this.Canvas.strokeStyle=item.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(xText,yFixed);this.Canvas.lineTo(xText+lineLength,yFixed);this.Canvas.stroke();xText+=lineLength+2;}this.Canvas.textAlign="left";if(Array.isArray(item.Message[1])){if(this.MultiTextFormat==1)//显示1行 格式:价格/百分比
|
|
2314
2314
|
{if(item.ExtendData){if(item.ExtendData.Font)this.Canvas.font=item.ExtendData.Font;}var textData={Text:[{Text:item.Message[1][0],Width:this.Canvas.measureText(item.Message[1][0]).width},{Text:item.Message[1][1],Width:this.Canvas.measureText(item.Message[1][1]).width}],X:xText+2,Y:yText,TextBaseline:this.Canvas.textBaseline,Item:item};aryMultiText.push(textData);}else if(this.MultiTextFormat==2)//显示2行
|
|
2315
|
-
{this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);var lineHeight=this.Canvas.measureText('M').width;if(itemHeight>lineHeight*2)this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);}else//显示第1行
|
|
2315
|
+
{this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);var lineHeight=this.Canvas.measureText('M').width;if(itemHeight>lineHeight*2)this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);}else if(this.MultiTextFormat==3){var obj={Data:item.Message[1],X:xText,Y:yText,TextBaseLine:textBaseline,IsLeft:false,Item:item,TextPadding:this.YTextPadding[1]};this.DrawMultiLineText(obj);}else//显示第1行
|
|
2316
2316
|
{this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);}}else{//计算显示的区域
|
|
2317
|
-
rtRight=this.GetTextTopBottom(textBaseline,yText);if(!rtPreRight||rtRight&&!this.IsTextTopBottomOverlap(rtRight,rtPreRight)){if(item.TextColor2)this.Canvas.fillStyle=item.TextColor2;if(rightExtendText&&rightExtendText.Align===2&&this.YRightTextInfo){this.Canvas.textAlign="right";var xRight=this.YRightTextInfo.MainTextWidth+right-this.YTextPadding[1];this.Canvas.fillText(item.Message[1],xRight,yText);}else{this.Canvas.fillText(item.Message[1],xText+this.YTextPadding[1],yText);}rtPreRight=rtRight;}}}yPrev=y;}if(IFrameSplitOperator.IsNonEmptyArray(aryMultiText)&&this.MultiTextFormat==1)this.DrawHorizontalMuText(aryMultiText);if(isDrawRight&&this.IsDrawRightBorder&&this.YRightTextInfo){var xRight=this.YRightTextInfo.MainTextWidth+right;xLine=ToFixedPoint(xRight);this.Canvas.strokeStyle=this.PenBorder;this.Canvas.beginPath();this.Canvas.moveTo(xLine,top);this.Canvas.lineTo(xLine,bottom);this.Canvas.stroke();if(IFrameSplitOperator.IsNonEmptyArray(this.YRightTextInfo.AryOverlayWidth)){this.Canvas.beginPath();for(var i=0;i<this.YRightTextInfo.AryOverlayWidth.length;++i){var width=this.YRightTextInfo.AryOverlayWidth[i];xRight+=width;xLine=ToFixedPoint(xRight);this.Canvas.moveTo(xLine,top);this.Canvas.lineTo(xLine,bottom);}this.Canvas.stroke();}}}
|
|
2317
|
+
rtRight=this.GetTextTopBottom(textBaseline,yText);if(!rtPreRight||rtRight&&!this.IsTextTopBottomOverlap(rtRight,rtPreRight)){if(item.TextColor2)this.Canvas.fillStyle=item.TextColor2;if(rightExtendText&&rightExtendText.Align===2&&this.YRightTextInfo){this.Canvas.textAlign="right";var xRight=this.YRightTextInfo.MainTextWidth+right-this.YTextPadding[1];this.Canvas.fillText(item.Message[1],xRight,yText);}else{this.Canvas.fillText(item.Message[1],xText+this.YTextPadding[1],yText);}rtPreRight=rtRight;}}}yPrev=y;}if(IFrameSplitOperator.IsNonEmptyArray(aryMultiText)&&this.MultiTextFormat==1)this.DrawHorizontalMuText(aryMultiText);if(isDrawRight&&this.IsDrawRightBorder&&this.YRightTextInfo){var xRight=this.YRightTextInfo.MainTextWidth+right;xLine=ToFixedPoint(xRight);this.Canvas.strokeStyle=this.PenBorder;this.Canvas.beginPath();this.Canvas.moveTo(xLine,top);this.Canvas.lineTo(xLine,bottom);this.Canvas.stroke();if(IFrameSplitOperator.IsNonEmptyArray(this.YRightTextInfo.AryOverlayWidth)){this.Canvas.beginPath();for(var i=0;i<this.YRightTextInfo.AryOverlayWidth.length;++i){var width=this.YRightTextInfo.AryOverlayWidth[i];xRight+=width;xLine=ToFixedPoint(xRight);this.Canvas.moveTo(xLine,top);this.Canvas.lineTo(xLine,bottom);}this.Canvas.stroke();}}};//多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
|
|
2318
|
+
this.DrawMultiLineText=function(obj){var lineSpacing=2;var lineHeight=this.Canvas.measureText('擎').width;var lineCount=obj.Data.length;var textHeight=lineHeight*lineCount+lineSpacing*(lineCount-1);var yText=obj.Y;if(obj.Item.Font!=null)this.Canvas.font=obj.Item.Font;if(obj.IsLeft){this.Canvas.textAlign="right";var xText=obj.X-obj.TextPadding;}else{this.Canvas.textAlign="left";var xText=obj.X+obj.TextPadding;}var textBaseline=this.Canvas.textBaseline;//备份下原来的对齐方式
|
|
2319
|
+
this.Canvas.textBaseline='top';if(obj.TextBaseLine==1)//middle
|
|
2320
|
+
{yText-=textHeight/2;}else if(obj.TextBaseLine==0)//top
|
|
2321
|
+
{}else if(obj.TextBaseLine==2)//bottom
|
|
2322
|
+
{yText-=textHeight;}for(var i=0;i<obj.Data.length;++i){var item=obj.Data[i];var text=item.Text;var backupTextColor=null;if(item.Color){backupTextColor=this.Canvas.fillStyle;this.Canvas.fillStyle=item.Color;}this.Canvas.fillText(text,xText,yText);yText+=lineHeight+lineSpacing;if(backupTextColor)this.Canvas.fillStyle=backupTextColor;}this.Canvas.textBaseline=textBaseline;//还原对齐方式
|
|
2323
|
+
};//上下区域是否重叠
|
|
2318
2324
|
this.IsTextTopBottomOverlap=function(rt,rt2){if(rt2.Top>=rt.Top&&rt2.Top<=rt.Bottom)return true;if(rt2.Bottom>=rt.Top&&rt2.Bottom<=rt.Bottom)return true;return false;};this.GetTextTopBottom=function(textBaseline,yText){var rtRight=null;var textHeight=this.Canvas.measureText('擎').width;if(textBaseline==0){rtRight={Top:yText,Bottom:yText+textHeight};}else if(textBaseline==1){rtRight={Top:yText-textHeight/2};rtRight.Bottom=rtRight.Top+textHeight;}else if(textBaseline==2){rtRight={Bottom:yText};rtRight.Top=rtRight.Bottom-textHeight;}return rtRight;};this.DrawHorizontalMuText=function(aryText){var maxWidth=[null,null];for(var i=0;i<aryText.length;++i){var item=aryText[i];var width=item.Text[0].Width;if(!IFrameSplitOperator.IsNumber(maxWidth[0]))maxWidth[0]=width;else if(maxWidth[0]<width)maxWidth[0]=width;width=item.Text[1].Width;if(!IFrameSplitOperator.IsNumber(maxWidth[1]))maxWidth[1]=width;else if(maxWidth[1]<width)maxWidth[1]=width;}for(var i=0;i<aryText.length;++i){var item=aryText[i];var message=item.Item;this.Canvas.textBaseline=message.TextBaseline;if(message.ExtendData&&message.ExtendData.Font)this.Canvas.font=message.ExtendData.Font;else if(message.Font)this.Canvas.font=message.Font;if(message.ExtendData&&message.ExtendData.PriceColor)this.Canvas.fillStyle=message.ExtendData.PriceColor;else this.Canvas.fillStyle=message.TextColor;this.Canvas.textAlign="right";var x=item.X+maxWidth[1];this.Canvas.fillText(item.Text[1].Text,x,item.Y);if(message.ExtendData&&message.ExtendData.SplitColor)this.Canvas.fillStyle=message.ExtendData.SplitColor;else this.Canvas.fillStyle=message.TextColor;this.Canvas.textAlign="left";var splitWidth=this.Canvas.measureText('/').width;this.Canvas.fillText('/',x,item.Y);if(message.ExtendData&&message.ExtendData.PercentageColor)this.Canvas.fillStyle=message.ExtendData.PercentageColor;else this.Canvas.fillStyle=message.TextColor;this.Canvas.textAlign="right";var x=item.X+maxWidth[1]+maxWidth[0]+splitWidth;this.Canvas.fillText(item.Text[0].Text,x,item.Y);var textWidth=maxWidth[1]+maxWidth[0]+splitWidth*4;if(this.RightTextMaxWidth<textWidth)this.RightTextMaxWidth=textWidth;}};//画Y轴Message[2,3]两个内部刻度
|
|
2319
2325
|
this.DrawInsideClientHorizontal=function(){var border=this.GetBorder();if(border.DayBorder&&IFrameSplitOperator.IsNonEmptyArray(border.DayBorder)){var item=border.DayBorder[0];var left=item.LeftEx;var item=border.DayBorder[border.DayBorder.length-1];var right=item.RightEx;var bottom=border.Bottom;var top=border.TopTitle;}else{var left=border.LeftEx;var right=border.RightEx;var bottom=border.Bottom;var top=border.TopTitle;}var pixelTatio=GetDevicePixelRatio();var yPrev=null;//上一个坐标y的值
|
|
2320
2326
|
var yInsideText=null;for(var i=this.HorizontalInfo.length-1;i>=0;--i)//从上往下画分割线
|
|
@@ -2350,13 +2356,13 @@ var yText=y;for(var i=0;i<textInfo.Text.length;++i){var itemText=textInfo.Text[i
|
|
|
2350
2356
|
if(itemText.TextColor)this.Canvas.fillStyle=itemText.TextColor;else this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(itemText.Text,textLeft+1*pixelTatio,yText);if(i==0)this.DrawLine(left,textLeft,yText,item.LineColor,item.LineType,item);yText+=textHeight+1*pixelTatio;}}}if(item.Type==3||item.Type==4){if(item.Title){var width=this.Canvas.measureText(item.Title).width+2*pixelTatio;if(this.IsHScreen){var bgTop=bottom-itemText.Width-width;var textLeft=y-textHeight/2-1*pixelTatio;this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(textLeft,bgTop,textHeight,width);this.DrawHScreenText({X:y,Y:bgTop},{Text:item.Title,Color:item.TextColor,XOffset:1*pixelTatio,YOffset:2*pixelTatio});}else{var bgTop=y-textHeight/2-1*pixelTatio;var textLeft=right-textWidth-width-1*pixelTatio;this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(textLeft,bgTop,width,textHeight);this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(item.Title,textLeft+1*pixelTatio,y);}}}}else{if(item.Font!=null)this.Canvas.font=item.Font;this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";var textInfo=this.GetCustomItemTextInfo(item,false,pixelTatio);var textWidth=textInfo.MaxWidth;var fontHeight=this.GetFontHeight();textHeight=fontHeight>defaultTextHeight?fontHeight:defaultTextHeight;var preTextRect=null;if(mapTextRect&&mapTextRect.has(3))preTextRect=mapTextRect.get(3);var yText=y;var rtText={};for(var i=0;i<textInfo.Text.length;++i){var itemText=textInfo.Text[i];if(this.IsHScreen){var bgTop=bottom;//bgTop+=(textWidth-itemText.Width);
|
|
2351
2357
|
var textLeft=yText-textHeight/2-1*pixelTatio;this.Canvas.fillStyle=item.LineColor;this.Canvas.fillRect(textLeft,bgTop,textHeight,itemText.Width);this.DrawHScreenText({X:yText,Y:bgTop},{Text:itemText.Text,Color:item.TextColor,XOffset:1*pixelTatio,YOffset:2*pixelTatio});if(i==0)this.DrawLine(top,bgTop,yText,item.LineColor,item.LineType,item);yText-=textHeight+1*pixelTatio;}else{if(itemText.Type===1){if(this.GetEventCallback){var bgTop=yText-textHeight/2-1*pixelTatio;var sendData={Top:bgTop,Left:right,Right:this.ChartBorder.GetChartWidth(),Height:null,IsShow:true,BGColor:item.LineColor,TextColor:item.TextColor,PixelTatio:pixelTatio,Position:"Right",IsInside:false};if(this.SendDrawCountDownEvent(sendData)){if(IFrameSplitOperator.IsPlusNumber(sendData.Height))yText+=textHeight+1*pixelTatio;}}}else{var bgTop=yText-textHeight/2-1*pixelTatio;if(i==0){var textLeft=right;rtText.Left=textLeft;if(preTextRect&&bgTop<preTextRect.Rect.Bottom){yText=preTextRect.Rect.Bottom;bgTop=yText-textHeight/2-1*pixelTatio;}}else{var textLeft=right+textWidth-itemText.Width;}if(emptyBGColor){this.Canvas.fillStyle=emptyBGColor;this.Canvas.fillRect(textLeft,bgTop,itemText.Width+1,textHeight);this.Canvas.strokeStyle=item.LineColor;this.Canvas.strokeRect(ToFixedPoint(textLeft),ToFixedPoint(bgTop),ToFixedRect(itemText.Width+1),ToFixedRect(textHeight));this.Canvas.fillStyle=item.LineColor;this.Canvas.fillText(itemText.Text,textLeft+2*pixelTatio,yText);}else{this.Canvas.fillStyle=item.LineColor;this.Canvas.fillRect(textLeft,bgTop,itemText.Width,textHeight);if(itemText.TextColor)this.Canvas.fillStyle=itemText.TextColor;else this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(itemText.Text,textLeft+1*pixelTatio,yText);}if(i==0)this.DrawLine(left,right,y,item.LineColor,item.LineType,item);yText+=textHeight+1*pixelTatio;rtText.Bottom=yText;}}}if(mapTextRect&&IFrameSplitOperator.IsNumber(rtText.Left)&&IFrameSplitOperator.IsNumber(rtText.Bottom)){mapTextRect.set(3,{Rect:rtText,Item:item});}if(item.Type==3||item.Type==4){if(item.Title){var bgColor=item.LineColor;var rgb=this.RGBToStruct(item.LineColor);if(rgb)bgColor='rgba('+rgb.R+', '+rgb.G+', '+rgb.B+', '+g_JSChartResource.FrameLatestPrice.BGAlpha+')';//内部刻度 背景增加透明度
|
|
2352
2358
|
var width=this.Canvas.measureText(item.Title).width+2*pixelTatio;if(this.IsHScreen){var bgTop=bottom-width;var textLeft=y-textHeight/2-1*pixelTatio;this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(textLeft,bgTop,textHeight,width);this.DrawHScreenText({X:y,Y:bgTop},{Text:item.Title,Color:item.TextColor,XOffset:1*pixelTatio,YOffset:2*pixelTatio});}else{var bgTop=y-textHeight/2-1*pixelTatio;var textLeft=right-width-1*pixelTatio;this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(textLeft,bgTop,width,textHeight);this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(item.Title,textLeft+1*pixelTatio,y);}}}}}};this.SendDrawCountDownEvent=function(sendData){if(!this.GetEventCallback)return false;var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_DRAW_COUNTDOWN);if(!event||!event.Callback)return false;event.Callback(event,sendData,this);return true;};this.DrawDotLine=function(left,right,y,color,option){var pixelTatio=GetDevicePixelRatio();this.Canvas.save();this.Canvas.strokeStyle=color;if(option&&IFrameSplitOperator.IsPlusNumber(option.LineWidth))this.Canvas.lineWidth=option.LineWidth*pixelTatio;if(option.LineDash)this.Canvas.setLineDash(option.LineDash);else this.Canvas.setLineDash([5*pixelTatio,5*pixelTatio]);//虚线
|
|
2353
|
-
this.Canvas.beginPath();if(this.IsHScreen){this.Canvas.moveTo(ToFixedPoint(y),left);this.Canvas.lineTo(ToFixedPoint(y),right);}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}this.Canvas.stroke();this.Canvas.restore();};this.DrawLine=function(left,right,y,color,lineType,option){if(lineType==-1)return;if(lineType==0){var pixelRatio=GetDevicePixelRatio();this.Canvas.strokeStyle=color;var bChangeLineWidth=false;if(option&&IFrameSplitOperator.IsPlusNumber(option.LineWidth)){this.Canvas.lineWidth=option.LineWidth*pixelRatio;bChangeLineWidth=true;}this.Canvas.beginPath();if(this.IsHScreen){this.Canvas.moveTo(ToFixedPoint(y),left);this.Canvas.lineTo(ToFixedPoint(y),right);}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}this.Canvas.stroke();if(bChangeLineWidth){this.Canvas.lineWidth=pixelRatio;}}else{this.DrawDotLine(left,right,y,color,option);}};this.DrawHScreenText=function(center,data){this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=data.Color;this.Canvas.save();this.Canvas.translate(center.X,center.Y);this.Canvas.rotate(90*Math.PI/180);this.Canvas.fillText(data.Text,data.XOffset,data.YOffset);this.Canvas.restore();};this.RGBToStruct=function(rgb){if(/^(rgb|RGB)/.test(rgb)){var aColor=rgb.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");var result={};if(aColor.length!=3)return null;result.R=Number(aColor[0]);result.G=Number(aColor[1]);result.B=Number(aColor[2]);return result;}return null;};this.GetScaleTextWidth=function(){var border=this.ChartBorder.GetBorder();var pixelTatio=GetDevicePixelRatio();//获取设备的分辨率
|
|
2359
|
+
this.Canvas.beginPath();if(this.IsHScreen){this.Canvas.moveTo(ToFixedPoint(y),left);this.Canvas.lineTo(ToFixedPoint(y),right);}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}this.Canvas.stroke();this.Canvas.restore();};this.DrawLine=function(left,right,y,color,lineType,option){if(lineType==-1)return;if(lineType==0){var pixelRatio=GetDevicePixelRatio();this.Canvas.strokeStyle=color;var bChangeLineWidth=false;if(option&&IFrameSplitOperator.IsPlusNumber(option.LineWidth)){this.Canvas.lineWidth=option.LineWidth*pixelRatio;bChangeLineWidth=true;}this.Canvas.beginPath();if(this.IsHScreen){this.Canvas.moveTo(ToFixedPoint(y),left);this.Canvas.lineTo(ToFixedPoint(y),right);}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}this.Canvas.stroke();if(bChangeLineWidth){this.Canvas.lineWidth=pixelRatio;}}else{this.DrawDotLine(left,right,y,color,option);}};this.DrawHScreenText=function(center,data){this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=data.Color;this.Canvas.save();this.Canvas.translate(center.X,center.Y);this.Canvas.rotate(90*Math.PI/180);this.Canvas.fillText(data.Text,data.XOffset,data.YOffset);this.Canvas.restore();};this.RGBToStruct=function(rgb){if(/^(rgb|RGB)/.test(rgb)){var aColor=rgb.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");var result={};if(aColor.length!=3)return null;result.R=Number(aColor[0]);result.G=Number(aColor[1]);result.B=Number(aColor[2]);return result;}return null;};this.GetMulitTextMaxWidth=function(aryData){var width=null;for(var i=0;i<aryData.length;++i){var item=aryData[i];var text=item.Text;if(!text)continue;var value=this.Canvas.measureText(text).width;if(width==null)width=value;else if(width<value)width=value;}return width;};this.GetScaleTextWidth=function(){var border=this.ChartBorder.GetBorder();var pixelTatio=GetDevicePixelRatio();//获取设备的分辨率
|
|
2354
2360
|
if(this.IsHScreen){var borderTop=this.ChartBorder.Top;var borderBottom=this.ChartBorder.Bottom;var isDrawLeft=borderTop>10*pixelTatio&&this.IsShowYText[0]===true&&this.YTextPosition[0]!=2;var isDrawRight=borderBottom>10*pixelTatio&&this.IsShowYText[1]===true&&this.YTextPosition[1]!=2;}else{var borderRight=this.ChartBorder.Right;var borderLeft=this.ChartBorder.Left;var isDrawLeft=borderLeft>10&&this.IsShowYText[0]===true&&this.YTextPosition[0]!=2;var isDrawRight=borderRight>10&&this.IsShowYText[1]===true&&this.YTextPosition[1]!=2;}if(!isDrawRight&&!isDrawLeft)return null;var width={Left:null,Right:null};var rightExtendWidth=0;var isYPercentage=false;//是否是百分比坐标
|
|
2355
|
-
if(this.YSplitOperator&&this.YSplitOperator.CoordinateType==1)isYPercentage=true;var leftExtendLineWidth=0;var rightExtendLineWidth=0;if(IFrameSplitOperator.IsNonEmptyArray(this.YLineExtend)){if(this.YLineExtend[0]&&this.YLineExtend[0].Width>1)leftExtendLineWidth=this.YLineExtend[0].Width;if(this.YLineExtend[1]&&this.YLineExtend[1].Width>1)rightExtendLineWidth=this.YLineExtend[1].Width;}for(var i=0;i<this.HorizontalInfo.length;++i){var textWidth=null;var item=this.HorizontalInfo[i];if(!item)continue;if(item.Font!=null)this.Canvas.font=item.Font;if(item.Message[0]!=null&&isDrawLeft){textWidth=this.Canvas.measureText(item.Message[0]).width;if(width.Left==null||width.Left<textWidth)width.Left=textWidth;//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
|
|
2361
|
+
if(this.YSplitOperator&&this.YSplitOperator.CoordinateType==1)isYPercentage=true;var leftExtendLineWidth=0;var rightExtendLineWidth=0;if(IFrameSplitOperator.IsNonEmptyArray(this.YLineExtend)){if(this.YLineExtend[0]&&this.YLineExtend[0].Width>1)leftExtendLineWidth=this.YLineExtend[0].Width;if(this.YLineExtend[1]&&this.YLineExtend[1].Width>1)rightExtendLineWidth=this.YLineExtend[1].Width;}for(var i=0;i<this.HorizontalInfo.length;++i){var textWidth=null;var item=this.HorizontalInfo[i];if(!item)continue;if(item.Font!=null)this.Canvas.font=item.Font;if(item.Message[0]!=null&&isDrawLeft){if(Array.isArray(item.Message[0])){textWidth=this.GetMulitTextMaxWidth(item.Message[0]);}else{textWidth=this.Canvas.measureText(item.Message[0]).width;}if(width.Left==null||width.Left<textWidth)width.Left=textWidth;//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
|
|
2356
2362
|
}if(item.Message[1]!=null&&isDrawRight){if(item.Font!=null)this.Canvas.font=item.Font;if(Array.isArray(item.Message[1])){if(this.MultiTextFormat==1)//显示1行 格式:价格/百分比
|
|
2357
2363
|
{if(item.ExtendData){if(item.ExtendData.Font)this.Canvas.font=item.ExtendData.Font;var width1=this.Canvas.measureText(item.Message[1][0]).width;var width2=this.Canvas.measureText(item.Message[1][1]).width;var width3=this.Canvas.measureText('/').width;textWidth=width1+width3;if(rightExtendWidth<width2)rightExtendWidth=width2;//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[1][1]}/${item.Message[1][0]} ${textWidth}, ${rightExtendWidth}`);
|
|
2358
2364
|
}}else if(this.MultiTextFormat==2)//显示2行
|
|
2359
|
-
{textWidth=this.Canvas.measureText(item.Message[1][0]).width;var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;if(textWidth<textWidth2)textWidth=textWidth2;}else//显示第1行
|
|
2365
|
+
{textWidth=this.Canvas.measureText(item.Message[1][0]).width;var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;if(textWidth<textWidth2)textWidth=textWidth2;}else if(this.MultiTextFormat==3){textWidth=this.GetMulitTextMaxWidth(item.Message[0]);}else//显示第1行
|
|
2360
2366
|
{textWidth=this.Canvas.measureText(item.Message[1][0]).width;if(isYPercentage){var perTextWidth=this.Canvas.measureText("-00.00%").width;if(perTextWidth>textWidth)textWidth=perTextWidth;}}}else{textWidth=this.Canvas.measureText(item.Message[1]).width;}if(width.Right==null||width.Right<textWidth)width.Right=textWidth;}}if(IFrameSplitOperator.IsNumber(width.Right))width.Right+=rightExtendWidth;if(IFrameSplitOperator.IsNumber(width.Left))width.Left+=this.YTextPadding[0]+leftExtendLineWidth;if(IFrameSplitOperator.IsNumber(width.Right))width.Right+=this.YTextPadding[1]+rightExtendLineWidth;return{TextWidth:width};};this.ClearToolbar=function(){if(!this.ToolbarID)return;var divToolbar=document.getElementById(this.ToolbarID);if(!divToolbar)return;this.ChartBorder.UIElement.parentNode.removeChild(divToolbar);this.ToolbarRect=null;};this.HideToolbar=function(){if(!this.ToolbarID)return;this.ToolbarRect=null;var divToolbar=document.getElementById(this.ToolbarID);if(!divToolbar)return;if(divToolbar.style.display!='none')divToolbar.style.display='none';};}function MinuteFrame(){this.newMethod=AverageWidthFrame;//派生
|
|
2361
2367
|
this.newMethod();delete this.newMethod;this.ClassName="MinuteFrame";this.DataWidth=1*GetDevicePixelRatio();this.DistanceWidth=1*GetDevicePixelRatio();this.MinuteCount=243;//每天的分钟个数
|
|
2362
2368
|
this.BeforeBGColor=g_JSChartResource.Minute.Before.BGColor;//集合竞价背景
|
|
@@ -4801,7 +4807,8 @@ this.EndDate;//{ Date:, Index: }
|
|
|
4801
4807
|
this.CenterDate;//{ Date:, Index: }
|
|
4802
4808
|
this.HQChart;this.DragRect;//拖拽边框区域数组 []
|
|
4803
4809
|
this.ShowRangeText={Enable:false,Position:0,//0顶部 1=中间 2=底部
|
|
4804
|
-
Font:g_JSChartResource.RectSelect.RangeTextFont,Color:g_JSChartResource.RectSelect.RangeTextColor,BGColor:g_JSChartResource.RectSelect.RangeTextBGColor,SubPosition:0,SubFont:g_JSChartResource.RectSelect.RangeTextSubFont,SubColor:g_JSChartResource.RectSelect.RangeTextSubColor,SubBGColor:g_JSChartResource.RectSelect.RangeTextSubBGColor};this.BorderCache
|
|
4810
|
+
Font:g_JSChartResource.RectSelect.RangeTextFont,Color:g_JSChartResource.RectSelect.RangeTextColor,BGColor:g_JSChartResource.RectSelect.RangeTextBGColor,SubPosition:0,SubFont:g_JSChartResource.RectSelect.RangeTextSubFont,SubColor:g_JSChartResource.RectSelect.RangeTextSubColor,SubBGColor:g_JSChartResource.RectSelect.RangeTextSubBGColor};this.BorderCache;this.IsOnlyOnePoint=false;//单点模式
|
|
4811
|
+
//设置参数接口
|
|
4805
4812
|
this.SetOption=function(option){if(option){if(option.LineColor)this.LineColor=option.LineColor;if(option.AreaColor)this.AreaColor=option.AreaColor;if(IFrameSplitOperator.IsBool(option.SpaceReselected))this.SpaceReselected=option.SpaceReselected;if(option.ShowRangeText){var item=option.ShowRangeText;if(IFrameSplitOperator.IsBool(item.Enable))this.ShowRangeText.Enable=item.Enable;if(IFrameSplitOperator.IsNumber(item.Position))this.ShowRangeText.Position=item.Position;if(IFrameSplitOperator.IsNumber(item.SubPosition))this.ShowRangeText.SubPosition=item.SubPosition;}}};this.ReloadResource=function(resource){this.LineColor=g_JSChartResource.RectSelect.LineColor;//竖线
|
|
4806
4813
|
this.LineWidth=g_JSChartResource.RectSelect.LineWidth;this.LineDotted=g_JSChartResource.RectSelect.LineDotted;this.AreaColor=g_JSChartResource.RectSelect.AreaColor;//面积
|
|
4807
4814
|
this.ShowRangeText.Font=g_JSChartResource.RectSelect.RangeTextFont;this.ShowRangeText.Color=g_JSChartResource.RectSelect.RangeTextColor;this.ShowRangeText.BGColor=g_JSChartResource.RectSelect.RangeTextBGColor;};this.IsMinuteChart=function(){var className=this.HQChart.ClassName;var isMinuteChart=className=="MinuteChartContainer"||className=="MinuteChartHScreenContainer"?true:false;return isMinuteChart;};this.GetKData=function(){if(!this.HQChart)return null;var isMinuteChart=this.IsMinuteChart();var data=null;if(isMinuteChart){if(!this.HQChart.SourceData)return null;data=this.HQChart.SourceData;}else{if(!this.HQChart.ChartPaint[0])return null;data=this.HQChart.ChartPaint[0].Data;if(!data)return null;}return data;};this.GetPointCount=function(){var count=0;if(this.FirstPoint)++count;if(this.SecondPoint)++count;return count;};this.DateToNumber=function(value,isMinuteChart){if(isMinuteChart){if(IFrameSplitOperator.IsNumber(value.Date))return value.Date*10000+value.Time;else return value.Time;}else{var period=this.HQChart.Period;if(ChartData.IsDayPeriod(period,true))return value.Date;//YYYYMMDD
|
|
@@ -4813,7 +4820,7 @@ if(this.SubClient.FirstPoint&&this.SubClient.SecondPoint){var firstValue=this.Da
|
|
|
4813
4820
|
if(this.SubClient.End.Date<=this.StartDate.Date||this.SubClient.Start.Date>=this.EndDate.Date){this.SubClient.Start=null;this.SubClient.End=null;}else{if(this.SubClient.Start.Date<this.StartDate.Date)this.SubClient.Start.Date=this.StartDate.Date;if(this.SubClient.End.Date>this.EndDate.Date)this.SubClient.End.Date=this.EndDate.Date;}}}};this.GetCenterPoint=function(){if(!this.FirstPoint||!this.SecondPoint)return null;if(!IFrameSplitOperator.IsNumber(this.FirstPoint.DataIndex))return null;if(!IFrameSplitOperator.IsNumber(this.SecondPoint.DataIndex))return null;var count=this.FirstPoint.DataIndex-this.SecondPoint.DataIndex;if(Math.abs(count)<3)return null;var centerIndex=parseInt(this.FirstPoint.DataIndex+(this.SecondPoint.DataIndex-this.FirstPoint.DataIndex)/2);if(centerIndex<0)return null;var data=this.GetKData();if(!data||!data.Data)return null;var kItem=data.Data[centerIndex];if(!kItem)return null;return{Date:kItem.Date,Time:kItem.Time,DataIndex:centerIndex};};this.MovePoint=function(offset){if(!this.FirstPoint||!this.SecondPoint)return false;var data=this.GetKData();if(!data||!data.Data)return false;var dataIndex=this.FirstPoint.DataIndex+offset;var kItem=data.Data[dataIndex];if(!kItem)return false;var firstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};var dataIndex=this.SecondPoint.DataIndex+offset;var kItem=data.Data[dataIndex];if(!kItem)return false;var secondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};var dataIndex=this.CenterPoint.DataIndex+offset;var kItem=data.Data[dataIndex];if(!kItem)return false;var centerPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};this.FirstPoint=firstPoint;this.SecondPoint=secondPoint;this.CenterPoint=centerPoint;return true;};this.MoveSubRect=function(step,isLeft){if(!this.FirstPoint||!this.SecondPoint)return false;if(!this.SubClient||!this.SubClient.FirstPoint||!this.SubClient.SecondPoint)return false;var data=this.GetKData();if(!data||!data.Data)return false;//区间范围
|
|
4814
4821
|
var startIndex=Math.min(this.FirstPoint.DataIndex,this.SecondPoint.DataIndex);var endIndex=Math.max(this.FirstPoint.DataIndex,this.SecondPoint.DataIndex);var subStartPoint=this.SubClient.FirstPoint;var subEndPoint=this.SubClient.SecondPoint;if(this.SubClient.FirstPoint.DataIndex>this.SubClient.SecondPoint.DataIndex){var subStartPoint=this.SubClient.SecondPoint;var subEndPoint=this.SubClient.FirstPoint;}var subStartIndex=subStartPoint.DataIndex;var subEndIndex=subEndPoint.DataIndex;if(isLeft){if(subStartIndex<=startIndex)return false;subStartIndex-=step;subEndIndex-=step;}else{if(subEndPoint.DataIndex>=endIndex)return false;subStartIndex+=step;subEndIndex+=step;}var bChanged=false;if(subStartIndex!=subStartPoint.DataIndex){subStartPoint.DataIndex=subStartIndex;var kItem=data.Data[subStartIndex];subStartPoint.Date=kItem.Date;subStartPoint.Time=kItem.Time;bChanged=true;}if(subEndIndex!=subStartPoint.DataIndex){subEndPoint.DataIndex=subEndIndex;var kItem=data.Data[subEndIndex];subEndPoint.Date=kItem.Date;subEndPoint.Time=kItem.Time;bChanged=true;}return bChanged;};this.SetPoint=function(kItem,option){var dataIndex=null;if(option){if(IFrameSplitOperator.IsNumber(option.DataIndex))dataIndex=option.DataIndex;}if(option&&IFrameSplitOperator.IsNumber(option.Index)){switch(option.Index){case 0:this.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};this.CenterPoint=this.GetCenterPoint();return true;case 1:this.SecondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};this.CenterPoint=this.GetCenterPoint();return true;case 2://中心偏移
|
|
4815
4822
|
var offset=dataIndex-this.CenterPoint.DataIndex;//this.CenterPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
4816
|
-
if(Math.abs(offset)>0)return this.MovePoint(offset);return false;case 3:this.SubClient.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;case 4:this.SubClient.SecondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;default:return false;}}else{if(!this.FirstPoint){this.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;}if(!this.SecondPoint){this.SecondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};this.CenterPoint=this.GetCenterPoint();return true;}return false;}};this.ClearPoint=function(){if(this.PreventClose)return false;var bRedraw=false;if(this.FirstPoint){this.FirstPoint=null;bRedraw=true;}if(this.SecondPoint){this.SecondPoint=null;bRedraw=true;}this.SubClient.FirstPoint=null;this.SubClient.SecondPoint=null;return bRedraw;};this.Draw=function(){this.BorderCache=null;this.StartDate=null;this.EndDate=null;this.CenterDate=null;this.DragRect=[];this.SubClient.Start=null;this.SubClient.End=null;if(!this.FirstPoint&&!this.SecondPoint)return;this.SortPoint();var data=this.GetKData();if(!data)return;this.Data=data;if(!this.ChartFrame||!this.ChartFrame.SubFrame)return;var subFrame=this.ChartFrame.SubFrame[0].Frame;if(!subFrame)return;var isHScreen=subFrame.IsHScreen===true;var dataWidth=subFrame.DataWidth;var distanceWidth=subFrame.DistanceWidth;var xPointCount=subFrame.XPointCount;if(isHScreen){var border=subFrame.GetBorder();var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;var chartright=border.BottomEx;this.BorderCache=border;}else{var border=subFrame.GetBorder();var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;var chartright=border.RightEx;var drawHeight=border.ChartHeight-border.TopTitle-5*GetDevicePixelRatio();var top=border.TopEx;var bottom=border.BottomEx;this.BorderCache=border;}this.Canvas.save();var isDayPeriod=ChartData.IsDayPeriod(this.HQChart.Period,true);var isMinuteChart=this.IsMinuteChart();var startPoint=null,endPoint=null,subStartPoint=null,subEndPoint=null;var startDate=null,startEnd=null;var aryLines=[];for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length&&j<xPointCount;++i,++j,xOffset+=dataWidth+distanceWidth){var item=this.Data.Data[i];if(!item)continue;var left=xOffset;var right=xOffset+dataWidth;if(isMinuteChart)var x=subFrame.GetXFromIndex(j);else var x=left+(right-left)/2;var value=this.DateToNumber(item,isMinuteChart);if(this.StartDate&&value==this.StartDate.Date){startPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.StartDate.Index,Type:0,Item:item};aryLines.push(startPoint);}if(this.EndDate&&value==this.EndDate.Date){endPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.EndDate.Index,Type:1,Item:item};aryLines.push(endPoint);}if(this.CenterDate&&value==this.CenterDate.Date){var centerPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.CenterDate.Index,Type:2,Item:item};aryLines.push(centerPoint);}if(this.SubClient&&this.SubClient.Start&&this.SubClient.End){if(value==this.SubClient.Start.Date){this.SubClient.Start.Point={Date:value,X:x,Top:top,Bottom:bottom,KItem:item};}if(value==this.SubClient.End.Date){this.SubClient.End.Point={Date:value,X:x,Top:top,Bottom:bottom,kItem:item};}}if(!startDate){startDate={Date:value,X:x,Top:top,Bottom:bottom};startEnd={Date:value,X:x,Top:top,Bottom:bottom};}else{startEnd.Date=value;startEnd.X=x;}if(startPoint&&endPoint)break;}this.DrawLines(aryLines);this.DrawArea(startPoint,endPoint,startDate,startEnd,this.AreaColor);if(this.SubClient&&this.SubClient.Start&&this.SubClient.End){this.DrawArea(this.SubClient.Start.Point,this.SubClient.End.Point,startDate,startEnd,this.SubAreaColor,4);if(this.SubClient.Start.Point){var item=this.SubClient.Start.Point;var point={X:item.X,Top:item.Top,Bottom:item.Bottom,PointIndex:item.DataIndex,Type:3,Item:item.KItem};aryLines.push(point);}}this.DrawRangeText(aryLines);this.Canvas.restore();};this.DrawRangeText=function(aryLines){if(!this.ShowRangeText)return;if(this.ShowRangeText.Enable==false)return;//文字
|
|
4823
|
+
if(Math.abs(offset)>0)return this.MovePoint(offset);return false;case 3:this.SubClient.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;case 4:this.SubClient.SecondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;default:return false;}}else{if(this.IsOnlyOnePoint){this.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;}if(!this.FirstPoint){this.FirstPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};return true;}if(!this.SecondPoint){this.SecondPoint={Date:kItem.Date,Time:kItem.Time,DataIndex:dataIndex};this.CenterPoint=this.GetCenterPoint();return true;}return false;}};this.ClearPoint=function(){if(this.PreventClose)return false;var bRedraw=false;if(this.FirstPoint){this.FirstPoint=null;bRedraw=true;}if(this.SecondPoint){this.SecondPoint=null;bRedraw=true;}this.SubClient.FirstPoint=null;this.SubClient.SecondPoint=null;return bRedraw;};this.Draw=function(){this.BorderCache=null;this.StartDate=null;this.EndDate=null;this.CenterDate=null;this.DragRect=[];this.SubClient.Start=null;this.SubClient.End=null;if(!this.FirstPoint&&!this.SecondPoint)return;this.SortPoint();var data=this.GetKData();if(!data)return;this.Data=data;if(!this.ChartFrame||!this.ChartFrame.SubFrame)return;var subFrame=this.ChartFrame.SubFrame[0].Frame;if(!subFrame)return;var isHScreen=subFrame.IsHScreen===true;var dataWidth=subFrame.DataWidth;var distanceWidth=subFrame.DistanceWidth;var xPointCount=subFrame.XPointCount;if(isHScreen){var border=subFrame.GetBorder();var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;var chartright=border.BottomEx;this.BorderCache=border;}else{var border=subFrame.GetBorder();var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;var chartright=border.RightEx;var drawHeight=border.ChartHeight-border.TopTitle-5*GetDevicePixelRatio();var top=border.TopEx;var bottom=border.BottomEx;this.BorderCache=border;}this.Canvas.save();var isDayPeriod=ChartData.IsDayPeriod(this.HQChart.Period,true);var isMinuteChart=this.IsMinuteChart();var startPoint=null,endPoint=null,subStartPoint=null,subEndPoint=null;var startDate=null,startEnd=null;var aryLines=[];for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length&&j<xPointCount;++i,++j,xOffset+=dataWidth+distanceWidth){var item=this.Data.Data[i];if(!item)continue;var left=xOffset;var right=xOffset+dataWidth;if(isMinuteChart)var x=subFrame.GetXFromIndex(j);else var x=left+(right-left)/2;var value=this.DateToNumber(item,isMinuteChart);if(this.StartDate&&value==this.StartDate.Date){startPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.StartDate.Index,Type:0,Item:item};aryLines.push(startPoint);}if(this.EndDate&&value==this.EndDate.Date){endPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.EndDate.Index,Type:1,Item:item};aryLines.push(endPoint);}if(this.CenterDate&&value==this.CenterDate.Date){var centerPoint={XIndex:i,X:x,Top:top,Bottom:bottom,PointIndex:this.CenterDate.Index,Type:2,Item:item};aryLines.push(centerPoint);}if(this.SubClient&&this.SubClient.Start&&this.SubClient.End){if(value==this.SubClient.Start.Date){this.SubClient.Start.Point={Date:value,X:x,Top:top,Bottom:bottom,KItem:item};}if(value==this.SubClient.End.Date){this.SubClient.End.Point={Date:value,X:x,Top:top,Bottom:bottom,kItem:item};}}if(!startDate){startDate={Date:value,X:x,Top:top,Bottom:bottom};startEnd={Date:value,X:x,Top:top,Bottom:bottom};}else{startEnd.Date=value;startEnd.X=x;}if(startPoint&&endPoint)break;}this.DrawLines(aryLines);this.DrawArea(startPoint,endPoint,startDate,startEnd,this.AreaColor);if(this.SubClient&&this.SubClient.Start&&this.SubClient.End){this.DrawArea(this.SubClient.Start.Point,this.SubClient.End.Point,startDate,startEnd,this.SubAreaColor,4);if(this.SubClient.Start.Point){var item=this.SubClient.Start.Point;var point={X:item.X,Top:item.Top,Bottom:item.Bottom,PointIndex:item.DataIndex,Type:3,Item:item.KItem};aryLines.push(point);}}this.DrawRangeText(aryLines);this.Canvas.restore();};this.DrawRangeText=function(aryLines){if(!this.ShowRangeText)return;if(this.ShowRangeText.Enable==false)return;//文字
|
|
4817
4824
|
var border=this.BorderCache;var isMinuteChart=this.IsMinuteChart();var period=this.HQChart.Period;var x,y,text;for(var i=0;i<aryLines.length;++i){var item=aryLines[i];if(item.Type===0||item.Type==1||item.Type==3)//第1个点,第2个点
|
|
4818
4825
|
{if(isMinuteChart){var strDate=IFrameSplitOperator.FormatDateString(item.Item.Date,"YYYY-MM-DD");var strTime=IFrameSplitOperator.FormatTimeString(item.Item.Time,"HH:MM");text=strDate+' '+strTime;}else{var strDate=IFrameSplitOperator.FormatDateString(item.Item.Date,"YYYY-MM-DD");var strTime=null;if(ChartData.IsMinutePeriod(period,true))strTime=IFrameSplitOperator.FormatTimeString(item.Item.Time,"HH:MM");else if(ChartData.IsSecondPeriod(period)||ChartData.IsTickPeriod(period))strTime=IFrameSplitOperator.FormatTimeString(item.Item.Time,"HH:MM:SS");if(strTime)text=strDate+' '+strTime;else text=strDate;}if(item.Type==3){var postion=this.ShowRangeText.SubPosition;var bgColor=this.ShowRangeText.SubBGColor;var textColor=this.ShowRangeText.SubColor;this.Canvas.font=this.ShowRangeText.SubFont;var textHeight=this.GetFontHeight();}else{var postion=this.ShowRangeText.Position;var bgColor=this.ShowRangeText.BGColor;var textColor=this.ShowRangeText.Color;this.Canvas.font=this.ShowRangeText.Font;var textHeight=this.GetFontHeight();}var textWidth=this.Canvas.measureText(text).width+4;var rtBG={Height:textHeight,Width:textWidth};if(item.Type==0||item.Type==3)//第1个点
|
|
4819
4826
|
{if(textWidth>item.X){this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";x=item.X+2;rtBG.X=item.X;}else{this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";x=item.X-2;rtBG.X=item.X-textWidth;}}else if(item.Type==1)//第2个点
|
|
@@ -12789,7 +12796,7 @@ hisData.Symbol=message.symbol;}var stockObj={HQDataType:HQ_DATA_TYPE.KLINE_ID,St
|
|
|
12789
12796
|
this.ExecuteScript(item,data);}this.Status=0;}};this.OnExecuteFinish=function(data,indexInfo,jsExectute,jobInfo){var message={Data:data,IndexInfo:indexInfo,ID:JSCHART_WORKER_MESSAGE_ID.FINISH_EXECUTE_SCRIPT,JobInfo:jobInfo};postMessage(message);};this.OnExecuteError=function(error,indexInfo,jobData){var message={IndexInfo:indexInfo,ID:JSCHART_WORKER_MESSAGE_ID.ERROR_EXECUTE_SCRIPT,Error:error};postMessage(message);};}/********************************************************************************
|
|
12790
12797
|
* 版本信息输出
|
|
12791
12798
|
*
|
|
12792
|
-
*/var HQCHART_VERSION="1.1.
|
|
12799
|
+
*/var HQCHART_VERSION="1.1.12904";function PrintHQChartVersion(){var log='*************************************************************************************************************\n*\n* HQChart Ver: '+HQCHART_VERSION+' \n* \n* License: Apache License 2.0 \n* Source: https://github.com/jones2000/HQChart\n*\n*************************************************************************************************************\n';console.log(log);}PrintHQChartVersion();//把给外界调用的方法暴露出来
|
|
12793
12800
|
exports.default=(_jsChartInit$jsChartS={jsChartInit:JSChart.Init,jsChartStyle:JSChart.SetStyle,// IsIndexSymbol:IsIndexSymbol,
|
|
12794
12801
|
// BaseIndex:BaseIndex,
|
|
12795
12802
|
// ChartLine:ChartLine,
|
package/package.json
CHANGED
package/src/jscommon/umychart.js
CHANGED
|
@@ -5906,7 +5906,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
5906
5906
|
var sendData={ MouseStatus:null, X:x, Y:y, FrameID:frameID, e:e };
|
|
5907
5907
|
if (this.TryMouseMove_CustomChartDrag(sendData))
|
|
5908
5908
|
{
|
|
5909
|
-
if (sendData.MouseStatus)
|
|
5909
|
+
if (sendData.MouseStatus)
|
|
5910
|
+
mouseStatus=sendData.MouseStatus;
|
|
5910
5911
|
}
|
|
5911
5912
|
|
|
5912
5913
|
var bDrawPicture=false; //是否正在画图
|
|
@@ -5956,7 +5957,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
5956
5957
|
}
|
|
5957
5958
|
else
|
|
5958
5959
|
{
|
|
5959
|
-
if (!this.MouseDrag)
|
|
5960
|
+
if (!this.MouseDrag)
|
|
5961
|
+
this.SetCursor({Cursor:"default"}); //this.UIElement.style.cursor="default";
|
|
5960
5962
|
}
|
|
5961
5963
|
}
|
|
5962
5964
|
|
|
@@ -10093,35 +10095,46 @@ function AverageWidthFrame()
|
|
|
10093
10095
|
|
|
10094
10096
|
if (item.Message[0]!=null && isDrawLeft)
|
|
10095
10097
|
{
|
|
10096
|
-
if (item.
|
|
10097
|
-
|
|
10098
|
-
var xText=left;
|
|
10099
|
-
if (leftExtendLine && leftExtendLine.Width>1)
|
|
10098
|
+
if (Array.isArray(item.Message[0]))
|
|
10100
10099
|
{
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
10107
|
-
this.Canvas.stroke();
|
|
10108
|
-
|
|
10109
|
-
xText-=lineLength;
|
|
10100
|
+
if (this.MultiTextFormat==3)
|
|
10101
|
+
{
|
|
10102
|
+
var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
|
|
10103
|
+
this.DrawMultiLineText(obj);
|
|
10104
|
+
}
|
|
10110
10105
|
}
|
|
10111
|
-
|
|
10112
|
-
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
10113
|
-
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
10106
|
+
else
|
|
10114
10107
|
{
|
|
10115
|
-
if (
|
|
10108
|
+
if (item.Font!=null) this.Canvas.font=item.Font;
|
|
10109
|
+
|
|
10110
|
+
var xText=left;
|
|
10111
|
+
if (leftExtendLine && leftExtendLine.Width>1)
|
|
10116
10112
|
{
|
|
10117
|
-
|
|
10118
|
-
this.Canvas.
|
|
10113
|
+
var lineLength=leftExtendLine.Width;
|
|
10114
|
+
if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
|
|
10115
|
+
else this.Canvas.strokeStyle=item.LineColor;
|
|
10116
|
+
this.Canvas.beginPath();
|
|
10117
|
+
this.Canvas.moveTo(xText,yFixed);
|
|
10118
|
+
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
10119
|
+
this.Canvas.stroke();
|
|
10120
|
+
|
|
10121
|
+
xText-=lineLength;
|
|
10119
10122
|
}
|
|
10120
|
-
|
|
10123
|
+
|
|
10124
|
+
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
10125
|
+
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
10121
10126
|
{
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10127
|
+
if (leftExtendText && leftExtendText.Align===1)
|
|
10128
|
+
{
|
|
10129
|
+
this.Canvas.textAlign="left";
|
|
10130
|
+
this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
|
|
10131
|
+
}
|
|
10132
|
+
else
|
|
10133
|
+
{
|
|
10134
|
+
this.Canvas.textAlign="right";
|
|
10135
|
+
this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
|
|
10136
|
+
rtPreLeft=rtLeft;
|
|
10137
|
+
}
|
|
10125
10138
|
}
|
|
10126
10139
|
}
|
|
10127
10140
|
}
|
|
@@ -10188,6 +10201,11 @@ function AverageWidthFrame()
|
|
|
10188
10201
|
var lineHeight=this.Canvas.measureText('M').width;
|
|
10189
10202
|
if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
|
|
10190
10203
|
}
|
|
10204
|
+
else if (this.MultiTextFormat==3)
|
|
10205
|
+
{
|
|
10206
|
+
var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
|
|
10207
|
+
this.DrawMultiLineText(obj);
|
|
10208
|
+
}
|
|
10191
10209
|
else //显示第1行
|
|
10192
10210
|
{
|
|
10193
10211
|
this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
|
|
@@ -10248,6 +10266,65 @@ function AverageWidthFrame()
|
|
|
10248
10266
|
}
|
|
10249
10267
|
}
|
|
10250
10268
|
|
|
10269
|
+
//多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
|
|
10270
|
+
this.DrawMultiLineText=function(obj)
|
|
10271
|
+
{
|
|
10272
|
+
var lineSpacing=2;
|
|
10273
|
+
var lineHeight=this.Canvas.measureText('擎').width;
|
|
10274
|
+
var lineCount=obj.Data.length;
|
|
10275
|
+
var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
|
|
10276
|
+
var yText=obj.Y;
|
|
10277
|
+
|
|
10278
|
+
if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
|
|
10279
|
+
|
|
10280
|
+
if (obj.IsLeft)
|
|
10281
|
+
{
|
|
10282
|
+
this.Canvas.textAlign="right";
|
|
10283
|
+
var xText=obj.X-obj.TextPadding;
|
|
10284
|
+
}
|
|
10285
|
+
else
|
|
10286
|
+
{
|
|
10287
|
+
this.Canvas.textAlign="left";
|
|
10288
|
+
var xText=obj.X+obj.TextPadding;
|
|
10289
|
+
}
|
|
10290
|
+
|
|
10291
|
+
var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
|
|
10292
|
+
this.Canvas.textBaseline='top';
|
|
10293
|
+
if (obj.TextBaseLine==1) //middle
|
|
10294
|
+
{
|
|
10295
|
+
yText-=textHeight/2;
|
|
10296
|
+
}
|
|
10297
|
+
else if (obj.TextBaseLine==0) //top
|
|
10298
|
+
{
|
|
10299
|
+
|
|
10300
|
+
}
|
|
10301
|
+
else if (obj.TextBaseLine==2) //bottom
|
|
10302
|
+
{
|
|
10303
|
+
yText-=textHeight;
|
|
10304
|
+
}
|
|
10305
|
+
|
|
10306
|
+
|
|
10307
|
+
for(var i=0;i<obj.Data.length;++i)
|
|
10308
|
+
{
|
|
10309
|
+
var item=obj.Data[i];
|
|
10310
|
+
var text=item.Text;
|
|
10311
|
+
|
|
10312
|
+
var backupTextColor=null;
|
|
10313
|
+
if (item.Color)
|
|
10314
|
+
{
|
|
10315
|
+
backupTextColor=this.Canvas.fillStyle;
|
|
10316
|
+
this.Canvas.fillStyle=item.Color;
|
|
10317
|
+
}
|
|
10318
|
+
|
|
10319
|
+
this.Canvas.fillText(text,xText,yText);
|
|
10320
|
+
yText+=lineHeight+lineSpacing;
|
|
10321
|
+
|
|
10322
|
+
if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
|
|
10323
|
+
}
|
|
10324
|
+
|
|
10325
|
+
this.Canvas.textBaseline=textBaseline; //还原对齐方式
|
|
10326
|
+
}
|
|
10327
|
+
|
|
10251
10328
|
//上下区域是否重叠
|
|
10252
10329
|
this.IsTextTopBottomOverlap=function(rt, rt2)
|
|
10253
10330
|
{
|
|
@@ -11457,6 +11534,24 @@ function AverageWidthFrame()
|
|
|
11457
11534
|
return null;
|
|
11458
11535
|
}
|
|
11459
11536
|
|
|
11537
|
+
this.GetMulitTextMaxWidth=function(aryData)
|
|
11538
|
+
{
|
|
11539
|
+
var width=null;
|
|
11540
|
+
|
|
11541
|
+
for(var i=0;i<aryData.length;++i)
|
|
11542
|
+
{
|
|
11543
|
+
var item=aryData[i];
|
|
11544
|
+
var text=item.Text;
|
|
11545
|
+
if (!text) continue;
|
|
11546
|
+
|
|
11547
|
+
var value=this.Canvas.measureText(text).width;
|
|
11548
|
+
if (width==null) width=value;
|
|
11549
|
+
else if(width<value) width=value;
|
|
11550
|
+
}
|
|
11551
|
+
|
|
11552
|
+
return width;
|
|
11553
|
+
}
|
|
11554
|
+
|
|
11460
11555
|
this.GetScaleTextWidth=function()
|
|
11461
11556
|
{
|
|
11462
11557
|
var border=this.ChartBorder.GetBorder();
|
|
@@ -11502,10 +11597,18 @@ function AverageWidthFrame()
|
|
|
11502
11597
|
|
|
11503
11598
|
if (item.Message[0]!=null && isDrawLeft)
|
|
11504
11599
|
{
|
|
11505
|
-
|
|
11600
|
+
if (Array.isArray(item.Message[0]))
|
|
11601
|
+
{
|
|
11602
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
11603
|
+
}
|
|
11604
|
+
else
|
|
11605
|
+
{
|
|
11606
|
+
textWidth=this.Canvas.measureText(item.Message[0]).width;
|
|
11607
|
+
}
|
|
11608
|
+
|
|
11506
11609
|
if (width.Left==null || width.Left<textWidth)
|
|
11507
11610
|
width.Left=textWidth;
|
|
11508
|
-
|
|
11611
|
+
|
|
11509
11612
|
//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
|
|
11510
11613
|
}
|
|
11511
11614
|
|
|
@@ -11536,6 +11639,10 @@ function AverageWidthFrame()
|
|
|
11536
11639
|
var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
|
|
11537
11640
|
if (textWidth<textWidth2) textWidth=textWidth2;
|
|
11538
11641
|
}
|
|
11642
|
+
else if (this.MultiTextFormat==3)
|
|
11643
|
+
{
|
|
11644
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
11645
|
+
}
|
|
11539
11646
|
else //显示第1行
|
|
11540
11647
|
{
|
|
11541
11648
|
textWidth=this.Canvas.measureText(item.Message[1][0]).width;
|
|
@@ -40627,6 +40734,7 @@ function RectSelectPaint()
|
|
|
40627
40734
|
};
|
|
40628
40735
|
|
|
40629
40736
|
this.BorderCache;
|
|
40737
|
+
this.IsOnlyOnePoint=false; //单点模式
|
|
40630
40738
|
|
|
40631
40739
|
//设置参数接口
|
|
40632
40740
|
this.SetOption=function(option)
|
|
@@ -40957,6 +41065,12 @@ function RectSelectPaint()
|
|
|
40957
41065
|
}
|
|
40958
41066
|
else
|
|
40959
41067
|
{
|
|
41068
|
+
if (this.IsOnlyOnePoint)
|
|
41069
|
+
{
|
|
41070
|
+
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
41071
|
+
return true;
|
|
41072
|
+
}
|
|
41073
|
+
|
|
40960
41074
|
if (!this.FirstPoint)
|
|
40961
41075
|
{
|
|
40962
41076
|
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
@@ -10073,7 +10073,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
10073
10073
|
var sendData={ MouseStatus:null, X:x, Y:y, FrameID:frameID, e:e };
|
|
10074
10074
|
if (this.TryMouseMove_CustomChartDrag(sendData))
|
|
10075
10075
|
{
|
|
10076
|
-
if (sendData.MouseStatus)
|
|
10076
|
+
if (sendData.MouseStatus)
|
|
10077
|
+
mouseStatus=sendData.MouseStatus;
|
|
10077
10078
|
}
|
|
10078
10079
|
|
|
10079
10080
|
var bDrawPicture=false; //是否正在画图
|
|
@@ -10123,7 +10124,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
10123
10124
|
}
|
|
10124
10125
|
else
|
|
10125
10126
|
{
|
|
10126
|
-
if (!this.MouseDrag)
|
|
10127
|
+
if (!this.MouseDrag)
|
|
10128
|
+
this.SetCursor({Cursor:"default"}); //this.UIElement.style.cursor="default";
|
|
10127
10129
|
}
|
|
10128
10130
|
}
|
|
10129
10131
|
|
|
@@ -14260,35 +14262,46 @@ function AverageWidthFrame()
|
|
|
14260
14262
|
|
|
14261
14263
|
if (item.Message[0]!=null && isDrawLeft)
|
|
14262
14264
|
{
|
|
14263
|
-
if (item.
|
|
14264
|
-
|
|
14265
|
-
var xText=left;
|
|
14266
|
-
if (leftExtendLine && leftExtendLine.Width>1)
|
|
14265
|
+
if (Array.isArray(item.Message[0]))
|
|
14267
14266
|
{
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
14274
|
-
this.Canvas.stroke();
|
|
14275
|
-
|
|
14276
|
-
xText-=lineLength;
|
|
14267
|
+
if (this.MultiTextFormat==3)
|
|
14268
|
+
{
|
|
14269
|
+
var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
|
|
14270
|
+
this.DrawMultiLineText(obj);
|
|
14271
|
+
}
|
|
14277
14272
|
}
|
|
14278
|
-
|
|
14279
|
-
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
14280
|
-
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
14273
|
+
else
|
|
14281
14274
|
{
|
|
14282
|
-
if (
|
|
14275
|
+
if (item.Font!=null) this.Canvas.font=item.Font;
|
|
14276
|
+
|
|
14277
|
+
var xText=left;
|
|
14278
|
+
if (leftExtendLine && leftExtendLine.Width>1)
|
|
14283
14279
|
{
|
|
14284
|
-
|
|
14285
|
-
this.Canvas.
|
|
14280
|
+
var lineLength=leftExtendLine.Width;
|
|
14281
|
+
if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
|
|
14282
|
+
else this.Canvas.strokeStyle=item.LineColor;
|
|
14283
|
+
this.Canvas.beginPath();
|
|
14284
|
+
this.Canvas.moveTo(xText,yFixed);
|
|
14285
|
+
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
14286
|
+
this.Canvas.stroke();
|
|
14287
|
+
|
|
14288
|
+
xText-=lineLength;
|
|
14286
14289
|
}
|
|
14287
|
-
|
|
14290
|
+
|
|
14291
|
+
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
14292
|
+
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
14288
14293
|
{
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14294
|
+
if (leftExtendText && leftExtendText.Align===1)
|
|
14295
|
+
{
|
|
14296
|
+
this.Canvas.textAlign="left";
|
|
14297
|
+
this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
|
|
14298
|
+
}
|
|
14299
|
+
else
|
|
14300
|
+
{
|
|
14301
|
+
this.Canvas.textAlign="right";
|
|
14302
|
+
this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
|
|
14303
|
+
rtPreLeft=rtLeft;
|
|
14304
|
+
}
|
|
14292
14305
|
}
|
|
14293
14306
|
}
|
|
14294
14307
|
}
|
|
@@ -14355,6 +14368,11 @@ function AverageWidthFrame()
|
|
|
14355
14368
|
var lineHeight=this.Canvas.measureText('M').width;
|
|
14356
14369
|
if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
|
|
14357
14370
|
}
|
|
14371
|
+
else if (this.MultiTextFormat==3)
|
|
14372
|
+
{
|
|
14373
|
+
var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
|
|
14374
|
+
this.DrawMultiLineText(obj);
|
|
14375
|
+
}
|
|
14358
14376
|
else //显示第1行
|
|
14359
14377
|
{
|
|
14360
14378
|
this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
|
|
@@ -14415,6 +14433,65 @@ function AverageWidthFrame()
|
|
|
14415
14433
|
}
|
|
14416
14434
|
}
|
|
14417
14435
|
|
|
14436
|
+
//多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
|
|
14437
|
+
this.DrawMultiLineText=function(obj)
|
|
14438
|
+
{
|
|
14439
|
+
var lineSpacing=2;
|
|
14440
|
+
var lineHeight=this.Canvas.measureText('擎').width;
|
|
14441
|
+
var lineCount=obj.Data.length;
|
|
14442
|
+
var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
|
|
14443
|
+
var yText=obj.Y;
|
|
14444
|
+
|
|
14445
|
+
if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
|
|
14446
|
+
|
|
14447
|
+
if (obj.IsLeft)
|
|
14448
|
+
{
|
|
14449
|
+
this.Canvas.textAlign="right";
|
|
14450
|
+
var xText=obj.X-obj.TextPadding;
|
|
14451
|
+
}
|
|
14452
|
+
else
|
|
14453
|
+
{
|
|
14454
|
+
this.Canvas.textAlign="left";
|
|
14455
|
+
var xText=obj.X+obj.TextPadding;
|
|
14456
|
+
}
|
|
14457
|
+
|
|
14458
|
+
var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
|
|
14459
|
+
this.Canvas.textBaseline='top';
|
|
14460
|
+
if (obj.TextBaseLine==1) //middle
|
|
14461
|
+
{
|
|
14462
|
+
yText-=textHeight/2;
|
|
14463
|
+
}
|
|
14464
|
+
else if (obj.TextBaseLine==0) //top
|
|
14465
|
+
{
|
|
14466
|
+
|
|
14467
|
+
}
|
|
14468
|
+
else if (obj.TextBaseLine==2) //bottom
|
|
14469
|
+
{
|
|
14470
|
+
yText-=textHeight;
|
|
14471
|
+
}
|
|
14472
|
+
|
|
14473
|
+
|
|
14474
|
+
for(var i=0;i<obj.Data.length;++i)
|
|
14475
|
+
{
|
|
14476
|
+
var item=obj.Data[i];
|
|
14477
|
+
var text=item.Text;
|
|
14478
|
+
|
|
14479
|
+
var backupTextColor=null;
|
|
14480
|
+
if (item.Color)
|
|
14481
|
+
{
|
|
14482
|
+
backupTextColor=this.Canvas.fillStyle;
|
|
14483
|
+
this.Canvas.fillStyle=item.Color;
|
|
14484
|
+
}
|
|
14485
|
+
|
|
14486
|
+
this.Canvas.fillText(text,xText,yText);
|
|
14487
|
+
yText+=lineHeight+lineSpacing;
|
|
14488
|
+
|
|
14489
|
+
if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
|
|
14490
|
+
}
|
|
14491
|
+
|
|
14492
|
+
this.Canvas.textBaseline=textBaseline; //还原对齐方式
|
|
14493
|
+
}
|
|
14494
|
+
|
|
14418
14495
|
//上下区域是否重叠
|
|
14419
14496
|
this.IsTextTopBottomOverlap=function(rt, rt2)
|
|
14420
14497
|
{
|
|
@@ -15624,6 +15701,24 @@ function AverageWidthFrame()
|
|
|
15624
15701
|
return null;
|
|
15625
15702
|
}
|
|
15626
15703
|
|
|
15704
|
+
this.GetMulitTextMaxWidth=function(aryData)
|
|
15705
|
+
{
|
|
15706
|
+
var width=null;
|
|
15707
|
+
|
|
15708
|
+
for(var i=0;i<aryData.length;++i)
|
|
15709
|
+
{
|
|
15710
|
+
var item=aryData[i];
|
|
15711
|
+
var text=item.Text;
|
|
15712
|
+
if (!text) continue;
|
|
15713
|
+
|
|
15714
|
+
var value=this.Canvas.measureText(text).width;
|
|
15715
|
+
if (width==null) width=value;
|
|
15716
|
+
else if(width<value) width=value;
|
|
15717
|
+
}
|
|
15718
|
+
|
|
15719
|
+
return width;
|
|
15720
|
+
}
|
|
15721
|
+
|
|
15627
15722
|
this.GetScaleTextWidth=function()
|
|
15628
15723
|
{
|
|
15629
15724
|
var border=this.ChartBorder.GetBorder();
|
|
@@ -15669,10 +15764,18 @@ function AverageWidthFrame()
|
|
|
15669
15764
|
|
|
15670
15765
|
if (item.Message[0]!=null && isDrawLeft)
|
|
15671
15766
|
{
|
|
15672
|
-
|
|
15767
|
+
if (Array.isArray(item.Message[0]))
|
|
15768
|
+
{
|
|
15769
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
15770
|
+
}
|
|
15771
|
+
else
|
|
15772
|
+
{
|
|
15773
|
+
textWidth=this.Canvas.measureText(item.Message[0]).width;
|
|
15774
|
+
}
|
|
15775
|
+
|
|
15673
15776
|
if (width.Left==null || width.Left<textWidth)
|
|
15674
15777
|
width.Left=textWidth;
|
|
15675
|
-
|
|
15778
|
+
|
|
15676
15779
|
//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
|
|
15677
15780
|
}
|
|
15678
15781
|
|
|
@@ -15703,6 +15806,10 @@ function AverageWidthFrame()
|
|
|
15703
15806
|
var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
|
|
15704
15807
|
if (textWidth<textWidth2) textWidth=textWidth2;
|
|
15705
15808
|
}
|
|
15809
|
+
else if (this.MultiTextFormat==3)
|
|
15810
|
+
{
|
|
15811
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
15812
|
+
}
|
|
15706
15813
|
else //显示第1行
|
|
15707
15814
|
{
|
|
15708
15815
|
textWidth=this.Canvas.measureText(item.Message[1][0]).width;
|
|
@@ -44794,6 +44901,7 @@ function RectSelectPaint()
|
|
|
44794
44901
|
};
|
|
44795
44902
|
|
|
44796
44903
|
this.BorderCache;
|
|
44904
|
+
this.IsOnlyOnePoint=false; //单点模式
|
|
44797
44905
|
|
|
44798
44906
|
//设置参数接口
|
|
44799
44907
|
this.SetOption=function(option)
|
|
@@ -45124,6 +45232,12 @@ function RectSelectPaint()
|
|
|
45124
45232
|
}
|
|
45125
45233
|
else
|
|
45126
45234
|
{
|
|
45235
|
+
if (this.IsOnlyOnePoint)
|
|
45236
|
+
{
|
|
45237
|
+
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
45238
|
+
return true;
|
|
45239
|
+
}
|
|
45240
|
+
|
|
45127
45241
|
if (!this.FirstPoint)
|
|
45128
45242
|
{
|
|
45129
45243
|
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
@@ -129154,7 +129268,7 @@ function ScrollBarBGChart()
|
|
|
129154
129268
|
|
|
129155
129269
|
|
|
129156
129270
|
|
|
129157
|
-
var HQCHART_VERSION="1.1.
|
|
129271
|
+
var HQCHART_VERSION="1.1.12904";
|
|
129158
129272
|
|
|
129159
129273
|
function PrintHQChartVersion()
|
|
129160
129274
|
{
|
|
@@ -10117,7 +10117,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
10117
10117
|
var sendData={ MouseStatus:null, X:x, Y:y, FrameID:frameID, e:e };
|
|
10118
10118
|
if (this.TryMouseMove_CustomChartDrag(sendData))
|
|
10119
10119
|
{
|
|
10120
|
-
if (sendData.MouseStatus)
|
|
10120
|
+
if (sendData.MouseStatus)
|
|
10121
|
+
mouseStatus=sendData.MouseStatus;
|
|
10121
10122
|
}
|
|
10122
10123
|
|
|
10123
10124
|
var bDrawPicture=false; //是否正在画图
|
|
@@ -10167,7 +10168,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
10167
10168
|
}
|
|
10168
10169
|
else
|
|
10169
10170
|
{
|
|
10170
|
-
if (!this.MouseDrag)
|
|
10171
|
+
if (!this.MouseDrag)
|
|
10172
|
+
this.SetCursor({Cursor:"default"}); //this.UIElement.style.cursor="default";
|
|
10171
10173
|
}
|
|
10172
10174
|
}
|
|
10173
10175
|
|
|
@@ -14304,35 +14306,46 @@ function AverageWidthFrame()
|
|
|
14304
14306
|
|
|
14305
14307
|
if (item.Message[0]!=null && isDrawLeft)
|
|
14306
14308
|
{
|
|
14307
|
-
if (item.
|
|
14308
|
-
|
|
14309
|
-
var xText=left;
|
|
14310
|
-
if (leftExtendLine && leftExtendLine.Width>1)
|
|
14309
|
+
if (Array.isArray(item.Message[0]))
|
|
14311
14310
|
{
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
14318
|
-
this.Canvas.stroke();
|
|
14319
|
-
|
|
14320
|
-
xText-=lineLength;
|
|
14311
|
+
if (this.MultiTextFormat==3)
|
|
14312
|
+
{
|
|
14313
|
+
var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
|
|
14314
|
+
this.DrawMultiLineText(obj);
|
|
14315
|
+
}
|
|
14321
14316
|
}
|
|
14322
|
-
|
|
14323
|
-
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
14324
|
-
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
14317
|
+
else
|
|
14325
14318
|
{
|
|
14326
|
-
if (
|
|
14319
|
+
if (item.Font!=null) this.Canvas.font=item.Font;
|
|
14320
|
+
|
|
14321
|
+
var xText=left;
|
|
14322
|
+
if (leftExtendLine && leftExtendLine.Width>1)
|
|
14327
14323
|
{
|
|
14328
|
-
|
|
14329
|
-
this.Canvas.
|
|
14324
|
+
var lineLength=leftExtendLine.Width;
|
|
14325
|
+
if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
|
|
14326
|
+
else this.Canvas.strokeStyle=item.LineColor;
|
|
14327
|
+
this.Canvas.beginPath();
|
|
14328
|
+
this.Canvas.moveTo(xText,yFixed);
|
|
14329
|
+
this.Canvas.lineTo(xText-lineLength,yFixed);
|
|
14330
|
+
this.Canvas.stroke();
|
|
14331
|
+
|
|
14332
|
+
xText-=lineLength;
|
|
14330
14333
|
}
|
|
14331
|
-
|
|
14334
|
+
|
|
14335
|
+
rtLeft=this.GetTextTopBottom(textBaseline,yText);
|
|
14336
|
+
if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
|
|
14332
14337
|
{
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14338
|
+
if (leftExtendText && leftExtendText.Align===1)
|
|
14339
|
+
{
|
|
14340
|
+
this.Canvas.textAlign="left";
|
|
14341
|
+
this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
|
|
14342
|
+
}
|
|
14343
|
+
else
|
|
14344
|
+
{
|
|
14345
|
+
this.Canvas.textAlign="right";
|
|
14346
|
+
this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
|
|
14347
|
+
rtPreLeft=rtLeft;
|
|
14348
|
+
}
|
|
14336
14349
|
}
|
|
14337
14350
|
}
|
|
14338
14351
|
}
|
|
@@ -14399,6 +14412,11 @@ function AverageWidthFrame()
|
|
|
14399
14412
|
var lineHeight=this.Canvas.measureText('M').width;
|
|
14400
14413
|
if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
|
|
14401
14414
|
}
|
|
14415
|
+
else if (this.MultiTextFormat==3)
|
|
14416
|
+
{
|
|
14417
|
+
var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
|
|
14418
|
+
this.DrawMultiLineText(obj);
|
|
14419
|
+
}
|
|
14402
14420
|
else //显示第1行
|
|
14403
14421
|
{
|
|
14404
14422
|
this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
|
|
@@ -14459,6 +14477,65 @@ function AverageWidthFrame()
|
|
|
14459
14477
|
}
|
|
14460
14478
|
}
|
|
14461
14479
|
|
|
14480
|
+
//多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
|
|
14481
|
+
this.DrawMultiLineText=function(obj)
|
|
14482
|
+
{
|
|
14483
|
+
var lineSpacing=2;
|
|
14484
|
+
var lineHeight=this.Canvas.measureText('擎').width;
|
|
14485
|
+
var lineCount=obj.Data.length;
|
|
14486
|
+
var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
|
|
14487
|
+
var yText=obj.Y;
|
|
14488
|
+
|
|
14489
|
+
if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
|
|
14490
|
+
|
|
14491
|
+
if (obj.IsLeft)
|
|
14492
|
+
{
|
|
14493
|
+
this.Canvas.textAlign="right";
|
|
14494
|
+
var xText=obj.X-obj.TextPadding;
|
|
14495
|
+
}
|
|
14496
|
+
else
|
|
14497
|
+
{
|
|
14498
|
+
this.Canvas.textAlign="left";
|
|
14499
|
+
var xText=obj.X+obj.TextPadding;
|
|
14500
|
+
}
|
|
14501
|
+
|
|
14502
|
+
var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
|
|
14503
|
+
this.Canvas.textBaseline='top';
|
|
14504
|
+
if (obj.TextBaseLine==1) //middle
|
|
14505
|
+
{
|
|
14506
|
+
yText-=textHeight/2;
|
|
14507
|
+
}
|
|
14508
|
+
else if (obj.TextBaseLine==0) //top
|
|
14509
|
+
{
|
|
14510
|
+
|
|
14511
|
+
}
|
|
14512
|
+
else if (obj.TextBaseLine==2) //bottom
|
|
14513
|
+
{
|
|
14514
|
+
yText-=textHeight;
|
|
14515
|
+
}
|
|
14516
|
+
|
|
14517
|
+
|
|
14518
|
+
for(var i=0;i<obj.Data.length;++i)
|
|
14519
|
+
{
|
|
14520
|
+
var item=obj.Data[i];
|
|
14521
|
+
var text=item.Text;
|
|
14522
|
+
|
|
14523
|
+
var backupTextColor=null;
|
|
14524
|
+
if (item.Color)
|
|
14525
|
+
{
|
|
14526
|
+
backupTextColor=this.Canvas.fillStyle;
|
|
14527
|
+
this.Canvas.fillStyle=item.Color;
|
|
14528
|
+
}
|
|
14529
|
+
|
|
14530
|
+
this.Canvas.fillText(text,xText,yText);
|
|
14531
|
+
yText+=lineHeight+lineSpacing;
|
|
14532
|
+
|
|
14533
|
+
if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
|
|
14534
|
+
}
|
|
14535
|
+
|
|
14536
|
+
this.Canvas.textBaseline=textBaseline; //还原对齐方式
|
|
14537
|
+
}
|
|
14538
|
+
|
|
14462
14539
|
//上下区域是否重叠
|
|
14463
14540
|
this.IsTextTopBottomOverlap=function(rt, rt2)
|
|
14464
14541
|
{
|
|
@@ -15668,6 +15745,24 @@ function AverageWidthFrame()
|
|
|
15668
15745
|
return null;
|
|
15669
15746
|
}
|
|
15670
15747
|
|
|
15748
|
+
this.GetMulitTextMaxWidth=function(aryData)
|
|
15749
|
+
{
|
|
15750
|
+
var width=null;
|
|
15751
|
+
|
|
15752
|
+
for(var i=0;i<aryData.length;++i)
|
|
15753
|
+
{
|
|
15754
|
+
var item=aryData[i];
|
|
15755
|
+
var text=item.Text;
|
|
15756
|
+
if (!text) continue;
|
|
15757
|
+
|
|
15758
|
+
var value=this.Canvas.measureText(text).width;
|
|
15759
|
+
if (width==null) width=value;
|
|
15760
|
+
else if(width<value) width=value;
|
|
15761
|
+
}
|
|
15762
|
+
|
|
15763
|
+
return width;
|
|
15764
|
+
}
|
|
15765
|
+
|
|
15671
15766
|
this.GetScaleTextWidth=function()
|
|
15672
15767
|
{
|
|
15673
15768
|
var border=this.ChartBorder.GetBorder();
|
|
@@ -15713,10 +15808,18 @@ function AverageWidthFrame()
|
|
|
15713
15808
|
|
|
15714
15809
|
if (item.Message[0]!=null && isDrawLeft)
|
|
15715
15810
|
{
|
|
15716
|
-
|
|
15811
|
+
if (Array.isArray(item.Message[0]))
|
|
15812
|
+
{
|
|
15813
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
15814
|
+
}
|
|
15815
|
+
else
|
|
15816
|
+
{
|
|
15817
|
+
textWidth=this.Canvas.measureText(item.Message[0]).width;
|
|
15818
|
+
}
|
|
15819
|
+
|
|
15717
15820
|
if (width.Left==null || width.Left<textWidth)
|
|
15718
15821
|
width.Left=textWidth;
|
|
15719
|
-
|
|
15822
|
+
|
|
15720
15823
|
//JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
|
|
15721
15824
|
}
|
|
15722
15825
|
|
|
@@ -15747,6 +15850,10 @@ function AverageWidthFrame()
|
|
|
15747
15850
|
var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
|
|
15748
15851
|
if (textWidth<textWidth2) textWidth=textWidth2;
|
|
15749
15852
|
}
|
|
15853
|
+
else if (this.MultiTextFormat==3)
|
|
15854
|
+
{
|
|
15855
|
+
textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
|
|
15856
|
+
}
|
|
15750
15857
|
else //显示第1行
|
|
15751
15858
|
{
|
|
15752
15859
|
textWidth=this.Canvas.measureText(item.Message[1][0]).width;
|
|
@@ -44838,6 +44945,7 @@ function RectSelectPaint()
|
|
|
44838
44945
|
};
|
|
44839
44946
|
|
|
44840
44947
|
this.BorderCache;
|
|
44948
|
+
this.IsOnlyOnePoint=false; //单点模式
|
|
44841
44949
|
|
|
44842
44950
|
//设置参数接口
|
|
44843
44951
|
this.SetOption=function(option)
|
|
@@ -45168,6 +45276,12 @@ function RectSelectPaint()
|
|
|
45168
45276
|
}
|
|
45169
45277
|
else
|
|
45170
45278
|
{
|
|
45279
|
+
if (this.IsOnlyOnePoint)
|
|
45280
|
+
{
|
|
45281
|
+
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
45282
|
+
return true;
|
|
45283
|
+
}
|
|
45284
|
+
|
|
45171
45285
|
if (!this.FirstPoint)
|
|
45172
45286
|
{
|
|
45173
45287
|
this.FirstPoint={ Date:kItem.Date, Time:kItem.Time, DataIndex:dataIndex };
|
|
@@ -129312,7 +129426,7 @@ function HQChartScriptWorker()
|
|
|
129312
129426
|
|
|
129313
129427
|
|
|
129314
129428
|
|
|
129315
|
-
var HQCHART_VERSION="1.1.
|
|
129429
|
+
var HQCHART_VERSION="1.1.12904";
|
|
129316
129430
|
|
|
129317
129431
|
function PrintHQChartVersion()
|
|
129318
129432
|
{
|