hqchart 1.1.13754 → 1.1.13760
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
|
@@ -6080,15 +6080,16 @@ this.LineWidth=1;this.Precision=2;//小数位数
|
|
|
6080
6080
|
this.ValueTextColor='rgb(250,250,250)';this.IsShowCorssCursor=true;//画的时候是否显示十字光标
|
|
6081
6081
|
this.GetLabelCallback;//绘制标题回调函数
|
|
6082
6082
|
this.PointCount=1;this.ClassName='ChartDrawHLine';this.Font=14*GetDevicePixelRatio()+"px 微软雅黑";this.TextFont=12*GetDevicePixelRatio()+"px 微软雅黑";this.RightSpaceWidth=50;this.ButtonPosition=0;//按钮位置, 0=价格后面, 1=价格上面 2=价格上面 左对齐 3=垂直排列
|
|
6083
|
-
this.ButtonBGColor='rgb(190,190,190)';this.ButtonSpace=3;this.TextMargin={Left:0,Right:0};this.AlwaysShowLab=false;//总是显示标签
|
|
6083
|
+
this.ButtonBGColor='rgb(190,190,190)';this.ButtonSpace=3;this.TextMargin={Left:0,Right:0,Top:0,Bottom:0,YOffset:4*GetDevicePixelRatio()};this.AlwaysShowLab=false;//总是显示标签
|
|
6084
6084
|
this.Button={CloseIcon:{Text:'\uE62B',Color:'rgb(255,255,255)',Family:"iconfont",Size:16,ID:JSCHART_BUTTON_ID.DRAW_PICTURE_DELETE,TooltipText:null,Margin:{Left:2,Right:2}},SettingIcon:{Text:'\uE623',Color:'rgb(255,255,255)',Family:"iconfont",Size:16,ID:JSCHART_BUTTON_ID.DRAW_PICTURE_SETTING,TooltipText:null,Margin:{Left:2,Right:2}//修改ID, Text , TooltipText 可以外部定制按钮
|
|
6085
6085
|
}};this.CustomButton=[];//自定义的按钮 { Text:'\ue62b', Color:'rgb(255,255,255)', Family:"iconfont", Size:16, ID:JSCHART_BUTTON_ID.DRAW_PICTURE_BUTTON_1, TooltipText:null, Data:null }
|
|
6086
6086
|
this.AryShowButton=[];//需要显示的按钮 { Data:, Width }
|
|
6087
6087
|
this.AryButton=[];this.ExtendData;//扩展数据
|
|
6088
6088
|
this.ShowPriceTextConfig={IsShow:[false,false,true],//[0]=left内 [1]=right内 [2]=right外
|
|
6089
|
-
Font:[12*GetDevicePixelRatio()+'px \u5FAE\u8F6F\u96C5\u9ED1',12*GetDevicePixelRatio()+'px \u5FAE\u8F6F\u96C5\u9ED1']}
|
|
6089
|
+
Font:[12*GetDevicePixelRatio()+'px \u5FAE\u8F6F\u96C5\u9ED1',12*GetDevicePixelRatio()+'px \u5FAE\u8F6F\u96C5\u9ED1']};this.LableInfo;//{ Position:2=右侧外部 }
|
|
6090
|
+
//内部变量
|
|
6090
6091
|
this.ColseButtonSize=0;this.SettingButtonSize=0;this.ButtonBGWidth=0;this.VerticalButtonInfo={Width:0,Height:0};//垂直按钮信息
|
|
6091
|
-
this.SetOption=function(option){if(this.Super_SetOption)this.Super_SetOption(option);if(option){if(option.GetLabelCallback){this.GetLabelCallback=option.GetLabelCallback;}if(IFrameSplitOperator.IsNumber(option.Precision))this.Precision=option.Precision;if(option.Font)this.Font=option.Font;if(option.ValueTextColor)this.ValueTextColor=option.ValueTextColor;if(option.ButtonBGColor)this.ButtonBGColor=option.ButtonBGColor;if(IFrameSplitOperator.IsNumber(option.ButtonPosition))this.ButtonPosition=option.ButtonPosition;if(IFrameSplitOperator.IsNumber(option.RightSpaceWidth))this.RightSpaceWidth=option.RightSpaceWidth;if(IFrameSplitOperator.IsBool(option.AlwaysShowLab))this.AlwaysShowLab=option.AlwaysShowLab;if(option.Button){var item=option.Button;if(item.CloseIcon){this.Button.CloseIcon=CloneData(item.CloseIcon);if(!this.Button.CloseIcon.ID)this.Button.CloseIcon.ID=JSCHART_BUTTON_ID.DRAW_PICTURE_DELETE;}else if(item.CloseIcon===null){this.Button.CloseIcon=null;}if(item.SettingIcon){this.Button.SettingIcon=CloneData(item.SettingIcon);if(!this.Button.SettingIcon.ID)this.Button.SettingIcon.ID=JSCHART_BUTTON_ID.DRAW_PICTURE_SETTING;}else if(item.SettingIcon===null){this.Button.SettingIcon=null;}}if(option.ExtendData)this.ExtendData=option.ExtendData;if(IFrameSplitOperator.IsNonEmptyArray(option.IsShowPriceText)){for(var i=0;i<option.IsShowPriceText.length&&i<3;++i){var value=option.IsShowPriceText[i];if(IFrameSplitOperator.IsBool(value))this.ShowPriceTextConfig.IsShow[i]=value;}}if(option.TextMargin){var item=option.TextMargin;if(IFrameSplitOperator.IsNumber(item.Left))this.TextMargin.Left=item.Left;if(IFrameSplitOperator.IsNumber(item.Right))this.TextMargin.Right=item.Right;}}};this.ExportStorageData=function(){var storageData;if(this.Super_ExportStorageData){storageData=this.Super_ExportStorageData();if(this.Label)storageData.Label=this.Label;}return storageData;}
|
|
6092
|
+
this.IsPointIn=this.IsPointIn_XYValue_Line;this.SetOption=function(option){if(this.Super_SetOption)this.Super_SetOption(option);if(option){if(option.GetLabelCallback){this.GetLabelCallback=option.GetLabelCallback;}if(IFrameSplitOperator.IsNumber(option.Precision))this.Precision=option.Precision;if(option.Font)this.Font=option.Font;if(option.ValueTextColor)this.ValueTextColor=option.ValueTextColor;if(option.ButtonBGColor)this.ButtonBGColor=option.ButtonBGColor;if(IFrameSplitOperator.IsNumber(option.ButtonPosition))this.ButtonPosition=option.ButtonPosition;if(IFrameSplitOperator.IsNumber(option.RightSpaceWidth))this.RightSpaceWidth=option.RightSpaceWidth;if(IFrameSplitOperator.IsBool(option.AlwaysShowLab))this.AlwaysShowLab=option.AlwaysShowLab;if(option.Button){var item=option.Button;if(item.CloseIcon){this.Button.CloseIcon=CloneData(item.CloseIcon);if(!this.Button.CloseIcon.ID)this.Button.CloseIcon.ID=JSCHART_BUTTON_ID.DRAW_PICTURE_DELETE;}else if(item.CloseIcon===null){this.Button.CloseIcon=null;}if(item.SettingIcon){this.Button.SettingIcon=CloneData(item.SettingIcon);if(!this.Button.SettingIcon.ID)this.Button.SettingIcon.ID=JSCHART_BUTTON_ID.DRAW_PICTURE_SETTING;}else if(item.SettingIcon===null){this.Button.SettingIcon=null;}}if(option.ExtendData)this.ExtendData=option.ExtendData;if(IFrameSplitOperator.IsNonEmptyArray(option.IsShowPriceText)){for(var i=0;i<option.IsShowPriceText.length&&i<3;++i){var value=option.IsShowPriceText[i];if(IFrameSplitOperator.IsBool(value))this.ShowPriceTextConfig.IsShow[i]=value;}}if(option.TextMargin){var item=option.TextMargin;if(IFrameSplitOperator.IsNumber(item.Left))this.TextMargin.Left=item.Left;if(IFrameSplitOperator.IsNumber(item.Right))this.TextMargin.Right=item.Right;if(IFrameSplitOperator.IsNumber(item.Top))this.TextMargin.Top=item.Top;if(IFrameSplitOperator.IsNumber(item.Bottom))this.TextMargin.Bottom=item.Bottom;if(IFrameSplitOperator.IsNumber(item.YOffset))this.TextMargin.YOffset=item.YOffset;}}};this.ExportStorageData=function(){var storageData;if(this.Super_ExportStorageData){storageData=this.Super_ExportStorageData();if(this.Label)storageData.Label=this.Label;}return storageData;};/*
|
|
6092
6093
|
this.GetXYCoordinate=function()
|
|
6093
6094
|
{
|
|
6094
6095
|
if (this.IsFrameMinSize()) return null;
|
|
@@ -6098,21 +6099,24 @@ this.SetOption=function(option){if(this.Super_SetOption)this.Super_SetOption(opt
|
|
|
6098
6099
|
}
|
|
6099
6100
|
*/this.IsDrawMain=function()//选中绘制在动态绘图上, 没有选中绘制在背景上
|
|
6100
6101
|
{if(!this.GetActiveDrawPicture)return true;var active=this.GetActiveDrawPicture();if(active.Select.Guid==this.Guid)return false;return true;};this.MainDraw=function(){this.Draw();};//获取需要显示的按钮 系统按钮+自定义按钮
|
|
6101
|
-
this.GetShowButton=function(){var aryButton=[];var item=this.Button.SettingIcon;if(item&&item.Text)aryButton.push({Data:item,Width:null});item=this.Button.CloseIcon;if(item&&item.Text)aryButton.push({Data:item,Width:null});if(IFrameSplitOperator.IsNonEmptyArray(this.CustomButton)){for(var i=0;i<this.CustomButton.length;++i){item=this.CustomButton[i];if(item&&item.Text)aryButton.push({Data:item,Width:null});}}return aryButton;};this.Draw=function(moveonPoint,mouseStatus){this.AryShowButton=[];this.LinePoint=[];this.AryButton=[];this.ColseButtonSize=0;this.SettingButtonSize=0;this.ButtonBGWidth=0;this.VerticalButtonInfo.Width=0;this.VerticalButtonInfo.Height=0;if(this.IsFrameMinSize())return;if(!this.IsShow)return;var drawPoint=this.CalculateDrawPoint();if(!drawPoint||drawPoint.length!=1)return;if(!this.Frame)return;if(this.Value.length!=1)return;var bVisibleRange=this.IsYValueInFrame(this.Value[0].YValue);//是否在可视范围
|
|
6102
|
+
this.GetShowButton=function(){var aryButton=[];var item=this.Button.SettingIcon;if(item&&item.Text)aryButton.push({Data:item,Width:null});item=this.Button.CloseIcon;if(item&&item.Text)aryButton.push({Data:item,Width:null});if(IFrameSplitOperator.IsNonEmptyArray(this.CustomButton)){for(var i=0;i<this.CustomButton.length;++i){item=this.CustomButton[i];if(item&&item.Text)aryButton.push({Data:item,Width:null});}}return aryButton;};this.Draw=function(moveonPoint,mouseStatus){this.AryShowButton=[];this.LinePoint=[];this.AryButton=[];this.ColseButtonSize=0;this.SettingButtonSize=0;this.ButtonBGWidth=0;this.LableInfo=null;this.VerticalButtonInfo.Width=0;this.VerticalButtonInfo.Height=0;if(this.IsFrameMinSize())return;if(!this.IsShow)return;var drawPoint=this.CalculateDrawPoint();if(!drawPoint||drawPoint.length!=1)return;if(!this.Frame)return;if(this.Value.length!=1)return;var bVisibleRange=this.IsYValueInFrame(this.Value[0].YValue);//是否在可视范围
|
|
6102
6103
|
if(!this.AlwaysShowLab&&!bVisibleRange)return;var isHScreen=this.Frame.IsHScreen;var left=this.Frame.ChartBorder.GetLeft();var right=this.Frame.ChartBorder.GetRight();if(isHScreen){left=this.Frame.ChartBorder.GetTop();right=this.Frame.ChartBorder.GetBottom();}this.ClipFrame();//画线段
|
|
6103
6104
|
if(bVisibleRange){this.Canvas.strokeStyle=this.LineColor;this.SetLineWidth();this.Canvas.beginPath();if(isHScreen){this.Canvas.moveTo(drawPoint[0].X,left);this.Canvas.lineTo(drawPoint[0].X,right);}else{this.Canvas.moveTo(left,ToFixedPoint(drawPoint[0].Y));this.Canvas.lineTo(right,ToFixedPoint(drawPoint[0].Y));}this.Canvas.stroke();this.RestoreLineWidth();}//画水平线段
|
|
6104
|
-
var line={Start:new Point(),End:new Point()};if(isHScreen){line.Start.X=drawPoint[0].X;line.Start.Y=left;line.End.X=drawPoint[0].X;line.End.Y=right;}else{line.Start.X=left;line.Start.Y=drawPoint[0].Y;line.End.X=right;line.End.Y=drawPoint[0].Y;}this.LinePoint.push(line);if(bVisibleRange)
|
|
6105
|
-
|
|
6106
|
-
if(
|
|
6105
|
+
var line={Start:new Point(),End:new Point()};if(isHScreen){line.Start.X=drawPoint[0].X;line.Start.Y=left;line.End.X=drawPoint[0].X;line.End.Y=right;}else{line.Start.X=left;line.Start.Y=drawPoint[0].Y;line.End.X=right;line.End.Y=drawPoint[0].Y;}this.LinePoint.push(line);if(bVisibleRange)//在可视范围内
|
|
6106
|
+
{var yValue=this.Frame.GetYData(drawPoint[0].Y,false);var strPrice=yValue.toFixed(this.Precision);if(this.ShowPriceTextConfig.IsShow[0]){this.DrawPriceText(strPrice,line.Start,line.End,0);}if(this.ShowPriceTextConfig.IsShow[1]){this.DrawPriceText(strPrice,line.Start,line.End,1);}}if(this.GetLabelCallback)this.LableInfo=this.GetLabelCallback(this);this.AryShowButton=this.GetShowButton();//获取按钮
|
|
6107
|
+
if(bVisibleRange)this.DrawInternalLabel(drawPoint[0].Y);//内部价格标签
|
|
6108
|
+
//画中心点
|
|
6107
6109
|
if(bVisibleRange){var xCenter=left+(right-left)/2;var point={X:xCenter,Y:drawPoint[0].Y};this.DrawPoint([point]);}this.Canvas.restore();//外部右侧显示价格
|
|
6108
|
-
if(this.ShowPriceTextConfig.IsShow[2]){var rtDraw={};this.CalculateButtonSize();this.
|
|
6109
|
-
if(moveonPoint&&mouseStatus){for(var i=0;i<this.AryButton.length;++i){var item=this.AryButton[i];var rtButton=item.Rect;if(moveonPoint.X>=rtButton.Left&&moveonPoint.X<rtButton.Right&&moveonPoint.Y>=rtButton.Top&&moveonPoint.Y<=rtButton.Bottom){mouseStatus.MouseOnToolbar={Rect:rtButton,Item:item,Frame:this.Frame,Point:{X:moveonPoint.X,Y:moveonPoint.Y}};break;}}}};this.CalculateLabSize=function(labInfo){this.Canvas.textAlign="left";this.Canvas.textBaseline="top";this.Canvas.font=this.TextFont;var lineHeight=this.Canvas.measureText("擎").width+2;var maxNameWidth=0,maxTextWidth=0;var lineCount=0;var lineSpace=0;if(IFrameSplitOperator.IsNumber(labInfo.LineSpace))lineSpace=labInfo.LineSpace;var maxNameWidth=0,maxTextWidth=0;var lineCount=0;var maxWidth=0;for(var i=0;i<labInfo.AryText.length;++i){var item=labInfo.AryText[i];item.NameWidth=0;item.TextWidth=0;if(item.Name)item.NameWidth=this.Canvas.measureText(item.Name).width+2;if(item.Text)item.TextWidth=this.Canvas.measureText(item.Text).width+2;if(maxNameWidth<item.NameWidth)maxNameWidth=item.NameWidth;if(maxTextWidth<item.TextWidth)maxTextWidth=item.TextWidth;var itemWidth=item.NameWidth+item.TextWidth;if(maxWidth<itemWidth)maxWidth=itemWidth;++lineCount;}var size={Width:maxWidth,Height:lineCount*
|
|
6110
|
-
|
|
6111
|
-
|
|
6110
|
+
if(this.ShowPriceTextConfig.IsShow[2]){var rtDraw={};this.CalculateButtonSize();this.DrawRightLabel(drawPoint[0].Y);if(bVisibleRange)this.DrawCustomHLine(drawPoint[0].Y);}//鼠标是否在按钮上
|
|
6111
|
+
if(moveonPoint&&mouseStatus){for(var i=0;i<this.AryButton.length;++i){var item=this.AryButton[i];var rtButton=item.Rect;if(moveonPoint.X>=rtButton.Left&&moveonPoint.X<rtButton.Right&&moveonPoint.Y>=rtButton.Top&&moveonPoint.Y<=rtButton.Bottom){mouseStatus.MouseOnToolbar={Rect:rtButton,Item:item,Frame:this.Frame,Point:{X:moveonPoint.X,Y:moveonPoint.Y}};break;}}}};this.CalculateLabSize=function(labInfo){this.Canvas.textAlign="left";this.Canvas.textBaseline="top";this.Canvas.font=this.TextFont;var lineHeight=this.Canvas.measureText("擎").width+2;var maxNameWidth=0,maxTextWidth=0;var lineCount=0;var lineSpace=0;if(IFrameSplitOperator.IsNumber(labInfo.LineSpace))lineSpace=labInfo.LineSpace;var maxNameWidth=0,maxTextWidth=0;var lineCount=0;var maxWidth=0;for(var i=0;i<labInfo.AryText.length;++i){var item=labInfo.AryText[i];item.NameWidth=0;item.TextWidth=0;if(item.Name)item.NameWidth=this.Canvas.measureText(item.Name).width+2;if(item.Text)item.TextWidth=this.Canvas.measureText(item.Text).width+2;if(maxNameWidth<item.NameWidth)maxNameWidth=item.NameWidth;if(maxTextWidth<item.TextWidth)maxTextWidth=item.TextWidth;var itemWidth=item.NameWidth+item.TextWidth;if(maxWidth<itemWidth)maxWidth=itemWidth;++lineCount;}var size={Width:maxWidth,Height:lineCount*lineHeight+(lineCount-1)*lineSpace,NameWidth:maxNameWidth,TextWidth:maxTextWidth,LineHeight:lineHeight};if(labInfo.LabelMargin){var item=labInfo.LabelMargin;if(IFrameSplitOperator.IsNumber(item.Left))size.Width+=item.Left;if(IFrameSplitOperator.IsNumber(item.Right))size.Width+=item.Right;if(IFrameSplitOperator.IsNumber(item.Top))size.Height+=item.Top;if(IFrameSplitOperator.IsNumber(item.Bottom))size.Height+=item.Bottom;}return size;};//绘制窗口内部标签
|
|
6112
|
+
this.DrawInternalLabel=function(y){if(!this.LableInfo||!IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText))return;if(this.LableInfo.Position==2)return;var border=this.Frame.GetBorder();var left=border.Left;var right=border.Right;var labSize=this.CalculateLabSize(this.LableInfo);var drawLeft=right-labSize.Width;var drawRight=drawLeft+labSize.Width;var drawTop=y-labSize.Height-1;if(drawTop<=border.TopEx)drawTop=y+1;var rtLabel={Left:drawLeft,Right:drawRight,Top:drawTop,Width:labSize.Width,Height:labSize.Height};rtLabel.Bottom=rtLabel.Top+rtLabel.Height;this.DrawLabel(this.LableInfo,labSize,rtLabel);};//绘制标签页
|
|
6113
|
+
this.DrawLabel=function(labelInfo,labelSize,rtLabel){//背景色
|
|
6114
|
+
if(labelInfo.BGColor){this.Canvas.fillStyle=labelInfo.BGColor;this.Canvas.fillRect(ToFixedRect(rtLabel.Left),ToFixedRect(rtLabel.Top),ToFixedRect(rtLabel.Width),ToFixedRect(rtLabel.Height));}var labelMargin=labelInfo.LabelMargin;var lineSpace=0;if(IFrameSplitOperator.IsNumber(labelInfo.LineSpace))lineSpace=labelInfo.LineSpace;var yText=rtLabel.Top;var xText=rtLabel.Left;var yRightText=rtLabel.Right;if(labelMargin){if(IFrameSplitOperator.IsNumber(labelMargin.Left))xText+=labelMargin.Left;if(IFrameSplitOperator.IsNumber(labelMargin.Right))yRightText-=labelMargin.Right;if(IFrameSplitOperator.IsNumber(labelMargin.Top))yText+=labelMargin.Top;}this.Canvas.font=this.TextFont;this.Canvas.textBaseline="top";for(var i=0;i<labelInfo.AryText.length;++i){if(i>0)yText+=lineSpace;var item=labelInfo.AryText[i];if(item.Name){this.Canvas.textAlign="left";this.Canvas.fillStyle=item.NameColor;this.Canvas.fillText(item.Name,xText,yText);}if(item.Text){this.Canvas.textAlign="right";this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(item.Text,yRightText,yText);}yText+=labelSize.LineHeight;}};this.DrawRightLabel=function(y){var rtDraw={};if(!this.LableInfo||!IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText)||this.LableInfo.Position!=2){this.DrawValueText(y,rtDraw);return;}var priceSize=this.CalculateValueText(y);var labSize=this.CalculateLabSize(this.LableInfo);var border=this.Frame.GetBorder();var yTop=y-priceSize.Height/2;var totalHeight=priceSize.Height+labSize.Height;var yBottom=yTop+totalHeight;var option={};if(yBottom>border.Bottom)//超过窗口底部, 标签位置不动
|
|
6115
|
+
{yBottom=border.Bottom;yTop=yBottom-totalHeight;option.Top=yTop;}this.DrawValueText(y,rtDraw,option);var drawLeft=rtDraw.Right-labSize.Width;if(drawLeft<rtDraw.Left)drawLeft=rtDraw.Left;var drawRight=drawLeft+labSize.Width;var drawTop=rtDraw.Bottom;var rtLabel={Left:drawLeft,Right:drawRight,Top:drawTop,Width:labSize.Width,Height:labSize.Height};rtLabel.Bottom=rtLabel.Top+rtLabel.Height;this.DrawLabel(this.LableInfo,labSize,rtLabel);this.DrawVerticalButton(rtLabel);};this.DrawCustomHLine=function(yLine){if(!this.LableInfo)return;if(!IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryLine))return;var left=this.Frame.ChartBorder.GetLeft();var right=this.Frame.ChartBorder.GetRight();var pixelRatio=GetDevicePixelRatio();var yMax=yLine,yMin=yLine;for(var i=0;i<this.LableInfo.AryLine.length;++i){var item=this.LableInfo.AryLine[i];if(!IFrameSplitOperator.IsNumber(item.Value))continue;if(item.Width<0)continue;var y=this.Frame.GetYFromData(item.Value);var yFixed=ToFixedPoint(y);var xRight=right;if(IFrameSplitOperator.IsPlusNumber(item.Width)){if(item.Width<1)xRight=left+item.Width*(right-left);//0.3 百分比
|
|
6112
6116
|
else xRight=left+item.Width*pixelRatio;//>1 实际数值就是长度
|
|
6113
|
-
}if(item.Color)this.Canvas.strokeStyle=item.Color;else this.Canvas.strokeStyle=this.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(left,yFixed);this.Canvas.lineTo(xRight,yFixed);this.Canvas.stroke();if(yMax<yFixed)yMax=yFixed;if(yMin>yFixed)yMin=yFixed;}if(yMax!=yMin&&
|
|
6114
|
-
this.Canvas.strokeStyle=this.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(right,ToFixedPoint(y));this.Canvas.lineTo(right+this.RightSpaceWidth,ToFixedPoint(y));this.Canvas.stroke();if(!bVisibleRange)this.Canvas.setLineDash([]);}this.Canvas.fillStyle=this.LineColor;this.Canvas.font=this.Font;var textWidth=this.Canvas.measureText(strValue).width;var lineHeight=this.GetFontHeight();var rtBG={Left:right+this.RightSpaceWidth,
|
|
6115
|
-
|
|
6117
|
+
}if(item.Color)this.Canvas.strokeStyle=item.Color;else this.Canvas.strokeStyle=this.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(left,yFixed);this.Canvas.lineTo(xRight,yFixed);this.Canvas.stroke();if(yMax<yFixed)yMax=yFixed;if(yMin>yFixed)yMin=yFixed;}if(yMax!=yMin&&this.LableInfo.VLine){var item=this.LableInfo.VLine;var x=left+20*pixelRatio;if(IFrameSplitOperator.IsNumber(item.XOffset))x=left+item.XOffset*pixelRatio;x=ToFixedPoint(x);if(item.Color)this.Canvas.strokeStyle=item.Color;else this.Canvas.strokeStyle=this.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(x,yMax);this.Canvas.lineTo(x,yMin);this.Canvas.stroke();}};this.DrawValueText=function(y,rtDraw,option){var left=this.Frame.ChartBorder.GetLeft();var right=this.Frame.ChartBorder.GetRight();var top=this.Frame.ChartBorder.GetTopEx();var bottom=this.Frame.ChartBorder.GetBottomEx();var pixelTatio=GetDevicePixelRatio();var labInfo=this.LabelInfo;if(labInfo&&IFrameSplitOperator.IsNumber(labInfo.TopOffset))top-=labInfo.TopOffset;if(labInfo&&IFrameSplitOperator.IsNumber(labInfo.BottomOffset))bottom+=labInfo.BottomOffset;var yValue=this.Frame.GetYData(y,false);var strValue=yValue.toFixed(this.Precision);if(labInfo&&labInfo.PriceSuffixText)strValue+=labInfo.PriceSuffixText;var bVisibleRange=true;if(y<top){y=top;bVisibleRange=false;}else if(y>bottom){y=bottom;bVisibleRange=false;}if(this.RightSpaceWidth>0){if(!bVisibleRange)this.Canvas.setLineDash([2*pixelTatio,3*pixelTatio]);//虚线
|
|
6118
|
+
this.Canvas.strokeStyle=this.LineColor;this.Canvas.beginPath();this.Canvas.moveTo(right,ToFixedPoint(y));this.Canvas.lineTo(right+this.RightSpaceWidth,ToFixedPoint(y));this.Canvas.stroke();if(!bVisibleRange)this.Canvas.setLineDash([]);}this.Canvas.fillStyle=this.LineColor;this.Canvas.font=this.Font;var textWidth=this.Canvas.measureText(strValue).width;var lineHeight=this.GetFontHeight();var rtBG={Left:right+this.RightSpaceWidth,YCenter:y,Width:textWidth,Height:lineHeight};rtBG.Height+=this.TextMargin.Top+this.TextMargin.Bottom;rtBG.Width+=this.TextMargin.Left+this.TextMargin.Right;rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;if(option&&IFrameSplitOperator.IsNumber(option.Top)){rtBG.Top=option.Top;rtBG.Bottom=rtBG.Top+rtBG.Height;}var xText=rtBG.Left+this.TextMargin.Left;var yText=rtBG.Top+this.TextMargin.Top+this.TextMargin.YOffset;if(this.ButtonPosition==1){this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width+this.ButtonBGWidth),ToFixedRect(rtBG.Height));}else{this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));}this.Canvas.fillStyle=this.ValueTextColor;this.Canvas.textAlign="left";this.Canvas.textBaseline="top";this.Canvas.fillText(strValue,xText,yText);rtDraw.Left=rtBG.Left;rtDraw.Top=rtBG.Top;rtDraw.Bottom=rtBG.Bottom;rtDraw.Right=rtBG.Right;this.DrawButton(rtBG.Top,rtBG.Right,lineHeight,rtDraw);};//计算右侧价格标签大小
|
|
6119
|
+
this.CalculateValueText=function(y){var yValue=this.Frame.GetYData(y,false);var strValue=yValue.toFixed(this.Precision);if(this.LableInfo&&this.LableInfo.PriceSuffixText)strValue+=this.LableInfo.PriceSuffixText;this.Canvas.font=this.Font;var textWidth=this.Canvas.measureText(strValue).width;var lineHeight=this.GetFontHeight();var size={Width:textWidth,Height:lineHeight};size.Height+=this.TextMargin.Top+this.TextMargin.Bottom;size.Width+=this.TextMargin.Left+this.TextMargin.Right;return size;};this.DrawPriceText=function(text,ptStart,ptEnd,position){if(position!=1&&position!=0)return;var font=this.ShowPriceTextConfig.Font[position];this.Canvas.fillStyle=this.LineColor;this.Canvas.font=font;var textWidth=this.Canvas.measureText(text).width;var lineHeight=this.GetFontHeight();var rtBG=null;if(position==1){var rtBG={Left:ptStart.X,Top:ptStart.Y-lineHeight/2,Width:textWidth+4,Height:lineHeight};rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Bottom=rtBG.Top+rtBG.Height;}else if(position==0){var rtBG={Right:ptEnd.X,Top:ptEnd.Y-lineHeight/2,Width:textWidth+4,Height:lineHeight};rtBG.Left=rtBG.Right-rtBG.Width;rtBG.Bottom=rtBG.Top+rtBG.Height;}this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width+this.ButtonBGWidth),ToFixedRect(rtBG.Height));this.Canvas.fillStyle=this.ValueTextColor;this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillText(text,rtBG.Left+2,ptStart.Y);};this.CalculateButtonSize=function(){var pixelRatio=GetDevicePixelRatio();if(!IFrameSplitOperator.IsNonEmptyArray(this.AryShowButton))return;var totalWidth=0;for(var i=0;i<this.AryShowButton.length;++i){var item=this.AryShowButton[i];var icon=item.Data;var font=icon.Size*pixelRatio+'px '+icon.Family;this.Canvas.font=font;item.Width=this.Canvas.measureText(icon.Text).width+2;item.Height=item.Width;if(icon.Margin){var margin=icon.Margin;if(IFrameSplitOperator.IsNumber(margin.Left))item.Width+=margin.Left;if(IFrameSplitOperator.IsNumber(margin.Right))item.Width+=margin.Right;if(IFrameSplitOperator.IsNumber(margin.Top))item.Height+=margin.Top;if(IFrameSplitOperator.IsNumber(margin.Bottom))item.Height+=margin.Bottom;}if(this.VerticalButtonInfo.Width<item.Width)this.VerticalButtonInfo.Width=item.Width;this.VerticalButtonInfo.Height+=item.Height;totalWidth+=item.Width;}this.ButtonBGWidth=totalWidth;};//垂直排列按钮
|
|
6116
6120
|
this.DrawVerticalButton=function(rtLab){if(this.ButtonPosition!=3)return;if(!IFrameSplitOperator.IsNonEmptyArray(this.AryShowButton))return;if(this.VerticalButtonInfo.Height<=0)return;var rtBG={Left:rtLab.Right,Top:rtLab.Top,Width:this.VerticalButtonInfo.Width,Height:this.VerticalButtonInfo.Height};rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Bottom=rtBG.Top+rtBG.Height;this.Canvas.fillStyle=this.ButtonBGColor;this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));var pixelRatio=GetDevicePixelRatio();var yTop=rtLab.Top;for(var i=0;i<this.AryShowButton.length;++i){var item=this.AryShowButton[i];var icon=item.Data;var rtButton={Left:rtBG.Left,Top:yTop,Width:this.VerticalButtonInfo.Width,Height:item.Height};rtButton.Right=rtButton.Left+rtButton.Width;rtButton.Bottom=rtButton.Top+rtButton.Height;var yCenter=rtButton.Top+rtButton.Height/2;var xCenter=rtButton.Left+rtButton.Width/2;var font=icon.Size*pixelRatio+'px '+icon.Family;this.Canvas.font=font;this.Canvas.textAlign="center";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=icon.Color;this.Canvas.fillText(icon.Text,xCenter,yCenter);this.AryButton.push({Rect:rtButton,ID:icon.ID,TooltipText:icon.TooltipText,Data:icon.Data});yTop=rtButton.Bottom;}};this.DrawButton=function(drawTop,drawLeft,drawHeight,rtDraw){if(!IFrameSplitOperator.IsNonEmptyArray(this.AryShowButton))return;if(this.ButtonPosition==3)return;//垂直按钮在DrawVerticalButton()调用
|
|
6117
6121
|
if(this.ButtonPosition==1){drawTop-=drawHeight;var chartWidth=this.Frame.ChartBorder.GetChartWidth();var chartLeft=this.Frame.ChartBorder.GetRight()+this.RightSpaceWidth;if(drawLeft+this.ButtonBGWidth>chartWidth)//右边不够了 往左移动
|
|
6118
6122
|
{drawLeft=chartWidth-this.ButtonBGWidth;}if(rtDraw.Left>drawLeft)drawLeft=rtDraw.Left;}else if(this.ButtonPosition==2){drawTop-=drawHeight;drawLeft=rtDraw.Left;}this.Canvas.fillStyle=this.LineColor;var left=drawLeft;var rtBG={Left:drawLeft,Top:drawTop,Width:this.ButtonBGWidth,Height:drawHeight};rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Bottom=rtBG.Top+rtBG.Height;this.Canvas.fillStyle=this.ButtonBGColor;this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));var pixelRatio=GetDevicePixelRatio();for(var i=0;i<this.AryShowButton.length;++i){var item=this.AryShowButton[i];var icon=item.Data;var rtButton={Left:left,Top:drawTop,Width:item.Width,Height:drawHeight};rtButton.Right=rtButton.Left+rtButton.Width;rtButton.Bottom=rtButton.Top+rtButton.Height;var yCenter=rtButton.Top+rtButton.Height/2;var xCenter=rtButton.Left+rtButton.Width/2;var font=icon.Size*pixelRatio+'px '+icon.Family;this.Canvas.font=font;this.Canvas.textAlign="center";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=icon.Color;this.Canvas.fillText(icon.Text,xCenter,yCenter);this.AryButton.push({Rect:rtButton,ID:icon.ID,TooltipText:icon.TooltipText,Data:icon.Data});left=rtButton.Right;}};this.PtInButtons=function(x,y){for(var i=0;i<this.AryButton.length;++i){var item=this.AryButton[i];if(!item.Rect)continue;var rect=item.Rect;this.Canvas.beginPath();this.Canvas.rect(rect.Left,rect.Top,rect.Width,rect.Height);if(this.Canvas.isPointInPath(x,y)){return{ID:item.ID,Rect:rect,Data:item.Data};}}return null;};}//趋势线
|
|
@@ -13788,7 +13792,7 @@ hisData.Symbol=message.symbol;}var stockObj={HQDataType:HQ_DATA_TYPE.KLINE_ID,St
|
|
|
13788
13792
|
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);};}/********************************************************************************
|
|
13789
13793
|
* 版本信息输出
|
|
13790
13794
|
*
|
|
13791
|
-
*/var HQCHART_VERSION="1.1.
|
|
13795
|
+
*/var HQCHART_VERSION="1.1.13759";function PrintHQChartVersion(){var logo='\n\n*************************************************************************************************************************************************************************** \n* \n* :%@@- \n* :@@@@- \n* =@@@@ :#@@@ .:+#@@@#=: :=*@@@@@@#+-. *@@@@. \n* :@@@@@ .@@@@@ .#@@@@@@@@@@@- +@@@@@@@@@@@@@+ @@@@@ -%@@* \n* +@@@@% #@@@@# *@@@@@@@@@@@@@@%. =@@@@@@@@@@@@@@@- @@@@@ -@@@@+ \n* %@@@@* @@@@@+ .%@@@@@@@@@@@@@@@@%: #@@@@@@@@@@@@@@@% @@@@# *@@@@= \n* @@@@@= @@@@@- .%@@@@@@@*++*%@@@@@@% .%@@@@@@@%*+==+**= -@@@@+ #@@@@- \n* @@@@@. @@@@@. #@@@@@%= =@@@@@@* %@@@@@@#: *@@@@- :::. .-+*###+: ::: .+##+: -%%@@@@@%%%% \n* .@@@@@ .@@@@@. +@@@@@% .@@@@@@ *@@@@@@: %@@@@: +@@@@@%. :%@@@@@@@@@@: *@@@ :@@@@@* @@@@@@@@@@@@ \n* :@@@@@ :@@@@@ @@@@@% :@@@@@+ @@@@@@: %@@@@-@@@@@@@@@. @@@@@@@@@@@@@. :@@@%-@@@@@@.:@@@@@@@@@@@# \n* -@@@@% -@@@@@ =@@@@@. %@@@@% %@@@@@- %@@@@@@@@@@@@@@* %@@@@@@@@@@@@+ -@@@@@@@@@@# -@@@@@@@@@@@. \n* +@@@@%=========#@@@@% @@@@@# :@@@@@ .@@@@@% @@@@@@@@%@@@@@@@ -%+:. .#@@@@* +@@@@@@@%%@. .::+@@@@#:: \n* #@@@@@@@@@@@@@@@@@@@# .@@@@@ .@@@@@ :@@@@@. @@@@@@#. #@@@@@. -@@@@* #@@@@@@: *@@@@+ \n* %@@@@@@@@@@@@@@@@@@@+ :@@@@@ .@@@@@ -@@@@@ @@@@@+ @@@@@. :@@@@* @@@@@% #@@@@- \n* @@@@@@@@@@@@@@@@@@@@: :@@@@% :@@@@@ +@@@@% -@@@@+ @@@@@ -@@@@+ @@@@@. @@@@@. \n* .@@@@@@@@@@@@@@@@@@@@ :@@@@% -@@@@% *@@@@% #@@@@. @@@@@ .=*#%%%@@@@@= :@@@@# @@@@@. \n* -@@@@@:::::::::=@@@@@ :@@@@@ @@@@@* +@@@@% @@@@@ @@@@% -#@@@@@@@@@@@@: -@@@@* @@@@@ \n* =@@@@% =@@@@% .@@@@@ :@@@@@. -@@@@% @@@@@ .@@@@* +@@@@@@@@@@@@@@. =@@@@+ .@@@@@ \n* +@@@@# +@@@@# @@@@@# %@@@@% :@@@@@ .@@@@% =@@@@= -@@@@@*-:..%@@@@ +@@@@= :@@@@# \n* *@@@@* *@@@@* +@@@@@: #@@@@@+ .@@@@@@ :@@@@% *@@@@- @@@@@. @@@@% #@@@@: =@@@@+ \n* %@@@@= %@@@@+ @@@@@@- .%@@@@@# #@@@@@# :@@@@% #@@@@: @@@@% @@@@* %@@@@. #@@@@- \n* @@@@@- @@@@@= =@@@@@@#=...-*@@@@@@@: @@@@@@%=. :+**. :@@@@* %@@@@. .@@@@* *@@@@= @@@@@ %@@@@+ \n* .@@@@@: .@@@@@: *@@@@@@@@@@@@@@@@@@@# =@@@@@@@@%%%@@@@@@ +@@@@- @@@@@ .@@@@@: :%@@@@@- .@@@@% %@@@@@*+- \n* :@@@@@ :@@@@@ +@@@@@@@@@@@@@@@@@@@# =@@@@@@@@@@@@@@@@% %@@@@ @@@@@ @@@@@@@@@@@@@@@: -@@@@* *@@@@@@@@- \n* =@@@@@ -@@@@@ :@@@@@@@@@@@@@@@@@@@# :@@@@@@@@@@@@@@@% @@@@@ %@@@% #@@@@@@@@@#@@@@. +@@@@- .@@@@@@@@# \n* *@@@@# =@@@@% :#@@@@@@@#: :@@@@@= =@@@@@@@@@@@+. @@@@@ :@@@+ *@@@@@@@- %@@@ *@@@= =@@@@@@@* \n* =++++- -++++= .:::. .=*+: :-=+++=:. ****= .=+. .-++=: :+++ -+=: .-=+=:. \n* \n* \n* HQChart \n* Ver: '+HQCHART_VERSION+' \n* License: Apache License 2.0 \n* Source: https://github.com/jones2000/HQChart\n*\n************************************************************************************************************************************************************************** \n ';console.log(logo);}PrintHQChartVersion();//把给外界调用的方法暴露出来
|
|
13792
13796
|
exports.default=(_jsChartInit$jsChartS={jsChartInit:JSChart.Init,jsChartStyle:JSChart.SetStyle,// IsIndexSymbol:IsIndexSymbol,
|
|
13793
13797
|
// BaseIndex:BaseIndex,
|
|
13794
13798
|
// ChartLine:ChartLine,
|
package/package.json
CHANGED
package/src/jscommon/umychart.js
CHANGED
|
@@ -58551,7 +58551,7 @@ function ChartDrawHLine()
|
|
|
58551
58551
|
this.ButtonBGColor='rgb(190,190,190)';
|
|
58552
58552
|
this.ButtonSpace=3;
|
|
58553
58553
|
|
|
58554
|
-
this.TextMargin={ Left:0, Right:0 };
|
|
58554
|
+
this.TextMargin={ Left:0, Right:0, Top:0, Bottom:0, YOffset:4*GetDevicePixelRatio() };
|
|
58555
58555
|
|
|
58556
58556
|
this.AlwaysShowLab=false; //总是显示标签
|
|
58557
58557
|
|
|
@@ -58575,7 +58575,9 @@ function ChartDrawHLine()
|
|
|
58575
58575
|
`${12*GetDevicePixelRatio()}px 微软雅黑`,
|
|
58576
58576
|
`${12*GetDevicePixelRatio()}px 微软雅黑`,
|
|
58577
58577
|
],
|
|
58578
|
-
};
|
|
58578
|
+
};
|
|
58579
|
+
|
|
58580
|
+
this.LableInfo; //{ Position:2=右侧外部 }
|
|
58579
58581
|
|
|
58580
58582
|
//内部变量
|
|
58581
58583
|
this.ColseButtonSize=0;
|
|
@@ -58583,7 +58585,7 @@ function ChartDrawHLine()
|
|
|
58583
58585
|
this.ButtonBGWidth=0;
|
|
58584
58586
|
this.VerticalButtonInfo={ Width:0, Height:0 }; //垂直按钮信息
|
|
58585
58587
|
|
|
58586
|
-
|
|
58588
|
+
this.IsPointIn=this.IsPointIn_XYValue_Line;
|
|
58587
58589
|
|
|
58588
58590
|
this.SetOption=function(option)
|
|
58589
58591
|
{
|
|
@@ -58644,6 +58646,9 @@ function ChartDrawHLine()
|
|
|
58644
58646
|
var item=option.TextMargin;
|
|
58645
58647
|
if (IFrameSplitOperator.IsNumber(item.Left)) this.TextMargin.Left=item.Left;
|
|
58646
58648
|
if (IFrameSplitOperator.IsNumber(item.Right)) this.TextMargin.Right=item.Right;
|
|
58649
|
+
if (IFrameSplitOperator.IsNumber(item.Top)) this.TextMargin.Top=item.Top;
|
|
58650
|
+
if (IFrameSplitOperator.IsNumber(item.Bottom)) this.TextMargin.Bottom=item.Bottom;
|
|
58651
|
+
if (IFrameSplitOperator.IsNumber(item.YOffset)) this.TextMargin.YOffset=item.YOffset;
|
|
58647
58652
|
}
|
|
58648
58653
|
}
|
|
58649
58654
|
}
|
|
@@ -58660,10 +58665,6 @@ function ChartDrawHLine()
|
|
|
58660
58665
|
return storageData;
|
|
58661
58666
|
}
|
|
58662
58667
|
|
|
58663
|
-
|
|
58664
|
-
this.IsPointIn=this.IsPointIn_XYValue_Line;
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
58668
|
/*
|
|
58668
58669
|
this.GetXYCoordinate=function()
|
|
58669
58670
|
{
|
|
@@ -58720,7 +58721,7 @@ function ChartDrawHLine()
|
|
|
58720
58721
|
this.ColseButtonSize=0;
|
|
58721
58722
|
this.SettingButtonSize=0;
|
|
58722
58723
|
this.ButtonBGWidth=0;
|
|
58723
|
-
|
|
58724
|
+
this.LableInfo=null;
|
|
58724
58725
|
this.VerticalButtonInfo.Width=0;
|
|
58725
58726
|
this.VerticalButtonInfo.Height=0;
|
|
58726
58727
|
|
|
@@ -58783,7 +58784,7 @@ function ChartDrawHLine()
|
|
|
58783
58784
|
}
|
|
58784
58785
|
this.LinePoint.push(line);
|
|
58785
58786
|
|
|
58786
|
-
if (bVisibleRange)
|
|
58787
|
+
if (bVisibleRange) //在可视范围内
|
|
58787
58788
|
{
|
|
58788
58789
|
var yValue=this.Frame.GetYData(drawPoint[0].Y, false);
|
|
58789
58790
|
var strPrice=yValue.toFixed(this.Precision);
|
|
@@ -58797,15 +58798,11 @@ function ChartDrawHLine()
|
|
|
58797
58798
|
this.DrawPriceText(strPrice, line.Start, line.End, 1);
|
|
58798
58799
|
}
|
|
58799
58800
|
}
|
|
58800
|
-
|
|
58801
|
-
|
|
58802
|
-
if (this.GetLabelCallback) labInfo=this.GetLabelCallback(this);
|
|
58801
|
+
|
|
58802
|
+
if (this.GetLabelCallback) this.LableInfo=this.GetLabelCallback(this);
|
|
58803
58803
|
|
|
58804
58804
|
this.AryShowButton=this.GetShowButton(); //获取按钮
|
|
58805
|
-
|
|
58806
|
-
//框架内的描述信息
|
|
58807
|
-
if (labInfo && bVisibleRange)
|
|
58808
|
-
this.DrawLab(labInfo, drawPoint[0].Y);
|
|
58805
|
+
if (bVisibleRange) this.DrawInternalLabel(drawPoint[0].Y); //内部价格标签
|
|
58809
58806
|
|
|
58810
58807
|
//画中心点
|
|
58811
58808
|
if (bVisibleRange)
|
|
@@ -58822,11 +58819,11 @@ function ChartDrawHLine()
|
|
|
58822
58819
|
{
|
|
58823
58820
|
var rtDraw={ };
|
|
58824
58821
|
this.CalculateButtonSize();
|
|
58825
|
-
this.
|
|
58826
|
-
if (
|
|
58827
|
-
if (labInfo && bVisibleRange) this.DrawCustomHLine(labInfo, drawPoint[0].Y);
|
|
58822
|
+
this.DrawRightLabel(drawPoint[0].Y);
|
|
58823
|
+
if (bVisibleRange) this.DrawCustomHLine(drawPoint[0].Y);
|
|
58828
58824
|
}
|
|
58829
58825
|
|
|
58826
|
+
|
|
58830
58827
|
//鼠标是否在按钮上
|
|
58831
58828
|
if (moveonPoint && mouseStatus)
|
|
58832
58829
|
{
|
|
@@ -58874,113 +58871,141 @@ function ChartDrawHLine()
|
|
|
58874
58871
|
++lineCount;
|
|
58875
58872
|
}
|
|
58876
58873
|
|
|
58877
|
-
var size={ Width:maxWidth, Height:
|
|
58874
|
+
var size={ Width:maxWidth, Height:lineCount*lineHeight+(lineCount-1)*lineSpace, NameWidth:maxNameWidth, TextWidth:maxTextWidth, LineHeight:lineHeight };
|
|
58875
|
+
if (labInfo.LabelMargin)
|
|
58876
|
+
{
|
|
58877
|
+
var item=labInfo.LabelMargin;
|
|
58878
|
+
if (IFrameSplitOperator.IsNumber(item.Left)) size.Width+=item.Left;
|
|
58879
|
+
if (IFrameSplitOperator.IsNumber(item.Right)) size.Width+=item.Right;
|
|
58880
|
+
if (IFrameSplitOperator.IsNumber(item.Top)) size.Height+=item.Top;
|
|
58881
|
+
if (IFrameSplitOperator.IsNumber(item.Bottom)) size.Height+=item.Bottom;
|
|
58882
|
+
}
|
|
58878
58883
|
|
|
58879
58884
|
return size;
|
|
58880
58885
|
}
|
|
58881
58886
|
|
|
58882
|
-
|
|
58887
|
+
//绘制窗口内部标签
|
|
58888
|
+
this.DrawInternalLabel=function(y)
|
|
58883
58889
|
{
|
|
58884
|
-
if (!
|
|
58885
|
-
if (
|
|
58886
|
-
if (labInfo.Position===2) return;
|
|
58890
|
+
if (!this.LableInfo || !IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText)) return;
|
|
58891
|
+
if (this.LableInfo.Position==2) return;
|
|
58887
58892
|
|
|
58888
|
-
var
|
|
58889
|
-
var
|
|
58890
|
-
var
|
|
58893
|
+
var border=this.Frame.GetBorder();
|
|
58894
|
+
var left=border.Left;
|
|
58895
|
+
var right=border.Right;
|
|
58896
|
+
var labSize=this.CalculateLabSize(this.LableInfo);
|
|
58891
58897
|
var drawLeft=right-labSize.Width;
|
|
58898
|
+
var drawRight=drawLeft+labSize.Width;
|
|
58892
58899
|
var drawTop=y-labSize.Height-1;
|
|
58900
|
+
if (drawTop<=border.TopEx) drawTop=y+1;
|
|
58893
58901
|
|
|
58894
|
-
|
|
58895
|
-
|
|
58896
|
-
{
|
|
58897
|
-
this.Canvas.fillStyle=labInfo.BGColor;
|
|
58898
|
-
var rtTop=y-labSize.Height-4;
|
|
58899
|
-
this.Canvas.fillRect(ToFixedRect(drawLeft),ToFixedRect(rtTop),ToFixedRect(right+drawLeft),ToFixedRect(y-rtTop));
|
|
58900
|
-
}
|
|
58902
|
+
var rtLabel={ Left:drawLeft, Right:drawRight, Top:drawTop, Width:labSize.Width, Height:labSize.Height };
|
|
58903
|
+
rtLabel.Bottom=rtLabel.Top+rtLabel.Height;
|
|
58901
58904
|
|
|
58902
|
-
|
|
58903
|
-
for(var i=0;i<labInfo.AryText.length;++i)
|
|
58904
|
-
{
|
|
58905
|
-
var item=labInfo.AryText[i];
|
|
58906
|
-
if (item.Name)
|
|
58907
|
-
{
|
|
58908
|
-
this.Canvas.fillStyle=item.NameColor;
|
|
58909
|
-
this.Canvas.fillText(item.Name,drawLeft+1,yText+1);
|
|
58910
|
-
}
|
|
58911
|
-
|
|
58912
|
-
if (item.Text)
|
|
58913
|
-
{
|
|
58914
|
-
this.Canvas.fillStyle=item.TextColor;
|
|
58915
|
-
this.Canvas.fillText(item.Text,drawLeft+labSize.NameWidth+1,yText+1);
|
|
58916
|
-
}
|
|
58917
|
-
|
|
58918
|
-
yText+=labSize.LineHeight;
|
|
58919
|
-
}
|
|
58905
|
+
this.DrawLabel(this.LableInfo, labSize, rtLabel);
|
|
58920
58906
|
}
|
|
58921
58907
|
|
|
58922
|
-
|
|
58908
|
+
//绘制标签页
|
|
58909
|
+
this.DrawLabel=function(labelInfo, labelSize, rtLabel)
|
|
58923
58910
|
{
|
|
58924
|
-
|
|
58925
|
-
if (
|
|
58926
|
-
|
|
58927
|
-
|
|
58911
|
+
//背景色
|
|
58912
|
+
if (labelInfo.BGColor)
|
|
58913
|
+
{
|
|
58914
|
+
this.Canvas.fillStyle=labelInfo.BGColor;
|
|
58915
|
+
this.Canvas.fillRect(ToFixedRect(rtLabel.Left),ToFixedRect(rtLabel.Top),ToFixedRect(rtLabel.Width),ToFixedRect(rtLabel.Height));
|
|
58916
|
+
}
|
|
58928
58917
|
|
|
58929
|
-
var
|
|
58930
|
-
if (drawLeft<rtLeftDraw.Left) drawLeft=rtLeftDraw.Left;
|
|
58931
|
-
var drawRight=drawLeft+labSize.Width;
|
|
58932
|
-
var drawTop=rtLeftDraw.Bottom;
|
|
58918
|
+
var labelMargin=labelInfo.LabelMargin;
|
|
58933
58919
|
var lineSpace=0;
|
|
58934
|
-
if (IFrameSplitOperator.IsNumber(
|
|
58920
|
+
if (IFrameSplitOperator.IsNumber(labelInfo.LineSpace)) lineSpace=labelInfo.LineSpace;
|
|
58921
|
+
|
|
58922
|
+
var yText=rtLabel.Top;
|
|
58923
|
+
var xText=rtLabel.Left;
|
|
58924
|
+
var yRightText=rtLabel.Right;
|
|
58935
58925
|
|
|
58936
|
-
|
|
58937
|
-
var rtLab={ Left:drawLeft, Top:drawTop, Width:labSize.Width, Height:labSize.Height }
|
|
58938
|
-
rtLab.Right=rtLab.Left+rtLab.Width;
|
|
58939
|
-
rtLab.Bottom=rtLab.Top+rtLab.Height;
|
|
58940
|
-
if (labInfo.BGColor)
|
|
58926
|
+
if (labelMargin)
|
|
58941
58927
|
{
|
|
58942
|
-
|
|
58943
|
-
|
|
58928
|
+
if (IFrameSplitOperator.IsNumber(labelMargin.Left)) xText+=labelMargin.Left;
|
|
58929
|
+
if (IFrameSplitOperator.IsNumber(labelMargin.Right)) yRightText-=labelMargin.Right;
|
|
58930
|
+
if (IFrameSplitOperator.IsNumber(labelMargin.Top)) yText+=labelMargin.Top;
|
|
58931
|
+
|
|
58944
58932
|
}
|
|
58945
58933
|
|
|
58946
|
-
|
|
58934
|
+
this.Canvas.font=this.TextFont;
|
|
58947
58935
|
this.Canvas.textBaseline="top";
|
|
58948
|
-
for(var i=0;i<
|
|
58936
|
+
for(var i=0;i<labelInfo.AryText.length;++i)
|
|
58949
58937
|
{
|
|
58950
|
-
|
|
58938
|
+
if (i>0) yText+=lineSpace;
|
|
58939
|
+
var item=labelInfo.AryText[i];
|
|
58951
58940
|
if (item.Name)
|
|
58952
58941
|
{
|
|
58953
58942
|
this.Canvas.textAlign="left";
|
|
58954
58943
|
this.Canvas.fillStyle=item.NameColor;
|
|
58955
|
-
this.Canvas.fillText(item.Name,
|
|
58944
|
+
this.Canvas.fillText(item.Name,xText,yText);
|
|
58956
58945
|
}
|
|
58957
58946
|
|
|
58958
58947
|
if (item.Text)
|
|
58959
58948
|
{
|
|
58960
58949
|
this.Canvas.textAlign="right";
|
|
58961
58950
|
this.Canvas.fillStyle=item.TextColor;
|
|
58962
|
-
this.Canvas.fillText(item.Text,
|
|
58951
|
+
this.Canvas.fillText(item.Text,yRightText,yText);
|
|
58963
58952
|
}
|
|
58964
58953
|
|
|
58965
|
-
yText+=
|
|
58954
|
+
yText+=labelSize.LineHeight;
|
|
58966
58955
|
}
|
|
58956
|
+
}
|
|
58967
58957
|
|
|
58968
|
-
|
|
58958
|
+
this.DrawRightLabel=function(y)
|
|
58959
|
+
{
|
|
58960
|
+
var rtDraw={ };
|
|
58961
|
+
if (!this.LableInfo || !IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText) || this.LableInfo.Position!=2)
|
|
58962
|
+
{
|
|
58963
|
+
this.DrawValueText(y, rtDraw);
|
|
58964
|
+
return;
|
|
58965
|
+
}
|
|
58966
|
+
|
|
58967
|
+
var priceSize=this.CalculateValueText(y);
|
|
58968
|
+
var labSize=this.CalculateLabSize(this.LableInfo);
|
|
58969
|
+
var border=this.Frame.GetBorder();
|
|
58970
|
+
var yTop=y-priceSize.Height/2;
|
|
58971
|
+
var totalHeight=priceSize.Height+labSize.Height;
|
|
58972
|
+
var yBottom=yTop+totalHeight;
|
|
58973
|
+
var option={ };
|
|
58974
|
+
if (yBottom>border.Bottom) //超过窗口底部, 标签位置不动
|
|
58975
|
+
{
|
|
58976
|
+
yBottom=border.Bottom;
|
|
58977
|
+
yTop=yBottom-totalHeight;
|
|
58978
|
+
option.Top=yTop;
|
|
58979
|
+
}
|
|
58980
|
+
|
|
58981
|
+
this.DrawValueText(y, rtDraw, option);
|
|
58982
|
+
|
|
58983
|
+
var drawLeft=rtDraw.Right-labSize.Width;
|
|
58984
|
+
if (drawLeft<rtDraw.Left) drawLeft=rtDraw.Left;
|
|
58985
|
+
var drawRight=drawLeft+labSize.Width;
|
|
58986
|
+
var drawTop=rtDraw.Bottom;
|
|
58987
|
+
|
|
58988
|
+
var rtLabel={ Left:drawLeft, Right:drawRight, Top:drawTop, Width:labSize.Width, Height:labSize.Height };
|
|
58989
|
+
rtLabel.Bottom=rtLabel.Top+rtLabel.Height;
|
|
58990
|
+
|
|
58991
|
+
this.DrawLabel(this.LableInfo, labSize, rtLabel);
|
|
58992
|
+
|
|
58993
|
+
this.DrawVerticalButton(rtLabel);
|
|
58969
58994
|
}
|
|
58970
58995
|
|
|
58971
|
-
this.DrawCustomHLine=function(
|
|
58996
|
+
this.DrawCustomHLine=function(yLine)
|
|
58972
58997
|
{
|
|
58973
|
-
if (!
|
|
58974
|
-
if (!IFrameSplitOperator.IsNonEmptyArray(
|
|
58998
|
+
if (!this.LableInfo) return;
|
|
58999
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryLine)) return;
|
|
58975
59000
|
|
|
58976
59001
|
var left=this.Frame.ChartBorder.GetLeft();
|
|
58977
59002
|
var right=this.Frame.ChartBorder.GetRight();
|
|
58978
59003
|
var pixelRatio=GetDevicePixelRatio();
|
|
58979
59004
|
|
|
58980
59005
|
var yMax=yLine, yMin=yLine;
|
|
58981
|
-
for(var i=0;i<
|
|
59006
|
+
for(var i=0;i<this.LableInfo.AryLine.length;++i)
|
|
58982
59007
|
{
|
|
58983
|
-
var item=
|
|
59008
|
+
var item=this.LableInfo.AryLine[i];
|
|
58984
59009
|
if (!IFrameSplitOperator.IsNumber(item.Value)) continue;
|
|
58985
59010
|
if (item.Width<0) continue;
|
|
58986
59011
|
|
|
@@ -59005,9 +59030,9 @@ function ChartDrawHLine()
|
|
|
59005
59030
|
if (yMin>yFixed) yMin=yFixed;
|
|
59006
59031
|
}
|
|
59007
59032
|
|
|
59008
|
-
if (yMax!=yMin &&
|
|
59033
|
+
if (yMax!=yMin && this.LableInfo.VLine)
|
|
59009
59034
|
{
|
|
59010
|
-
var item=
|
|
59035
|
+
var item=this.LableInfo.VLine;
|
|
59011
59036
|
var x=left+20*pixelRatio;
|
|
59012
59037
|
if (IFrameSplitOperator.IsNumber(item.XOffset)) x=left+item.XOffset*pixelRatio;
|
|
59013
59038
|
x=ToFixedPoint(x);
|
|
@@ -59021,14 +59046,14 @@ function ChartDrawHLine()
|
|
|
59021
59046
|
}
|
|
59022
59047
|
}
|
|
59023
59048
|
|
|
59024
|
-
this.DrawValueText=function(y, rtDraw,
|
|
59049
|
+
this.DrawValueText=function(y, rtDraw, option)
|
|
59025
59050
|
{
|
|
59026
59051
|
var left=this.Frame.ChartBorder.GetLeft();
|
|
59027
59052
|
var right=this.Frame.ChartBorder.GetRight();
|
|
59028
59053
|
var top=this.Frame.ChartBorder.GetTopEx();
|
|
59029
59054
|
var bottom=this.Frame.ChartBorder.GetBottomEx();
|
|
59030
59055
|
var pixelTatio = GetDevicePixelRatio();
|
|
59031
|
-
|
|
59056
|
+
var labInfo=this.LabelInfo;
|
|
59032
59057
|
if (labInfo && IFrameSplitOperator.IsNumber(labInfo.TopOffset)) top-=labInfo.TopOffset;
|
|
59033
59058
|
if (labInfo && IFrameSplitOperator.IsNumber(labInfo.BottomOffset)) bottom+=labInfo.BottomOffset;
|
|
59034
59059
|
|
|
@@ -59063,12 +59088,21 @@ function ChartDrawHLine()
|
|
|
59063
59088
|
this.Canvas.font=this.Font;
|
|
59064
59089
|
var textWidth=this.Canvas.measureText(strValue).width;
|
|
59065
59090
|
var lineHeight=this.GetFontHeight();
|
|
59066
|
-
var rtBG={ Left:right+this.RightSpaceWidth,
|
|
59067
|
-
|
|
59068
|
-
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
59091
|
+
var rtBG={ Left:right+this.RightSpaceWidth, YCenter:y, Width:textWidth, Height:lineHeight };
|
|
59092
|
+
rtBG.Height+=(this.TextMargin.Top+this.TextMargin.Bottom);
|
|
59069
59093
|
rtBG.Width+=(this.TextMargin.Left+this.TextMargin.Right);
|
|
59070
59094
|
rtBG.Right=rtBG.Left+rtBG.Width;
|
|
59071
|
-
|
|
59095
|
+
rtBG.Top=rtBG.YCenter-rtBG.Height/2;
|
|
59096
|
+
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
59097
|
+
|
|
59098
|
+
if (option && IFrameSplitOperator.IsNumber(option.Top))
|
|
59099
|
+
{
|
|
59100
|
+
rtBG.Top=option.Top;
|
|
59101
|
+
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
59102
|
+
}
|
|
59103
|
+
|
|
59104
|
+
var xText=rtBG.Left+this.TextMargin.Left;
|
|
59105
|
+
var yText=rtBG.Top+this.TextMargin.Top+this.TextMargin.YOffset;
|
|
59072
59106
|
|
|
59073
59107
|
if (this.ButtonPosition==1)
|
|
59074
59108
|
{
|
|
@@ -59081,8 +59115,8 @@ function ChartDrawHLine()
|
|
|
59081
59115
|
|
|
59082
59116
|
this.Canvas.fillStyle=this.ValueTextColor
|
|
59083
59117
|
this.Canvas.textAlign="left";
|
|
59084
|
-
this.Canvas.textBaseline="
|
|
59085
|
-
this.Canvas.fillText(strValue,xText,
|
|
59118
|
+
this.Canvas.textBaseline="top";
|
|
59119
|
+
this.Canvas.fillText(strValue,xText,yText);
|
|
59086
59120
|
|
|
59087
59121
|
rtDraw.Left=rtBG.Left;
|
|
59088
59122
|
rtDraw.Top=rtBG.Top;
|
|
@@ -59092,6 +59126,24 @@ function ChartDrawHLine()
|
|
|
59092
59126
|
this.DrawButton(rtBG.Top, rtBG.Right, lineHeight, rtDraw);
|
|
59093
59127
|
}
|
|
59094
59128
|
|
|
59129
|
+
//计算右侧价格标签大小
|
|
59130
|
+
this.CalculateValueText=function(y)
|
|
59131
|
+
{
|
|
59132
|
+
var yValue=this.Frame.GetYData(y,false);
|
|
59133
|
+
var strValue=yValue.toFixed(this.Precision);
|
|
59134
|
+
if (this.LableInfo &&this.LableInfo.PriceSuffixText) strValue+=this.LableInfo.PriceSuffixText;
|
|
59135
|
+
|
|
59136
|
+
this.Canvas.font=this.Font;
|
|
59137
|
+
var textWidth=this.Canvas.measureText(strValue).width;
|
|
59138
|
+
var lineHeight=this.GetFontHeight();
|
|
59139
|
+
|
|
59140
|
+
var size={ Width:textWidth, Height:lineHeight };
|
|
59141
|
+
size.Height+=(this.TextMargin.Top+this.TextMargin.Bottom);
|
|
59142
|
+
size.Width+=(this.TextMargin.Left+this.TextMargin.Right);
|
|
59143
|
+
|
|
59144
|
+
return size;
|
|
59145
|
+
}
|
|
59146
|
+
|
|
59095
59147
|
this.DrawPriceText=function(text, ptStart, ptEnd, position)
|
|
59096
59148
|
{
|
|
59097
59149
|
if (position!=1 && position!=0) return;
|