hqchart 1.1.12898 → 1.1.12900

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.
@@ -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;//集合竞价背景
@@ -12789,7 +12795,7 @@ hisData.Symbol=message.symbol;}var stockObj={HQDataType:HQ_DATA_TYPE.KLINE_ID,St
12789
12795
  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
12796
  * 版本信息输出
12791
12797
  *
12792
- */var HQCHART_VERSION="1.1.12897";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();//把给外界调用的方法暴露出来
12798
+ */var HQCHART_VERSION="1.1.12899";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
12799
  exports.default=(_jsChartInit$jsChartS={jsChartInit:JSChart.Init,jsChartStyle:JSChart.SetStyle,// IsIndexSymbol:IsIndexSymbol,
12794
12800
  // BaseIndex:BaseIndex,
12795
12801
  // ChartLine:ChartLine,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.12898",
3
+ "version": "1.1.12900",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -10093,35 +10093,46 @@ function AverageWidthFrame()
10093
10093
 
10094
10094
  if (item.Message[0]!=null && isDrawLeft)
10095
10095
  {
10096
- if (item.Font!=null) this.Canvas.font=item.Font;
10097
-
10098
- var xText=left;
10099
- if (leftExtendLine && leftExtendLine.Width>1)
10096
+ if (Array.isArray(item.Message[0]))
10100
10097
  {
10101
- var lineLength=leftExtendLine.Width;
10102
- if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
10103
- else this.Canvas.strokeStyle=item.LineColor;
10104
- this.Canvas.beginPath();
10105
- this.Canvas.moveTo(xText,yFixed);
10106
- this.Canvas.lineTo(xText-lineLength,yFixed);
10107
- this.Canvas.stroke();
10108
-
10109
- xText-=lineLength;
10098
+ if (this.MultiTextFormat==3)
10099
+ {
10100
+ var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
10101
+ this.DrawMultiLineText(obj);
10102
+ }
10110
10103
  }
10111
-
10112
- rtLeft=this.GetTextTopBottom(textBaseline,yText);
10113
- if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
10104
+ else
10114
10105
  {
10115
- if (leftExtendText && leftExtendText.Align===1)
10106
+ if (item.Font!=null) this.Canvas.font=item.Font;
10107
+
10108
+ var xText=left;
10109
+ if (leftExtendLine && leftExtendLine.Width>1)
10116
10110
  {
10117
- this.Canvas.textAlign="left";
10118
- this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
10111
+ var lineLength=leftExtendLine.Width;
10112
+ if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
10113
+ else this.Canvas.strokeStyle=item.LineColor;
10114
+ this.Canvas.beginPath();
10115
+ this.Canvas.moveTo(xText,yFixed);
10116
+ this.Canvas.lineTo(xText-lineLength,yFixed);
10117
+ this.Canvas.stroke();
10118
+
10119
+ xText-=lineLength;
10119
10120
  }
10120
- else
10121
+
10122
+ rtLeft=this.GetTextTopBottom(textBaseline,yText);
10123
+ if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
10121
10124
  {
10122
- this.Canvas.textAlign="right";
10123
- this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
10124
- rtPreLeft=rtLeft;
10125
+ if (leftExtendText && leftExtendText.Align===1)
10126
+ {
10127
+ this.Canvas.textAlign="left";
10128
+ this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
10129
+ }
10130
+ else
10131
+ {
10132
+ this.Canvas.textAlign="right";
10133
+ this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
10134
+ rtPreLeft=rtLeft;
10135
+ }
10125
10136
  }
10126
10137
  }
10127
10138
  }
@@ -10188,6 +10199,11 @@ function AverageWidthFrame()
10188
10199
  var lineHeight=this.Canvas.measureText('M').width;
10189
10200
  if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
10190
10201
  }
10202
+ else if (this.MultiTextFormat==3)
10203
+ {
10204
+ var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
10205
+ this.DrawMultiLineText(obj);
10206
+ }
10191
10207
  else //显示第1行
10192
10208
  {
10193
10209
  this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
@@ -10248,6 +10264,65 @@ function AverageWidthFrame()
10248
10264
  }
10249
10265
  }
10250
10266
 
10267
+ //多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
10268
+ this.DrawMultiLineText=function(obj)
10269
+ {
10270
+ var lineSpacing=2;
10271
+ var lineHeight=this.Canvas.measureText('擎').width;
10272
+ var lineCount=obj.Data.length;
10273
+ var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
10274
+ var yText=obj.Y;
10275
+
10276
+ if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
10277
+
10278
+ if (obj.IsLeft)
10279
+ {
10280
+ this.Canvas.textAlign="right";
10281
+ var xText=obj.X-obj.TextPadding;
10282
+ }
10283
+ else
10284
+ {
10285
+ this.Canvas.textAlign="left";
10286
+ var xText=obj.X+obj.TextPadding;
10287
+ }
10288
+
10289
+ var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
10290
+ this.Canvas.textBaseline='top';
10291
+ if (obj.TextBaseLine==1) //middle
10292
+ {
10293
+ yText-=textHeight/2;
10294
+ }
10295
+ else if (obj.TextBaseLine==0) //top
10296
+ {
10297
+
10298
+ }
10299
+ else if (obj.TextBaseLine==2) //bottom
10300
+ {
10301
+ yText-=textHeight;
10302
+ }
10303
+
10304
+
10305
+ for(var i=0;i<obj.Data.length;++i)
10306
+ {
10307
+ var item=obj.Data[i];
10308
+ var text=item.Text;
10309
+
10310
+ var backupTextColor=null;
10311
+ if (item.Color)
10312
+ {
10313
+ backupTextColor=this.Canvas.fillStyle;
10314
+ this.Canvas.fillStyle=item.Color;
10315
+ }
10316
+
10317
+ this.Canvas.fillText(text,xText,yText);
10318
+ yText+=lineHeight+lineSpacing;
10319
+
10320
+ if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
10321
+ }
10322
+
10323
+ this.Canvas.textBaseline=textBaseline; //还原对齐方式
10324
+ }
10325
+
10251
10326
  //上下区域是否重叠
10252
10327
  this.IsTextTopBottomOverlap=function(rt, rt2)
10253
10328
  {
@@ -11457,6 +11532,24 @@ function AverageWidthFrame()
11457
11532
  return null;
11458
11533
  }
11459
11534
 
11535
+ this.GetMulitTextMaxWidth=function(aryData)
11536
+ {
11537
+ var width=null;
11538
+
11539
+ for(var i=0;i<aryData.length;++i)
11540
+ {
11541
+ var item=aryData[i];
11542
+ var text=item.Text;
11543
+ if (!text) continue;
11544
+
11545
+ var value=this.Canvas.measureText(text).width;
11546
+ if (width==null) width=value;
11547
+ else if(width<value) width=value;
11548
+ }
11549
+
11550
+ return width;
11551
+ }
11552
+
11460
11553
  this.GetScaleTextWidth=function()
11461
11554
  {
11462
11555
  var border=this.ChartBorder.GetBorder();
@@ -11502,10 +11595,18 @@ function AverageWidthFrame()
11502
11595
 
11503
11596
  if (item.Message[0]!=null && isDrawLeft)
11504
11597
  {
11505
- textWidth=this.Canvas.measureText(item.Message[0]).width;
11598
+ if (Array.isArray(item.Message[0]))
11599
+ {
11600
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
11601
+ }
11602
+ else
11603
+ {
11604
+ textWidth=this.Canvas.measureText(item.Message[0]).width;
11605
+ }
11606
+
11506
11607
  if (width.Left==null || width.Left<textWidth)
11507
11608
  width.Left=textWidth;
11508
-
11609
+
11509
11610
  //JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
11510
11611
  }
11511
11612
 
@@ -11536,6 +11637,10 @@ function AverageWidthFrame()
11536
11637
  var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
11537
11638
  if (textWidth<textWidth2) textWidth=textWidth2;
11538
11639
  }
11640
+ else if (this.MultiTextFormat==3)
11641
+ {
11642
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
11643
+ }
11539
11644
  else //显示第1行
11540
11645
  {
11541
11646
  textWidth=this.Canvas.measureText(item.Message[1][0]).width;
@@ -14260,35 +14260,46 @@ function AverageWidthFrame()
14260
14260
 
14261
14261
  if (item.Message[0]!=null && isDrawLeft)
14262
14262
  {
14263
- if (item.Font!=null) this.Canvas.font=item.Font;
14264
-
14265
- var xText=left;
14266
- if (leftExtendLine && leftExtendLine.Width>1)
14263
+ if (Array.isArray(item.Message[0]))
14267
14264
  {
14268
- var lineLength=leftExtendLine.Width;
14269
- if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
14270
- else this.Canvas.strokeStyle=item.LineColor;
14271
- this.Canvas.beginPath();
14272
- this.Canvas.moveTo(xText,yFixed);
14273
- this.Canvas.lineTo(xText-lineLength,yFixed);
14274
- this.Canvas.stroke();
14275
-
14276
- xText-=lineLength;
14265
+ if (this.MultiTextFormat==3)
14266
+ {
14267
+ var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
14268
+ this.DrawMultiLineText(obj);
14269
+ }
14277
14270
  }
14278
-
14279
- rtLeft=this.GetTextTopBottom(textBaseline,yText);
14280
- if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
14271
+ else
14281
14272
  {
14282
- if (leftExtendText && leftExtendText.Align===1)
14273
+ if (item.Font!=null) this.Canvas.font=item.Font;
14274
+
14275
+ var xText=left;
14276
+ if (leftExtendLine && leftExtendLine.Width>1)
14283
14277
  {
14284
- this.Canvas.textAlign="left";
14285
- this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
14278
+ var lineLength=leftExtendLine.Width;
14279
+ if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
14280
+ else this.Canvas.strokeStyle=item.LineColor;
14281
+ this.Canvas.beginPath();
14282
+ this.Canvas.moveTo(xText,yFixed);
14283
+ this.Canvas.lineTo(xText-lineLength,yFixed);
14284
+ this.Canvas.stroke();
14285
+
14286
+ xText-=lineLength;
14286
14287
  }
14287
- else
14288
+
14289
+ rtLeft=this.GetTextTopBottom(textBaseline,yText);
14290
+ if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
14288
14291
  {
14289
- this.Canvas.textAlign="right";
14290
- this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
14291
- rtPreLeft=rtLeft;
14292
+ if (leftExtendText && leftExtendText.Align===1)
14293
+ {
14294
+ this.Canvas.textAlign="left";
14295
+ this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
14296
+ }
14297
+ else
14298
+ {
14299
+ this.Canvas.textAlign="right";
14300
+ this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
14301
+ rtPreLeft=rtLeft;
14302
+ }
14292
14303
  }
14293
14304
  }
14294
14305
  }
@@ -14355,6 +14366,11 @@ function AverageWidthFrame()
14355
14366
  var lineHeight=this.Canvas.measureText('M').width;
14356
14367
  if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
14357
14368
  }
14369
+ else if (this.MultiTextFormat==3)
14370
+ {
14371
+ var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
14372
+ this.DrawMultiLineText(obj);
14373
+ }
14358
14374
  else //显示第1行
14359
14375
  {
14360
14376
  this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
@@ -14415,6 +14431,65 @@ function AverageWidthFrame()
14415
14431
  }
14416
14432
  }
14417
14433
 
14434
+ //多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
14435
+ this.DrawMultiLineText=function(obj)
14436
+ {
14437
+ var lineSpacing=2;
14438
+ var lineHeight=this.Canvas.measureText('擎').width;
14439
+ var lineCount=obj.Data.length;
14440
+ var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
14441
+ var yText=obj.Y;
14442
+
14443
+ if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
14444
+
14445
+ if (obj.IsLeft)
14446
+ {
14447
+ this.Canvas.textAlign="right";
14448
+ var xText=obj.X-obj.TextPadding;
14449
+ }
14450
+ else
14451
+ {
14452
+ this.Canvas.textAlign="left";
14453
+ var xText=obj.X+obj.TextPadding;
14454
+ }
14455
+
14456
+ var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
14457
+ this.Canvas.textBaseline='top';
14458
+ if (obj.TextBaseLine==1) //middle
14459
+ {
14460
+ yText-=textHeight/2;
14461
+ }
14462
+ else if (obj.TextBaseLine==0) //top
14463
+ {
14464
+
14465
+ }
14466
+ else if (obj.TextBaseLine==2) //bottom
14467
+ {
14468
+ yText-=textHeight;
14469
+ }
14470
+
14471
+
14472
+ for(var i=0;i<obj.Data.length;++i)
14473
+ {
14474
+ var item=obj.Data[i];
14475
+ var text=item.Text;
14476
+
14477
+ var backupTextColor=null;
14478
+ if (item.Color)
14479
+ {
14480
+ backupTextColor=this.Canvas.fillStyle;
14481
+ this.Canvas.fillStyle=item.Color;
14482
+ }
14483
+
14484
+ this.Canvas.fillText(text,xText,yText);
14485
+ yText+=lineHeight+lineSpacing;
14486
+
14487
+ if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
14488
+ }
14489
+
14490
+ this.Canvas.textBaseline=textBaseline; //还原对齐方式
14491
+ }
14492
+
14418
14493
  //上下区域是否重叠
14419
14494
  this.IsTextTopBottomOverlap=function(rt, rt2)
14420
14495
  {
@@ -15624,6 +15699,24 @@ function AverageWidthFrame()
15624
15699
  return null;
15625
15700
  }
15626
15701
 
15702
+ this.GetMulitTextMaxWidth=function(aryData)
15703
+ {
15704
+ var width=null;
15705
+
15706
+ for(var i=0;i<aryData.length;++i)
15707
+ {
15708
+ var item=aryData[i];
15709
+ var text=item.Text;
15710
+ if (!text) continue;
15711
+
15712
+ var value=this.Canvas.measureText(text).width;
15713
+ if (width==null) width=value;
15714
+ else if(width<value) width=value;
15715
+ }
15716
+
15717
+ return width;
15718
+ }
15719
+
15627
15720
  this.GetScaleTextWidth=function()
15628
15721
  {
15629
15722
  var border=this.ChartBorder.GetBorder();
@@ -15669,10 +15762,18 @@ function AverageWidthFrame()
15669
15762
 
15670
15763
  if (item.Message[0]!=null && isDrawLeft)
15671
15764
  {
15672
- textWidth=this.Canvas.measureText(item.Message[0]).width;
15765
+ if (Array.isArray(item.Message[0]))
15766
+ {
15767
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
15768
+ }
15769
+ else
15770
+ {
15771
+ textWidth=this.Canvas.measureText(item.Message[0]).width;
15772
+ }
15773
+
15673
15774
  if (width.Left==null || width.Left<textWidth)
15674
15775
  width.Left=textWidth;
15675
-
15776
+
15676
15777
  //JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
15677
15778
  }
15678
15779
 
@@ -15703,6 +15804,10 @@ function AverageWidthFrame()
15703
15804
  var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
15704
15805
  if (textWidth<textWidth2) textWidth=textWidth2;
15705
15806
  }
15807
+ else if (this.MultiTextFormat==3)
15808
+ {
15809
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
15810
+ }
15706
15811
  else //显示第1行
15707
15812
  {
15708
15813
  textWidth=this.Canvas.measureText(item.Message[1][0]).width;
@@ -129154,7 +129259,7 @@ function ScrollBarBGChart()
129154
129259
 
129155
129260
 
129156
129261
 
129157
- var HQCHART_VERSION="1.1.12897";
129262
+ var HQCHART_VERSION="1.1.12899";
129158
129263
 
129159
129264
  function PrintHQChartVersion()
129160
129265
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.12897";
8
+ var HQCHART_VERSION="1.1.12899";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {
@@ -14304,35 +14304,46 @@ function AverageWidthFrame()
14304
14304
 
14305
14305
  if (item.Message[0]!=null && isDrawLeft)
14306
14306
  {
14307
- if (item.Font!=null) this.Canvas.font=item.Font;
14308
-
14309
- var xText=left;
14310
- if (leftExtendLine && leftExtendLine.Width>1)
14307
+ if (Array.isArray(item.Message[0]))
14311
14308
  {
14312
- var lineLength=leftExtendLine.Width;
14313
- if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
14314
- else this.Canvas.strokeStyle=item.LineColor;
14315
- this.Canvas.beginPath();
14316
- this.Canvas.moveTo(xText,yFixed);
14317
- this.Canvas.lineTo(xText-lineLength,yFixed);
14318
- this.Canvas.stroke();
14319
-
14320
- xText-=lineLength;
14309
+ if (this.MultiTextFormat==3)
14310
+ {
14311
+ var obj={ Data:item.Message[0], X:left, Y:yText, TextBaseLine:textBaseline, IsLeft:true, Item:item, TextPadding:this.YTextPadding[0] };
14312
+ this.DrawMultiLineText(obj);
14313
+ }
14321
14314
  }
14322
-
14323
- rtLeft=this.GetTextTopBottom(textBaseline,yText);
14324
- if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
14315
+ else
14325
14316
  {
14326
- if (leftExtendText && leftExtendText.Align===1)
14317
+ if (item.Font!=null) this.Canvas.font=item.Font;
14318
+
14319
+ var xText=left;
14320
+ if (leftExtendLine && leftExtendLine.Width>1)
14327
14321
  {
14328
- this.Canvas.textAlign="left";
14329
- this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
14322
+ var lineLength=leftExtendLine.Width;
14323
+ if (leftExtendLine.Color) this.Canvas.strokeStyle=leftExtendLine.Color;
14324
+ else this.Canvas.strokeStyle=item.LineColor;
14325
+ this.Canvas.beginPath();
14326
+ this.Canvas.moveTo(xText,yFixed);
14327
+ this.Canvas.lineTo(xText-lineLength,yFixed);
14328
+ this.Canvas.stroke();
14329
+
14330
+ xText-=lineLength;
14330
14331
  }
14331
- else
14332
+
14333
+ rtLeft=this.GetTextTopBottom(textBaseline,yText);
14334
+ if (!rtPreLeft || (rtLeft && !this.IsTextTopBottomOverlap(rtLeft, rtPreLeft)))
14332
14335
  {
14333
- this.Canvas.textAlign="right";
14334
- this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
14335
- rtPreLeft=rtLeft;
14336
+ if (leftExtendText && leftExtendText.Align===1)
14337
+ {
14338
+ this.Canvas.textAlign="left";
14339
+ this.Canvas.fillText(item.Message[0],this.YTextPadding[0],yText);
14340
+ }
14341
+ else
14342
+ {
14343
+ this.Canvas.textAlign="right";
14344
+ this.Canvas.fillText(item.Message[0],xText-this.YTextPadding[0],yText);
14345
+ rtPreLeft=rtLeft;
14346
+ }
14336
14347
  }
14337
14348
  }
14338
14349
  }
@@ -14399,6 +14410,11 @@ function AverageWidthFrame()
14399
14410
  var lineHeight=this.Canvas.measureText('M').width;
14400
14411
  if (itemHeight>lineHeight*2) this.Canvas.fillText(item.Message[1][1],xText+this.YTextPadding[1],yText+lineHeight);
14401
14412
  }
14413
+ else if (this.MultiTextFormat==3)
14414
+ {
14415
+ var obj={ Data:item.Message[1], X:xText, Y:yText, TextBaseLine:textBaseline, IsLeft:false, Item:item, TextPadding:this.YTextPadding[1] };
14416
+ this.DrawMultiLineText(obj);
14417
+ }
14402
14418
  else //显示第1行
14403
14419
  {
14404
14420
  this.Canvas.fillText(item.Message[1][0],xText+this.YTextPadding[1],yText);
@@ -14459,6 +14475,65 @@ function AverageWidthFrame()
14459
14475
  }
14460
14476
  }
14461
14477
 
14478
+ //多行文字刻度输出 obj={ Data:, X:, Y:, TextBaseLine:, IsLeft:, Item:刻度数据 }
14479
+ this.DrawMultiLineText=function(obj)
14480
+ {
14481
+ var lineSpacing=2;
14482
+ var lineHeight=this.Canvas.measureText('擎').width;
14483
+ var lineCount=obj.Data.length;
14484
+ var textHeight=lineHeight*lineCount+(lineSpacing*(lineCount-1));
14485
+ var yText=obj.Y;
14486
+
14487
+ if (obj.Item.Font!=null) this.Canvas.font=obj.Item.Font;
14488
+
14489
+ if (obj.IsLeft)
14490
+ {
14491
+ this.Canvas.textAlign="right";
14492
+ var xText=obj.X-obj.TextPadding;
14493
+ }
14494
+ else
14495
+ {
14496
+ this.Canvas.textAlign="left";
14497
+ var xText=obj.X+obj.TextPadding;
14498
+ }
14499
+
14500
+ var textBaseline=this.Canvas.textBaseline; //备份下原来的对齐方式
14501
+ this.Canvas.textBaseline='top';
14502
+ if (obj.TextBaseLine==1) //middle
14503
+ {
14504
+ yText-=textHeight/2;
14505
+ }
14506
+ else if (obj.TextBaseLine==0) //top
14507
+ {
14508
+
14509
+ }
14510
+ else if (obj.TextBaseLine==2) //bottom
14511
+ {
14512
+ yText-=textHeight;
14513
+ }
14514
+
14515
+
14516
+ for(var i=0;i<obj.Data.length;++i)
14517
+ {
14518
+ var item=obj.Data[i];
14519
+ var text=item.Text;
14520
+
14521
+ var backupTextColor=null;
14522
+ if (item.Color)
14523
+ {
14524
+ backupTextColor=this.Canvas.fillStyle;
14525
+ this.Canvas.fillStyle=item.Color;
14526
+ }
14527
+
14528
+ this.Canvas.fillText(text,xText,yText);
14529
+ yText+=lineHeight+lineSpacing;
14530
+
14531
+ if (backupTextColor) this.Canvas.fillStyle=backupTextColor;
14532
+ }
14533
+
14534
+ this.Canvas.textBaseline=textBaseline; //还原对齐方式
14535
+ }
14536
+
14462
14537
  //上下区域是否重叠
14463
14538
  this.IsTextTopBottomOverlap=function(rt, rt2)
14464
14539
  {
@@ -15668,6 +15743,24 @@ function AverageWidthFrame()
15668
15743
  return null;
15669
15744
  }
15670
15745
 
15746
+ this.GetMulitTextMaxWidth=function(aryData)
15747
+ {
15748
+ var width=null;
15749
+
15750
+ for(var i=0;i<aryData.length;++i)
15751
+ {
15752
+ var item=aryData[i];
15753
+ var text=item.Text;
15754
+ if (!text) continue;
15755
+
15756
+ var value=this.Canvas.measureText(text).width;
15757
+ if (width==null) width=value;
15758
+ else if(width<value) width=value;
15759
+ }
15760
+
15761
+ return width;
15762
+ }
15763
+
15671
15764
  this.GetScaleTextWidth=function()
15672
15765
  {
15673
15766
  var border=this.ChartBorder.GetBorder();
@@ -15713,10 +15806,18 @@ function AverageWidthFrame()
15713
15806
 
15714
15807
  if (item.Message[0]!=null && isDrawLeft)
15715
15808
  {
15716
- textWidth=this.Canvas.measureText(item.Message[0]).width;
15809
+ if (Array.isArray(item.Message[0]))
15810
+ {
15811
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
15812
+ }
15813
+ else
15814
+ {
15815
+ textWidth=this.Canvas.measureText(item.Message[0]).width;
15816
+ }
15817
+
15717
15818
  if (width.Left==null || width.Left<textWidth)
15718
15819
  width.Left=textWidth;
15719
-
15820
+
15720
15821
  //JSConsole.Chart.Log(`[ChartData::GetScaleTextWidth] ${item.Message[0]} ${textWidth}`);
15721
15822
  }
15722
15823
 
@@ -15747,6 +15848,10 @@ function AverageWidthFrame()
15747
15848
  var textWidth2=this.Canvas.measureText(item.Message[1][1]).width;
15748
15849
  if (textWidth<textWidth2) textWidth=textWidth2;
15749
15850
  }
15851
+ else if (this.MultiTextFormat==3)
15852
+ {
15853
+ textWidth=this.GetMulitTextMaxWidth(item.Message[0]);
15854
+ }
15750
15855
  else //显示第1行
15751
15856
  {
15752
15857
  textWidth=this.Canvas.measureText(item.Message[1][0]).width;
@@ -129312,7 +129417,7 @@ function HQChartScriptWorker()
129312
129417
 
129313
129418
 
129314
129419
 
129315
- var HQCHART_VERSION="1.1.12897";
129420
+ var HQCHART_VERSION="1.1.12899";
129316
129421
 
129317
129422
  function PrintHQChartVersion()
129318
129423
  {