hqchart 1.1.15091 → 1.1.15104
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
|
@@ -1703,7 +1703,9 @@ ON_CLICK_CHART_CELL:171,//点击图形单元
|
|
|
1703
1703
|
GET_DEFAULT_INDEX_PARAM:172,//获取指标默认参数
|
|
1704
1704
|
ON_RELOAD_RESOURCE:173,ON_REPORT_DATA_FILTER:174,//数据筛选
|
|
1705
1705
|
ON_REPORT_SHOW_TOOLTIP:175,//报价列表 提示信息\
|
|
1706
|
-
ON_FORMAT_TVLONGPOSITION_LABEL:176,ON_FORMAT_COUNTDOWN_TEXT:177
|
|
1706
|
+
ON_FORMAT_TVLONGPOSITION_LABEL:176,ON_FORMAT_COUNTDOWN_TEXT:177,//倒计时
|
|
1707
|
+
ON_CLICK_INDEX_LOCK:178,//点击指标锁
|
|
1708
|
+
ON_CORSSCURSOR_STATUS_CHANGE:179//十字光标状态改变
|
|
1707
1709
|
};var JSCHART_OPERATOR_ID={OP_SCROLL_LEFT:1,//往左移动
|
|
1708
1710
|
OP_SCROLL_RIGHT:2,//往右移动
|
|
1709
1711
|
OP_ZOOM_OUT:3,//缩小
|
|
@@ -1823,7 +1825,8 @@ CLOSE_ID:5000,//15:00 后,首先发 CLOSE 标志
|
|
|
1823
1825
|
ENDTR_ID:6000,//交易结束
|
|
1824
1826
|
//上面状态个位数 是停牌状态 如3001 连续交易时间段停牌
|
|
1825
1827
|
SUSP_ID:1//停牌
|
|
1826
|
-
|
|
1828
|
+
//十字光标状态
|
|
1829
|
+
};var JSCHART_CORSSCURSOR_STATUS_ID={NONE_ID:0,LINE_ID:1,LEFT_TEXT_ID:2,LEFT_INTER_TEXT_ID:4,RIGHT_TEXT_ID:8,RIGHT_INTER_TEXT_ID:16,BOTTOM_TEXT_ID:32};function PhoneDBClick(){this.Start=[];this.Clear=function(){this.Start=[];};this.AddTouchStart=function(x,y,time){if(this.Start.length>0){var item=this.Start[this.Start.length-1];var spanTime=time-item.Time;if(spanTime>0&&spanTime<300){this.Start.push({X:x,Y:y,Time:time});}else{this.Start=[];}}else{this.Start.push({X:x,Y:y,Time:time});}};this.IsVaildDBClick=function(){if(this.Start.length==2)return true;return false;};this.AddTouchEnd=function(time){if(this.Start.length<=0)return;var item=this.Start[this.Start.length-1];var spanTime=time-item.Time;if(spanTime>=0&&spanTime<150){}else{this.Start=[];}};}/*
|
|
1827
1830
|
图形控件
|
|
1828
1831
|
*/function JSChartContainer(uielement,OffscreenElement,cacheElement){var _this9=this;this.ClassName='JSChartContainer';var _self=this;this.Frame;//框架画法
|
|
1829
1832
|
this.ChartPaint=new Array();//图形画法
|
|
@@ -1904,7 +1907,8 @@ SelectedXBorder:{Mode:0,Date:null},//X边框选中模式 Mode:0=禁用 分时图
|
|
|
1904
1907
|
RightHorizontal:{//Show:true,
|
|
1905
1908
|
//Width:5
|
|
1906
1909
|
},//锁十字光标
|
|
1907
|
-
LockCorssCursor:{X:{Enable:false}}
|
|
1910
|
+
LockCorssCursor:{X:{Enable:false}},CorssCursorStatus:{Value:null},//十字光标状态 只读
|
|
1911
|
+
//图形中的单元选中状态
|
|
1908
1912
|
MapIndexChartCache:new _map2.default(),//key 指标GUID
|
|
1909
1913
|
TradeStatus:null,//当前交易状态 { Date, Time:数据最后更新的时间, Status: }
|
|
1910
1914
|
LatestPoint:null//最新的点位置 { X:, Y: }
|
|
@@ -1937,7 +1941,8 @@ this.KeyboardMove={Timer:null,Delay:100,PressTime:500,Enable:false,Event:null};/
|
|
|
1937
1941
|
this.MapEventListenerCache=new _map2.default();//addEventListener 监听事件 key=type:"keydown|keyup ....", value:{ Callback:, Option: }
|
|
1938
1942
|
this.AddEventListener=function(eventTarget,type,listener,option){if(!eventTarget||!type||!listener)return false;var callback=listener.bind(this);var item={Callback:callback,Option:option,Type:type,Element:eventTarget};eventTarget.addEventListener(type,callback,option);this.MapEventListenerCache.set(item.Type,item);return true;};this.RemoveEventListener=function(eventTarget,type){if(!eventTarget||!type)return false;if(!this.MapEventListenerCache.has(type))return false;var item=this.MapEventListenerCache.get(type);if(!item.Element||!item.Callback)return false;this.MapEventListenerCache.delete(item.Type);item.Element.removeEventListener(item.Type,item.Callback,item.Option);};//option={ KeyDown:, Wheel }
|
|
1939
1943
|
this.AddDefaultEventListener=function(option){var _this4=this;var bRegisterKeydown=true;var bRegisterWheel=true;if(option){if(IFrameSplitOperator.IsBool(option.KeyDown))bRegisterKeydown=option.KeyDown;if(IFrameSplitOperator.IsBool(option.Wheel))bRegisterWheel=option.Wheel;}if(bRegisterKeydown){this.AddEventListener(this.UIElement,"keydown",function(e){_this4.OnKeyDown(e);},true);this.AddEventListener(this.UIElement,"keyup",function(e){_this4.OnKeyUp(e);},true);}if(bRegisterWheel){this.AddEventListener(this.UIElement,"wheel",function(e){_this4.OnWheel(e);},true);}JSConsole.Chart.Log('[JSChartContainer::AddDefaultEventListener] [keydown,keyup]='+bRegisterKeydown+', [wheel]='+bRegisterWheel);};this.RemoveAllEventListener=function(){var _iteratorNormalCompletion2=true;var _didIteratorError2=false;var _iteratorError2=undefined;try{for(var _iterator2=(0,_getIterator3.default)(this.MapEventListenerCache),_step2;!(_iteratorNormalCompletion2=(_step2=_iterator2.next()).done);_iteratorNormalCompletion2=true){var mapItem=_step2.value;var item=mapItem[1];if(!item.Element||!item.Callback)continue;item.Element.removeEventListener(item.Type,item.Callback,item.Option);}}catch(err){_didIteratorError2=true;_iteratorError2=err;}finally{try{if(!_iteratorNormalCompletion2&&_iterator2.return){_iterator2.return();}}finally{if(_didIteratorError2){throw _iteratorError2;}}}this.MapEventListenerCache.clear();};this.ClearGlobalOption=function(){if(!this.GlobalOption)return;this.GlobalOption.LatestPoint=null;this.GlobalOption.TradeStatus=null;this.GlobalOption.CountDown=null;};this.RestoreFocus=function(delay){var _this5=this;var value=1000;if(IFrameSplitOperator.IsNumber(delay))value=delay;this.ClearRestoreFocusTimer();this.RestoreFocusTimer=setTimeout(function(){_this5.SetFocus();},value);};this.ClearRestoreFocusTimer=function(){if(this.RestoreFocusTimer){clearTimeout(this.RestoreFocusTimer);this.RestoreFocusTimer=null;}};this.GetVolUnit=function()//成交量单位
|
|
1940
|
-
{var upperSymbol=this.Symbol?this.Symbol.toUpperCase():null;var unit=MARKET_SUFFIX_NAME.GetVolUnit(upperSymbol);return unit;};this.ClearStockCache=function(){this.StockCache.Data=null;this.BuySellData.AryBuy=null;this.BuySellData.ArySell=null;};this.
|
|
1944
|
+
{var upperSymbol=this.Symbol?this.Symbol.toUpperCase():null;var unit=MARKET_SUFFIX_NAME.GetVolUnit(upperSymbol);return unit;};this.ClearStockCache=function(){this.StockCache.Data=null;this.BuySellData.AryBuy=null;this.BuySellData.ArySell=null;};this.UpdateCorssCursorStatus=function(){if(!this.ChartCorssCursor)return false;if(!this.GlobalOption||!this.GlobalOption.CorssCursorStatus)return false;var status=this.ChartCorssCursor.Status;//状态改变了
|
|
1945
|
+
if(this.GlobalOption.CorssCursorStatus.Value!=status){this.GlobalOption.CorssCursorStatus.Value=status;var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CORSSCURSOR_STATUS_CHANGE);if(event&&event.Callback){var sendData={Status:status,IsShowLine:(status&JSCHART_CORSSCURSOR_STATUS_ID.LINE_ID)>0};event.Callback(event,sendData,this);}}return true;};this.InitalPopMenu=function()//初始化弹出窗口
|
|
1941
1946
|
{if(this.JSPopMenu)return;this.JSPopMenu=new JSPopMenu();//内置菜单
|
|
1942
1947
|
this.JSPopMenu.Inital(this);};this.InitalDrawToolDialog=function(){if(this.DialogDrawTool)return;this.DialogDrawTool=new JSDialogDrawTool();this.DialogDrawTool.Inital(this);this.DialogDrawTool.Create();};this.InitalTooltipDialog=function(option){if(this.DialogTooltip)return;this.DialogTooltip=new JSDialogTooltip();this.DialogTooltip.Inital(this,option);this.DialogTooltip.Create();};this.InitalFloatTooltip=function(option){if(this.FloatTooltip)return;this.FloatTooltip=new JSFloatTooltip();this.FloatTooltip.Inital(this,option);this.FloatTooltip.Create();};this.InitalSmallFloatTooltip=function(option){if(this.SmallFloatTooltipGroup)return;this.SmallFloatTooltipGroup=new JSSmallFloatTooltipGroup();this.SmallFloatTooltipGroup.Inital(this,option);this.SmallFloatTooltipGroup.Create();};this.InitalModifyDrawDialog=function(){if(this.DialogModifyDraw)return;this.DialogModifyDraw=new JSDialogModifyDraw();this.DialogModifyDraw.Inital(this);this.DialogModifyDraw.Create();};this.InitalSelectRectDialog=function(option){if(this.DialogSelectRect)return;this.DialogSelectRect=new JSDialogSelectRect();this.DialogSelectRect.Inital(this,option);this.DialogSelectRect.Create();};this.InitalSearchIndexDialog=function(option){if(this.DialogSearchIndex)return;this.DialogSearchIndex=new JSDialogSearchIndex();this.DialogSearchIndex.Inital(this,option);this.DialogSearchIndex.Create();};this.InitalModifyIndexParamDialog=function(option){if(this.DialogModifyIndexParam)return;this.DialogModifyIndexParam=new JSDialogModifyIndexParam();this.DialogModifyIndexParam.Inital(this,option);this.DialogModifyIndexParam.Create();};this.ShowChangeIndexDialog=function(data){if(!data)return;if(!this.DialogSearchIndex)return;data.Title='\u5207\u6362\u6307\u6807 [\u7A97\u53E3'+(data.WindowIndex+1)+']';this.DialogSearchIndex.SetOpData(data);this.DialogSearchIndex.Show();};this.ShowAddOverlayIndexDialog=function(data){if(!data)return;if(!this.DialogSearchIndex)return;data.Title='\u6DFB\u52A0\u53E0\u52A0\u6307\u6807 [\u7A97\u53E3'+(data.WindowIndex+1)+']';this.DialogSearchIndex.SetOpData(data);this.DialogSearchIndex.Show();};//添加指标窗口
|
|
1943
1948
|
this.ShowAddIndexWindowDialog=function(option){if(!this.DialogSearchIndex)return;var data=option;if(!data)data={};data.OpType=3;data.Title='\u589E\u52A0\u6307\u6807\u7A97\u53E3';this.DialogSearchIndex.SetOpData(data);this.DialogSearchIndex.Show();};this.ShowModifyIndexParamDialog=function(data){if(!this.DialogModifyIndexParam)return;if(data.Type==1){var indexScript=this.WindowIndex[data.WindowIndex];if(!indexScript)return;data.IndexScript=indexScript;data.Title='['+indexScript.Name+']\u53C2\u6570\u4FEE\u6539 \u7A97\u53E3['+(data.WindowIndex+1)+']';}else if(data.Type==2){var overlayIndex=this.GetOverlayIndexByIdentify(data.Identify);if(!overlayIndex||!overlayIndex.OverlayItem.Script)return;var indexScript=overlayIndex.OverlayItem.Script;data.IndexScript=indexScript;data.Title='['+indexScript.Name+']\u53C2\u6570\u4FEE\u6539 \u53E0\u52A0\u7A97\u53E3['+(data.WindowIndex+1)+']';}this.DialogModifyIndexParam.SetIndexData(data);this.DialogModifyIndexParam.Show();};this.DrawSelectRectDialog=function(){};this.IsShowSelectRectDialog=function(){if(!this.DialogSelectRect)return false;return this.DialogSelectRect.IsShow();};this.ShowDrawToolDialog=function(x,y){if(!this.DialogDrawTool)return;var rtClient=this.UIElement.getBoundingClientRect();var rtScroll=GetScrollPosition();var top=this.UIElement.offsetTop+15;var left=this.UIElement.offsetWidth-this.DialogDrawTool.DivDialog.offsetWidth-15;left+=rtClient.left+rtScroll.Left;top+=rtClient.top+rtScroll.Top;this.DialogDrawTool.Show(left,top);};this.IsShowDrawToolDialog=function(){if(!this.DialogDrawTool)return false;return this.DialogDrawTool.IsShow();};this.ShowModifyDrawDialog=function(chart,x,y){if(!this.DialogModifyDraw)return;this.DialogModifyDraw.SetChartPicture(chart);if(this.DialogModifyDraw.IsShow())return;var rtClient=this.UIElement.getBoundingClientRect();var rtScroll=GetScrollPosition();var top=this.UIElement.offsetTop+15;var left=(this.UIElement.offsetWidth-this.DialogModifyDraw.DivDialog.offsetWidth)/2;left+=rtClient.left+rtScroll.Left;top+=rtClient.top+rtScroll.Top;this.DialogModifyDraw.Show(left,top);};this.CloseModifyDrawDialog=function(){if(!this.DialogModifyDraw)return;this.DialogModifyDraw.Close();};this.IsShowTooltipDialog=function(){if(!this.DialogTooltip)return false;return this.DialogTooltip.IsShow();};this.CloseTooltipDialog=function(){if(!this.DialogTooltip)return;this.DialogTooltip.Close();};this.HideFloatTooltip=function(){if(!this.FloatTooltip)return;this.FloatTooltip.Hide();};this.HideSmallFloatTooltip=function(){if(!this.SmallFloatTooltipGroup)return;this.SmallFloatTooltipGroup.Hide();};this.DestroyTooltipDialog=function(){if(!this.DialogTooltip)return;this.DialogTooltip.Destroy();this.DialogTooltip=null;};this.DestroyFloatTooltip=function(){if(!this.FloatTooltip)return;this.FloatTooltip.Destroy();this.FloatTooltip=null;};this.DestroySmallFloatTooltip=function(){if(!this.SmallFloatTooltipGroup)return;this.SmallFloatTooltipGroup.Destroy();this.SmallFloatTooltipGroup=null;};this.DestroySearchIndexDialog=function(){if(!this.DialogSearchIndex)return;this.DialogSearchIndex.Destroy();this.DialogSearchIndex=null;};this.DestroyDialogDrawTool=function(){if(!this.DialogDrawTool)return;this.DialogDrawTool.Destroy();this.DialogDrawTool=null;};this.DestroyDialogModifyIndexParam=function(){if(!this.DialogModifyIndexParam)return;this.DialogModifyIndexParam.Destroy();this.DialogModifyIndexParam=null;};this.DestroyDialogSelectRect=function(){if(!this.DialogSelectRect)return;this.DialogSelectRect.Destroy();this.DialogSelectRect=null;};this.DestroyDialogModifyDraw=function(){if(!this.DialogModifyDraw)return;this.DialogModifyDraw.Destroy();this.DialogModifyDraw=null;};this.DestroyPopMenu=function(){if(!this.JSPopMenu)return;this.JSPopMenu.Destroy();this.JSPopMenu=null;};//隐藏内置的弹框div
|
|
@@ -2114,7 +2119,7 @@ for(var i=0;i<this.OverlayChartPaint.length;++i){var item=this.OverlayChartPaint
|
|
|
2114
2119
|
for(var i=0;i<this.ExtendChartPaint.length;++i){var item=this.ExtendChartPaint[i];item.Canvas=canvas;}};//清空画布
|
|
2115
2120
|
this.ClearCanvas=function(canvas){if(!canvas)return;if(!this.UIElement)return;canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);};this.ClearCorssCursorCanvas=function(){if(!this.CorssCursorCanvas)return;this.CorssCursorCanvas.clearRect(0,0,this.CorssCursorElement.width,this.CorssCursorElement.height);};this.Draw=function(){var _this14=this;if(this.ChartCorssCursor)this.ChartCorssCursor.Status=0;if(this.UIElement.width<=0||this.UIElement.height<=0)return;this.StopDrawDynamicInfo();this.ClearCorssCursorCanvas();var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_BEFORE_DRAW);if(event&&event.Callback){var sendData={};event.Callback(event,sendData,this);}this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);if(this.CacheCanvas)this.CacheCanvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);var pixelTatio=GetDevicePixelRatio();//获取设备的分辨率
|
|
2116
2121
|
this.Canvas.lineWidth=pixelTatio;//手机端需要根据分辨率比调整线段宽度
|
|
2117
|
-
if(this.ChartSplashPaint&&this.ChartSplashPaint.IsEnableSplash){var data=this.InvokeBeforeDrawSplashScreenCallback();if(data&&data.PreventDefault===true)return;this.Frame.ClearCoordinateText();this.Frame.Draw({IsEnableSplash:this.ChartSplashPaint.IsEnableSplash});this.ChartSplashPaint.Draw();return;}if(this.CacheCanvas)this.SetCanvas(this.CacheCanvas);//框架
|
|
2122
|
+
if(this.ChartSplashPaint&&this.ChartSplashPaint.IsEnableSplash){var data=this.InvokeBeforeDrawSplashScreenCallback();if(data&&data.PreventDefault===true)return;this.Frame.ClearCoordinateText();this.Frame.Draw({IsEnableSplash:this.ChartSplashPaint.IsEnableSplash});this.ChartSplashPaint.Draw();this.UpdateCorssCursorStatus();return;}if(this.CacheCanvas)this.SetCanvas(this.CacheCanvas);//框架
|
|
2118
2123
|
if(this.Frame.SetBeforeDrawXYCallback){this.Frame.SetBeforeDrawXYCallback(function(frame){_this14.BeforeDrawXYCoordinate(frame);});}this.Frame.Draw();if(this.Frame.DrawCustomVertical){var eventCVericalDraw=this.GetEventCallback(JSCHART_EVENT_ID.ON_CUSTOM_VERTICAL_DRAW);this.Frame.DrawCustomVertical(eventCVericalDraw);}this.Frame.CalculateLock();for(var i=0;i<this.ChartDrawPicture.length;++i){var item=this.ChartDrawPicture[i];if(!item.IsDrawMain)continue;if(item.IsDrawMain())item.MainDraw();}//框架内图形
|
|
2119
2124
|
for(var i=0;i<this.ChartPaint.length;++i){var item=this.ChartPaint[i];if(item.IsDrawFirst)item.Draw();}this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_5);if(this.Frame.DrawOveraly)this.Frame.DrawOveraly(true);//画叠加指标
|
|
2120
2125
|
for(var i=0;i<this.ChartPaint.length;++i){var item=this.ChartPaint[i];if(!item.IsDrawFirst)item.Draw();}for(var i=0;i<this.ChartPaintEx.length;++i){var item=this.ChartPaintEx[i];item.Draw();}//叠加股票
|
|
@@ -2176,7 +2181,7 @@ item.Draw();}if(this.SelectChartDrawPicture)this.SelectChartDrawPicture.Draw();i
|
|
|
2176
2181
|
*/this.OffscreenToShowCanvas();//更新滚动条
|
|
2177
2182
|
if(typeof this.UpdateScrollBar=='function')this.UpdateScrollBar();if(this.LastMouseStatus.MouseOnToolbar)//工具栏按钮提示信息
|
|
2178
2183
|
{var frame=this.LastMouseStatus.MouseOnToolbar.Frame;if(frame&&frame.DrawToolbarTooltip)frame.DrawToolbarTooltip(this.LastMouseStatus.MouseOnToolbar);}if(bDrawDialogTooltip)this.DrawTooltipDialog();//发送图形状态给外部
|
|
2179
|
-
if(this.mapEvent.has(JSCHART_EVENT_ID.CHART_STATUS)){var event=this.mapEvent.get(JSCHART_EVENT_ID.CHART_STATUS);var data={};if(typeof this.GetChartStatus=='function')data=this.GetChartStatus();event.Callback(event,data,this);}++this.TouchDrawCount;};this.DrawExtendChartPaint=function(level,option){if(!IFrameSplitOperator.IsNonEmptyArray(this.ExtendChartPaint))return;//扩展图形
|
|
2184
|
+
if(this.mapEvent.has(JSCHART_EVENT_ID.CHART_STATUS)){var event=this.mapEvent.get(JSCHART_EVENT_ID.CHART_STATUS);var data={};if(typeof this.GetChartStatus=='function')data=this.GetChartStatus();event.Callback(event,data,this);}++this.TouchDrawCount;this.UpdateCorssCursorStatus();};this.DrawExtendChartPaint=function(level,option){if(!IFrameSplitOperator.IsNonEmptyArray(this.ExtendChartPaint))return;//扩展图形
|
|
2180
2185
|
for(var i=0;i<this.ExtendChartPaint.length;++i){var item=this.ExtendChartPaint[i];if(item.IsCallbackDraw)continue;var value=item.GetPriority();//绘图优先级
|
|
2181
2186
|
if(value!=level)continue;if(level==IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_20){item.Draw();if(item.DrawToolbar&&option)item.DrawToolbar(option.MoveonPoint,option.LastMouseStatus);}else if(level==IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_25&&option){if(item.ClassName=='KLineTooltipPaint'&&option){if(option.Tooltip==false)continue;if(option.Point)item.LatestPoint=option.Point;}else if(item.ClassName=="MinuteTooltipPaint"&&option){if(option.Point)item.LatestPoint=option.Point;}item.Draw(option.MoveonPoint,option.LastMouseStatus);}else{item.Draw();}}};this.PtInButton=function(x,y){var button=this.Frame.PtInButtons(x,y);if(button)return{Name:"FrameButton",Button:button};button=this.PtInExtendChartButtons(x,y);if(button)return{Name:"ExtendChartButton",Button:button};button=this.PtInDrawPictureButtons(x,y);if(button)return{Name:"DrawPictureButton",Button:button};button=this.PtInTitleButtons(x,y);if(button)return{Name:"TitleButton",Button:button};return null;};this.DrawDrawPictureXYCoordinate=function(){var actionDrawPicture=null;//当前激活的画图
|
|
2182
2187
|
if(this.CurrentChartDrawPicture)actionDrawPicture=this.CurrentChartDrawPicture;else if(this.SelectChartDrawPicture)actionDrawPicture=this.SelectChartDrawPicture;//画图工具显示点在Y轴的刻度
|
|
@@ -2207,43 +2212,9 @@ if(this.ChartCorssCursor){this.ChartCorssCursor.LastPoint=corssCursorPos.LastPoi
|
|
|
2207
2212
|
{this.ChartCorssCursor.Canvas=this.CorssCursorCanvas;this.ChartCorssCursor.Canvas.clearRect(0,0,this.CorssCursorElement.width,this.CorssCursorElement.height);bRestoreCanvas=true;}if(option&&option.Corss==false){}else if(this.DragMode==JSCHART_DRAG_ID.CLICK_TOUCH_MODE_ID){if(this.TouchStatus.CorssCursorShow==true)this.ChartCorssCursor.Draw();}else if(this.EnableClickModel){if(this.ClickModel.IsShowCorssCursor===true)this.ChartCorssCursor.Draw();}else if(this.IsOnTouch===false&&this.CurrentChartDrawPicture&&this.CurrentChartDrawPicture.IsShowCorssCursor===true)//开始绘图
|
|
2208
2213
|
{this.ChartCorssCursor.Draw();}else if(!(this.IsOnTouch===false&&this.CorssCursorTouchEnd===true)&&!this.CurrentChartDrawPicture){this.ChartCorssCursor.Draw();}else if(this.IsOnTouch===true&&this.CurrentChartDrawPicture&&this.EnableShowCorssCursor&&this.EnableShowCorssCursor.DrawPicture==true){this.ChartCorssCursor.Draw();}if(bRestoreCanvas){this.ChartCorssCursor.Canvas=this.Canvas;}bDrawDialogTooltip=true;}var ptPosition=null;//鼠标位置 null 无效 -1 在外面 >=0 对应的指标窗口中ID
|
|
2209
2214
|
if(option&&option.Point&&(option.ParentFunction=='OnMouseMove'||option.ParentFunction=='MoveCorssCursorIndex')){ptPosition=this.Frame.PtInFrame(option.Point.X,option.Point.Y);}var drawStatus=this.GetDrawStatus();drawStatus.DrawName="DrawDynamicInfo";for(var i=0;i<this.TitlePaint.length;++i){var item=this.TitlePaint[i];if(!item.IsDynamic)continue;item.CursorIndex=corssCursorPos.CursorIndex;item.LastPoint=this.LastPoint;if(item.OnDrawEvent){item.OnDrawEvent.FunctionName='DrawDynamicInfo';item.OnDrawEvent.PointPosition=ptPosition;if(this.IsLockCorssCursor()){if(item.OnDrawEvent.PointPosition<0)item.OnDrawEvent.PointPosition=0;}}item.DrawStatus=drawStatus;var pointInfo=null;if(option&&IFrameSplitOperator.IsNumber(option.ClientPos)&&option.Point)//当前鼠标所在位置的详细信息 包含盘前盘后
|
|
2210
|
-
{pointInfo={ClientPos:option.ClientPos,Point:{X:option.Point.X,Y:option.Point.Y}};if(this.IsLockCorssCursor()){if(pointInfo.ClientPos<=0)pointInfo.ClientPos=1;}}item.PointInfo=pointInfo;item.Draw(moveonPoint,this.LastMouseStatus);}var exChartOption={MoveonPoint:moveonPoint,LastMouseStatus:this.LastMouseStatus};if(option){exChartOption.Tooltip=option.Tooltip;exChartOption.Point=option.Point;}this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_25,exChartOption)
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
var item=this.ExtendChartPaint[i];
|
|
2214
|
-
if (item.IsCallbackDraw) continue;
|
|
2215
|
-
if (item.DrawAfterPicture) continue;
|
|
2216
|
-
if (item.ClassName=='KLineTooltipPaint' && option)
|
|
2217
|
-
{
|
|
2218
|
-
if (option.Tooltip==false) continue;
|
|
2219
|
-
if (option.Point) item.LatestPoint=option.Point;
|
|
2220
|
-
}
|
|
2221
|
-
else if (item.ClassName=="MinuteTooltipPaint" && option)
|
|
2222
|
-
{
|
|
2223
|
-
if (option.Point) item.LatestPoint=option.Point;
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
if (item.IsDynamic && item.DrawAfterTitle===true) item.Draw(moveonPoint, this.LastMouseStatus);
|
|
2227
|
-
}
|
|
2228
|
-
*/if(this.EnableAnimation)this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_30);/*
|
|
2229
|
-
if (this.EnableAnimation)
|
|
2230
|
-
{
|
|
2231
|
-
for(var i=0;i<this.ExtendChartPaint.length;++i) //动画
|
|
2232
|
-
{
|
|
2233
|
-
var item=this.ExtendChartPaint[i];
|
|
2234
|
-
if (item.IsAnimation===true) item.Draw();
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
*/for(var i=0;i<this.ChartDrawPicture.length;++i){var item=this.ChartDrawPicture[i];if(item.IsDrawFirst)continue;if(item.IsDrawMain&&item.IsDrawMain()){if(item.MainPartDraw)item.MainPartDraw();continue;}if(this.SelectChartDrawPicture&&item.Guid==this.SelectChartDrawPicture.Guid)continue;//选中画图最后画 确保显示在最外面
|
|
2238
|
-
item.Draw(moveonPoint,this.LastMouseStatus);}if(this.SelectChartDrawPicture){this.SelectChartDrawPicture.Draw(moveonPoint,this.LastMouseStatus);}if(this.CurrentChartDrawPicture&&this.CurrentChartDrawPicture.Status!=10){this.CurrentChartDrawPicture.Draw();}this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_50);/*
|
|
2239
|
-
for(var i=0;i<this.ExtendChartPaint.length;++i) //动态扩展图形
|
|
2240
|
-
{
|
|
2241
|
-
var item=this.ExtendChartPaint[i];
|
|
2242
|
-
if (item.DrawAfterPicture)
|
|
2243
|
-
item.Draw();
|
|
2244
|
-
}
|
|
2245
|
-
*/if(this.LastMouseStatus.MouseOnToolbar)//工具栏按钮提示信息
|
|
2246
|
-
{var frame=this.LastMouseStatus.MouseOnToolbar.Frame;if(frame&&frame.DrawToolbarTooltip)frame.DrawToolbarTooltip(this.LastMouseStatus.MouseOnToolbar);}this.OffscreenToShowCanvas();if(bDrawDialogTooltip)this.DrawTooltipDialog();++this.TouchDrawCount;};this.DrawAnimation=function()//绘制动画 如弹幕
|
|
2215
|
+
{pointInfo={ClientPos:option.ClientPos,Point:{X:option.Point.X,Y:option.Point.Y}};if(this.IsLockCorssCursor()){if(pointInfo.ClientPos<=0)pointInfo.ClientPos=1;}}item.PointInfo=pointInfo;item.Draw(moveonPoint,this.LastMouseStatus);}var exChartOption={MoveonPoint:moveonPoint,LastMouseStatus:this.LastMouseStatus};if(option){exChartOption.Tooltip=option.Tooltip;exChartOption.Point=option.Point;}this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_25,exChartOption);if(this.EnableAnimation)this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_30);for(var i=0;i<this.ChartDrawPicture.length;++i){var item=this.ChartDrawPicture[i];if(item.IsDrawFirst)continue;if(item.IsDrawMain&&item.IsDrawMain()){if(item.MainPartDraw)item.MainPartDraw();continue;}if(this.SelectChartDrawPicture&&item.Guid==this.SelectChartDrawPicture.Guid)continue;//选中画图最后画 确保显示在最外面
|
|
2216
|
+
item.Draw(moveonPoint,this.LastMouseStatus);}if(this.SelectChartDrawPicture){this.SelectChartDrawPicture.Draw(moveonPoint,this.LastMouseStatus);}if(this.CurrentChartDrawPicture&&this.CurrentChartDrawPicture.Status!=10){this.CurrentChartDrawPicture.Draw();}this.DrawExtendChartPaint(IExtendChartPainting.DRAW_PRIORITY_ID.LEVEL_50);if(this.LastMouseStatus.MouseOnToolbar)//工具栏按钮提示信息
|
|
2217
|
+
{var frame=this.LastMouseStatus.MouseOnToolbar.Frame;if(frame&&frame.DrawToolbarTooltip)frame.DrawToolbarTooltip(this.LastMouseStatus.MouseOnToolbar);}this.OffscreenToShowCanvas();if(bDrawDialogTooltip)this.DrawTooltipDialog();++this.TouchDrawCount;this.UpdateCorssCursorStatus();};this.DrawAnimation=function()//绘制动画 如弹幕
|
|
2247
2218
|
{if(!this.EnableAnimation)return;if(this.Frame.ScreenImageData&&!this.IsOnTouch){for(var i=0;i<this.ExtendChartPaint.length;++i){var item=this.ExtendChartPaint[i];if(item.IsAnimation===true)item.IsMoveStep=true;//移动弹幕
|
|
2248
2219
|
}this.DrawDynamicInfo();}var self=this;window.requestAnimationFrame(function(){self.DrawAnimation();});};this.StartAnimation=function(option){var bCreated=false;//是否已经创建了弹幕画法
|
|
2249
2220
|
var barrageData=null;for(var i=0;i<this.ExtendChartPaint.length;++i){var item=this.ExtendChartPaint[i];if(item.ClassName==='BarragePaint'){bCreated=true;barrageData=item.BarrageList;break;}}if(!bCreated){var chart=new BarragePaint();chart.Canvas=this.Canvas;chart.ChartBorder=this.Frame.ChartBorder;chart.ChartFrame=this.Frame;chart.HQChart=this;chart.SetOption(option);this.ExtendChartPaint.push(chart);barrageData=chart.BarrageList;}this.EnableAnimation=true;var self=this;window.requestAnimationFrame(function(){self.DrawAnimation();});return barrageData;};this.StopAnimation=function(){this.EnableAnimation=false;this.DrawDynamicInfo();};this.GetChartTooltipData=function(x,y,option){var toolTip=new TooltipData();if(this.ChartInfoPaint){if(this.ChartInfoPaint.GetTooltipData(x,y,toolTip))return toolTip;}if(this.PtInChartPaintTooltip(x,y,toolTip))return toolTip;if(IFrameSplitOperator.IsNonEmptyArray(this.Frame.SubFrame)){for(var i=0;i<this.Frame.SubFrame.length;++i){var subFrame=this.Frame.SubFrame[i];for(var j=0;j<subFrame.OverlayIndex.length;++j){var overlayItem=subFrame.OverlayIndex[j];for(var k=0;k<overlayItem.ChartPaint.length;++k){var item=overlayItem.ChartPaint[k];if(item.GetTooltipData(x,y,toolTip))return toolTip;}}}}if(this.PtInOverlayChartPaintTooltip(x,y,toolTip))return toolTip;if(this.PtInExtendChartPaintTooltip(x,y,toolTip))return toolTip;return null;};this.GetCorssCursorTooltipData=function(option){if(!this.ChartCorssCursor)return null;if(this.ChartCorssCursor.Status===0)return null;if(!this.ChartCorssCursor.IsShowCorss)return null;var kItem=this.ChartCorssCursor.StringFormatX.KItem;if(!kItem)return null;//X轴取十字光标坐标
|
|
@@ -5022,21 +4993,18 @@ function ChartDrawFlagText(){this.newMethod=IChartPainting;//派生
|
|
|
5022
4993
|
this.newMethod();delete this.newMethod;this.ClassName="ChartDrawFlagText";this.MapCache=null;//key=date/date-time value={ Date:, Time:, Data:[ ] }
|
|
5023
4994
|
this.AryData=[];this.GetKValue=ChartData.GetKValue;this.BuildCacheData=function(){var mapData=new _map2.default();this.MapCache=mapData;if(!this.Data||!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data))return;if(!IFrameSplitOperator.IsNonEmptyArray(this.AryData))return;for(var i=0;i<this.Data.Data.length;++i){var item=this.AryData[i];if(!item)continue;var kItem=this.Data.Data[i];item.Date=kItem.Date;item.Time=kItem.Time;var key=this.BuildKey(kItem);mapData.set(key,item);}};this.Draw=function(){};this.GetCorssCursorTooltipData=function(kItem,tooltip){if(!kItem)return null;if(!this.MapCache)return null;var key=this.BuildKey(kItem);if(!this.MapCache.has(key))return null;var item=this.MapCache.get(key);if(item.YValue>this.ChartFrame.HorizontalMax||item.YValue<this.ChartFrame.HorizontalMin)return null;var y=this.ChartFrame.GetYFromData(item.YValue,false);tooltip.AryData.push({Data:item,Y:y,ChartPaint:this,Type:1});return item;};this.GetMaxMin=function(){return{Min:null,Max:null};};}//锁 支持横屏
|
|
5024
4995
|
function ChartLock(){this.newMethod=IChartPainting;//派生
|
|
5025
|
-
this.newMethod();delete this.newMethod;this.ClassName="ChartLock";this.
|
|
5026
|
-
this.LockCount=20;// 锁最新的几个数据
|
|
4996
|
+
this.newMethod();delete this.newMethod;this.ClassName="ChartLock";this.LockCount=20;// 锁最新的几个数据
|
|
5027
4997
|
this.BGColor=g_JSChartResource.IndexLock.BGColor;this.TextColor=g_JSChartResource.IndexLock.TextColor;this.Font=g_JSChartResource.IndexLock.Font;this.Title=g_JSChartResource.IndexLock.Title;this.LockRect=null;//上锁区域
|
|
5028
4998
|
this.LockID;//锁ID
|
|
5029
4999
|
this.Callback;//回调
|
|
5030
5000
|
this.IndexName;//指标名字
|
|
5031
5001
|
this.IndexID;//指标ID
|
|
5032
|
-
this.MinWidth=null;//最小宽度
|
|
5033
5002
|
this.CalculateTextSize=function(aryText,defaultFont,out){if(!out||!IFrameSplitOperator.IsNonEmptyArray(aryText))return false;this.Canvas.font=defaultFont;var lineHeight=this.Canvas.measureText("擎").width;//行高
|
|
5034
|
-
var height=0,width=0;out.AryText=[];for(var i=0;i<aryText.length;++i){var item=aryText[i];if(!item||!item.Text)continue;var textWidth=this.Canvas.measureText(item.Text).width;var lineItem={Text:item.Text,Width:textWidth,Height:lineHeight,Color:item.Color,TextMargin:{Top:0,Bottom:0,Left:0,Right:0},YOffset:0};if(IFrameSplitOperator.IsNumber(item.YOffset))lineItem.YOffset=item.YOffset;if(item.TextMargin){var margin=item.TextMargin;if(IFrameSplitOperator.IsNumber(margin.Top))lineItem.TextMargin.Top=margin.Top;if(IFrameSplitOperator.IsNumber(margin.Bottom))lineItem.TextMargin.Bottom=margin.Bottom;if(IFrameSplitOperator.IsNumber(margin.Left))lineItem.TextMargin.Left=margin.Left;if(IFrameSplitOperator.IsNumber(margin.Right))lineItem.TextMargin.Right=margin.Right;}lineItem.Height+=lineItem.TextMargin.Top+lineItem.TextMargin.Bottom;lineItem.Width+=lineItem.TextMargin.Left+lineItem.TextMargin.Right;if(width<lineItem.Width)width=lineItem.Width;out.AryText.push(lineItem);height+=lineItem.Height;}out.Width=width;out.Height=height;return true;};this.Draw=function(
|
|
5035
|
-
|
|
5036
|
-
var bgColor=this.SetFillStyle(this.BGColor,rtBG.Left,rtBG.Top,rtBG.Left,rtBG.Bottom);this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
this.GetTooltipData=function(x,y,tooltip){if(this.LockRect==null)return false;this.Canvas.beginPath();this.Canvas.rect(this.LockRect.Left,this.LockRect.Top,this.LockRect.Width,this.LockRect.Height);if(this.Canvas.isPointInPath(x,y)){tooltip.Data={ID:this.LockID,Callback:this.Callback,IndexName:this.IndexName,IndexID:this.IndexID};tooltip.ChartPaint=this;return true;}return false;};}//买卖盘
|
|
5003
|
+
var height=0,width=0;out.AryText=[];for(var i=0;i<aryText.length;++i){var item=aryText[i];if(!item||!item.Text)continue;var textWidth=this.Canvas.measureText(item.Text).width;var lineItem={Text:item.Text,Width:textWidth,Height:lineHeight,Color:item.Color,TextMargin:{Top:0,Bottom:0,Left:0,Right:0},YOffset:0};if(IFrameSplitOperator.IsNumber(item.YOffset))lineItem.YOffset=item.YOffset;if(item.TextMargin){var margin=item.TextMargin;if(IFrameSplitOperator.IsNumber(margin.Top))lineItem.TextMargin.Top=margin.Top;if(IFrameSplitOperator.IsNumber(margin.Bottom))lineItem.TextMargin.Bottom=margin.Bottom;if(IFrameSplitOperator.IsNumber(margin.Left))lineItem.TextMargin.Left=margin.Left;if(IFrameSplitOperator.IsNumber(margin.Right))lineItem.TextMargin.Right=margin.Right;}lineItem.Height+=lineItem.TextMargin.Top+lineItem.TextMargin.Bottom;lineItem.Width+=lineItem.TextMargin.Left+lineItem.TextMargin.Right;if(width<lineItem.Width)width=lineItem.Width;out.AryText.push(lineItem);height+=lineItem.Height;}out.Width=width;out.Height=height;return true;};this.Draw=function(bDraw){this.LockRect=null;if(!bDraw)return;if(this.NotSupportMessage){this.DrawNotSupportmessage();return;}var bHScreen=this.ChartFrame.IsHScreen;var bMinute=this.IsMinuteFrame();var dataWidth=this.ChartFrame.DataWidth;var distanceWidth=this.ChartFrame.DistanceWidth;var xPointCount=this.ChartFrame.XPointCount;var border=this.ChartFrame.GetBorder();if(bHScreen){var chartright=border.BottomEx;var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;}else{var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;var chartright=border.RightEx;}var kData=this.ChartFrame.Data;var left=xOffset;if(kData&&IFrameSplitOperator.IsNonEmptyArray(kData.Data)){for(var i=kData.DataOffset,j=0;i<kData.Data.length-this.LockCount&&j<xPointCount-this.LockCount;++i,++j,xOffset+=dataWidth+distanceWidth){var kItem=kData.Data[i];if(kItem.Open==null||kItem.High==null||kItem.Low==null||kItem.Close==null)continue;if(bMinute){left=this.ChartFrame.GetXFromIndex(j);}else{left=xOffset;var right=xOffset+dataWidth;if(right>chartright)break;}}}if(bHScreen){var rtBG={Left:border.Left,Right:border.RightEx,Top:left,Bottom:border.Bottom};rtBG.Width=rtBG.Right-rtBG.Left;rtBG.Height=rtBG.Bottom-rtBG.Top;var bgColor=this.SetFillStyle(this.BGColor,rtBG.Left,rtBG.Top,rtBG.Right,rtBG.Top);this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.LockRect=rtBG;//保存上锁区域
|
|
5004
|
+
}else{var rtBG={Left:left,Right:border.RightEx,Top:border.TopTitle,Bottom:border.Bottom};rtBG.Width=rtBG.Right-rtBG.Left;rtBG.Height=rtBG.Bottom-rtBG.Top;//上下渐变
|
|
5005
|
+
var bgColor=this.SetFillStyle(this.BGColor,rtBG.Left,rtBG.Top,rtBG.Left,rtBG.Bottom);this.Canvas.fillStyle=bgColor;this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.LockRect=rtBG;//保存上锁区域
|
|
5006
|
+
}var aryText=null;if(Array.isArray(this.Title))aryText=this.Title;else aryText=[{Text:this.Title}];var outSize={};if(!this.CalculateTextSize(aryText,this.Font,outSize))return;this.Canvas.textAlign='left';this.Canvas.textBaseline='bottom';this.Canvas.font=this.Font;if(bHScreen){var top=rtBG.Top+(rtBG.Height-outSize.Width)/2;if(outSize.Width>rtBG.Height)top=rtBG.Bottom-outSize.Width;var left=rtBG.Left+(rtBG.Width-outSize.Height)/2;this.Canvas.save();this.Canvas.translate(left,top);this.Canvas.rotate(90*Math.PI/180);var yText=0,xText=0;for(var i=0;i<outSize.AryText.length;++i){var item=outSize.AryText[i];if(item.Color)this.Canvas.fillStyle=item.Color;else this.Canvas.fillStyle=this.TextColor;yText+=item.Height;this.Canvas.fillText(item.Text,xText,yText+item.YOffset);}this.Canvas.restore();}else{var left=rtBG.Left+(rtBG.Width-outSize.Width)/2;if(outSize.Width>rtBG.Width)left=rtBG.Right-outSize.Width;var top=rtBG.Top+(rtBG.Height-outSize.Height)/2;var yText=top,xText=left;for(var i=0;i<outSize.AryText.length;++i){var item=outSize.AryText[i];if(item.Color)this.Canvas.fillStyle=item.Color;else this.Canvas.fillStyle=this.TextColor;yText+=item.Height;this.Canvas.fillText(item.Text,xText,yText+item.YOffset);}}};//x,y是否在上锁区域
|
|
5007
|
+
this.GetTooltipData=function(x,y,tooltip){if(!this.LockRect)return false;if(Path2DHelper.PtInRect(x,y,this.LockRect)){tooltip.Data={ID:this.LockID,Callback:this.Callback,IndexName:this.IndexName,IndexID:this.IndexID};tooltip.ChartPaint=this;return true;}return false;};}//买卖盘
|
|
5040
5008
|
function ChartBuySell(){this.newMethod=ChartSingleText;//派生
|
|
5041
5009
|
this.newMethod();delete this.newMethod;this.ClassName="ChartBuySell";this.TextFont=g_JSChartResource.KLineTrain.Font;//"bold 14px arial"; //买卖信息字体
|
|
5042
5010
|
this.LastDataIcon=g_JSChartResource.KLineTrain.LastDataIcon;//{Color:'rgb(0,0,205)',Text:'↓'};
|
|
@@ -6090,31 +6058,31 @@ this.BorderColor=g_JSChartResource.CorssCursorBorderColor;//边框颜色
|
|
|
6090
6058
|
this.XRangeBGColor=g_JSChartResource.CorssCursorXRangeBGColor;this.LineDash=g_JSChartResource.CorssCursorLineDash.slice();//虚线
|
|
6091
6059
|
this.RightButton.BGColor=g_JSChartResource.CorssCursor.RightButton.BGColor;this.RightButton.PenColor=g_JSChartResource.CorssCursor.RightButton.PenColor;this.RightButton.Icon=CloneData(g_JSChartResource.CorssCursor.RightButton.Icon);this.RightOverlayConfig=CloneData(g_JSChartResource.CorssCursor.RightOverlayText);this.CorssPointConfig.Center=CloneData(g_JSChartResource.CorssCursor.CorssPoint.Center);this.CorssPointConfig.Border=CloneData(g_JSChartResource.CorssCursor.CorssPoint.Border);};this.GetCloseYPoint=function(index){if(!this.StringFormatX.Data)return null;var data=this.StringFormatX.Data;if(!data.Data||data.Data.length<=0)return null;var dataIndex=data.DataOffset+index;if(dataIndex>=data.Data.length)dataIndex=data.Data.length-1;if(dataIndex<0)return null;var klineData=data.Data[dataIndex];if(!klineData)return null;this.Close=klineData.Close;var yPoint=this.Frame.GetYFromData(this.Close);return yPoint;};this.GetMinuteCloseYPoint=function(index){if(this.EnableNewIndex&&this.CorssCursorIndex){if(!this.StringFormatX||!this.StringFormatX.GetMinuteCloseYPoint)return null;var closeData=this.StringFormatX.GetMinuteCloseYPoint(this.CorssCursorIndex);if(!closeData)return null;this.Close=closeData.Price;return closeData.Y;}else{if(!IFrameSplitOperator.IsNumber(index))return null;index=parseInt(index.toFixed(0));//index=parseInt(index);
|
|
6092
6060
|
if(!this.StringFormatX.Data)return null;var data=this.StringFormatX.Data;if(!data.Data||data.Data.length<=0)return null;var dataIndex=data.DataOffset+index;if(dataIndex>=data.Data.length)dataIndex=data.Data.length-1;if(dataIndex<0)return null;var close=data.Data[dataIndex];if(!IFrameSplitOperator.IsNumber(index))return null;this.Close=close;var yPoint=this.Frame.GetYFromData(this.Close);return yPoint;}};this.GetDateTimeRange=function(index,option){if(!IFrameSplitOperator.IsNumber(index))return null;index=parseInt(index);var data=this.StringFormatX.Data;if(!data.Data||data.Data.length<=0)return null;var dataIndex=data.DataOffset+index;if(dataIndex>=data.Data.length||dataIndex<0)return null;if(!this.Frame||!this.Frame.SubFrame[0]||!this.Frame.SubFrame[0].Frame)return null;var frame=this.Frame.SubFrame[0].Frame;var dataWidth=frame.DataWidth;var distanceWidth=frame.DistanceWidth;var xPointCount=frame.XPointCount;var kItem=data.Data[dataIndex];if(!kItem)return null;var date=kItem.Date*1000000;var time=parseInt(kItem.Time/100)*100;var startTime=date+time;var endTime=date+time+59;var endIndex=dataIndex;for(var i=dataIndex;i<data.Data.length;++i){var item=data.Data[i];var dateTime=item.Date*1000000+item.Time;if(dateTime>endTime)break;if(i-data.DataOffset>=xPointCount)break;endIndex=i;}var startIndex=dataIndex;for(var i=dataIndex;i>=0&&i>=data.DataOffset;--i){var item=data.Data[i];var dateTime=item.Date*1000000+item.Time;if(dateTime<startTime)break;startIndex=i;}var range={StartIndex:startIndex,EndIndex:endIndex};range.XStart=this.Frame.GetXFromIndex(startIndex-data.DataOffset);range.XEnd=this.Frame.GetXFromIndex(endIndex-data.DataOffset);range.XStart-=(distanceWidth+dataWidth)/2;range.XEnd+=(distanceWidth+dataWidth)/2;return range;};this.FixMinuteLastTimeXPoint=function(index){if(!IFrameSplitOperator.IsNumber(index))return null;index=parseInt(index);if(!this.StringFormatX.Data)return null;var data=this.StringFormatX.Data;if(!data.Data||data.Data.length<=0)return null;var dataIndex=data.DataOffset+index;if(dataIndex<data.Data.length)return null;dataIndex=data.Data.length-1;dataIndex-=data.DataOffset;var xPoint=this.Frame.GetXFromIndex(dataIndex);return{X:xPoint,Index:dataIndex};};//返回 -1=不在客户区 1=在主区域 2=左边扩展 3=右边扩展
|
|
6093
|
-
this.PtInClient=function(x,y){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){var border=this.Frame.ChartBorder.GetHScreenBorder();this.Canvas.rect(border.Left,border.TopEx,border.Right-border.Left,border.BottomEx-border.TopEx);}else{var border=this.Frame.ChartBorder.GetBorder();this.Canvas.rect(border.LeftEx,border.Top,border.RightEx-border.LeftEx,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 1;if(this.Frame.ChartBorder.LeftExtendWidth>10){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){this.Canvas.rect(border.Left,border.Top,border.Right-border.Left,border.TopEx-border.Top);}else{this.Canvas.rect(border.Left,border.Top,border.LeftEx-border.Left,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 2;}if(this.Frame.ChartBorder.RightExtendWidth>10){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){this.Canvas.rect(border.Left,border.BottomEx,border.Right-border.Left,border.Bottom-border.BottomEx);}else{this.Canvas.rect(border.RightEx,border.Top,border.Right-border.RightEx,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 3;}return-1;};this.GetFontHeight=function(font){return GetFontHeight(this.Canvas,font,"擎");};this.Draw=function(){this.Status=
|
|
6061
|
+
this.PtInClient=function(x,y){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){var border=this.Frame.ChartBorder.GetHScreenBorder();this.Canvas.rect(border.Left,border.TopEx,border.Right-border.Left,border.BottomEx-border.TopEx);}else{var border=this.Frame.ChartBorder.GetBorder();this.Canvas.rect(border.LeftEx,border.Top,border.RightEx-border.LeftEx,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 1;if(this.Frame.ChartBorder.LeftExtendWidth>10){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){this.Canvas.rect(border.Left,border.Top,border.Right-border.Left,border.TopEx-border.Top);}else{this.Canvas.rect(border.Left,border.Top,border.LeftEx-border.Left,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 2;}if(this.Frame.ChartBorder.RightExtendWidth>10){this.Canvas.beginPath();if(this.Frame.IsHScreen===true){this.Canvas.rect(border.Left,border.BottomEx,border.Right-border.Left,border.Bottom-border.BottomEx);}else{this.Canvas.rect(border.RightEx,border.Top,border.Right-border.RightEx,border.Bottom-border.Top);}if(this.Canvas.isPointInPath(x,y))return 3;}return-1;};this.GetFontHeight=function(font){return GetFontHeight(this.Canvas,font,"擎");};this.Draw=function(){this.Status=JSCHART_CORSSCURSOR_STATUS_ID.NONE_ID;this.RightButton.Rect=null;this.BottomButton.Rect=null;this.LastValue=null;if(!this.LastPoint)return;if(!this.IsShow)return;this.Close=null;var x=this.LastPoint.X;var y=this.LastPoint.Y;var clientPos=this.PtInClient(x,y);this.PointY=null;this.PointY==null;this.ClientPos=clientPos;if(clientPos<=0)return;if(this.Frame.IsHScreen===true){this.HScreenDraw();return;}var border=this.Frame.ChartBorder.GetBorder();var left=border.Left;var right=border.Right;var top=border.TopTitle;var bottom=border.Bottom;var rightWidth=this.Frame.ChartBorder.Right;var chartRight=border.ChartWidth;if(this.IsOnlyDrawKLine)//手机端 十字只能画在K线上
|
|
6094
6062
|
{x=this.Frame.GetXFromIndex(this.CursorIndex);if(this.IsShowClose){var yPoint=this.GetCloseYPoint(this.CursorIndex);if(yPoint!=null)y=yPoint;}}else if(this.IsOnlyDrawMinute){var yPoint=this.GetMinuteCloseYPoint(this.CursorIndex);if(yPoint!=null)y=yPoint;}if(this.CallAcutionXOperator){this.CallAcutionXOperator.Value=x;this.CallAcutionXOperator.Point={X:x,Y:y};this.CallAcutionXOperator.ClientPos=clientPos;if(this.CallAcutionXOperator.Operator()){x=this.CallAcutionXOperator.X;}}if(this.IsFixXLastTime){var value=this.FixMinuteLastTimeXPoint(this.CursorIndex);if(value){x=value.X;this.CursorIndex=value.Index;}}this.PointY=[[left,y],[right,y]];this.PointX=[[x,top],[x,bottom]];//十字线
|
|
6095
6063
|
if(this.IsShowCorss){var rangeBG=null;if(this.IsDrawXRangeBG){rangeBG=this.GetDateTimeRange(this.CursorIndex);}var pixel=GetDevicePixelRatio();if(this.HPenType==1||this.HPenType==0)//0=虚线 1=实线
|
|
6096
6064
|
{this.Canvas.strokeStyle=this.HPenColor;if(this.HPenType==0)this.Canvas.setLineDash(this.LineDash);//虚线
|
|
6097
6065
|
//this.Canvas.lineWidth=0.5
|
|
6098
6066
|
this.Canvas.beginPath();this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));this.Canvas.stroke();if(this.HPenType==0)this.Canvas.setLineDash([]);}this.Canvas.save();this.Canvas.strokeStyle=this.VPenColor;if(this.VPenType==0){this.Canvas.setLineDash(this.LineDash);//虚线
|
|
6099
6067
|
}else if(this.VPenType==2){var barWidth=this.Frame.SubFrame[0].Frame.DataWidth;//和K线一样宽度
|
|
6100
|
-
if(barWidth>2*pixel)this.Canvas.lineWidth=barWidth;}this.Canvas.beginPath();if(this.VLineType==1){if(rangeBG){this.Canvas.fillStyle=this.XRangeBGColor;this.Canvas.fillRect(rangeBG.XStart,border.Top,rangeBG.XEnd-rangeBG.XStart,border.Bottom-border.Top);}this.Canvas.moveTo(ToFixedPoint(x),border.Top);this.Canvas.lineTo(ToFixedPoint(x),border.Bottom);}else{if(this.Frame.SubFrame.length>0){for(var i in this.Frame.SubFrame){var frame=this.Frame.SubFrame[i].Frame;var subBorder=frame.ChartBorder.GetBorder();top=subBorder.TopTitle;bottom=subBorder.Bottom;if(rangeBG){this.Canvas.fillStyle=this.XRangeBGColor;this.Canvas.fillRect(rangeBG.XStart,top,rangeBG.XEnd-rangeBG.XStart,bottom-top);}this.Canvas.moveTo(ToFixedPoint(x),top);this.Canvas.lineTo(ToFixedPoint(x),bottom);}}else{this.Canvas.moveTo(ToFixedPoint(x),top);this.Canvas.lineTo(ToFixedPoint(x),bottom);}}this.Canvas.stroke();this.Canvas.restore();this.Canvas.save();this.DrawCorssPoint(x,y);this.Canvas.restore();}var xValue=this.Frame.GetXData(x);var yValueExtend={};var yValue=this.Frame.GetYData(y,yValueExtend);if((this.IsOnlyDrawMinute||this.IsShowClose)&&this.Close!=null)yValue=this.Close;this.LastValue={Y:{Value:yValue,Extend:yValueExtend}};//缓存十字光标对应的数值
|
|
6068
|
+
if(barWidth>2*pixel)this.Canvas.lineWidth=barWidth;}this.Canvas.beginPath();if(this.VLineType==1){if(rangeBG){this.Canvas.fillStyle=this.XRangeBGColor;this.Canvas.fillRect(rangeBG.XStart,border.Top,rangeBG.XEnd-rangeBG.XStart,border.Bottom-border.Top);}this.Canvas.moveTo(ToFixedPoint(x),border.Top);this.Canvas.lineTo(ToFixedPoint(x),border.Bottom);}else{if(this.Frame.SubFrame.length>0){for(var i in this.Frame.SubFrame){var frame=this.Frame.SubFrame[i].Frame;var subBorder=frame.ChartBorder.GetBorder();top=subBorder.TopTitle;bottom=subBorder.Bottom;if(rangeBG){this.Canvas.fillStyle=this.XRangeBGColor;this.Canvas.fillRect(rangeBG.XStart,top,rangeBG.XEnd-rangeBG.XStart,bottom-top);}this.Canvas.moveTo(ToFixedPoint(x),top);this.Canvas.lineTo(ToFixedPoint(x),bottom);}}else{this.Canvas.moveTo(ToFixedPoint(x),top);this.Canvas.lineTo(ToFixedPoint(x),bottom);}}this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LINE_ID;this.Canvas.stroke();this.Canvas.restore();this.Canvas.save();this.DrawCorssPoint(x,y);this.Canvas.restore();}var xValue=this.Frame.GetXData(x);var yValueExtend={};var yValue=this.Frame.GetYData(y,yValueExtend);if((this.IsOnlyDrawMinute||this.IsShowClose)&&this.Close!=null)yValue=this.Close;this.LastValue={Y:{Value:yValue,Extend:yValueExtend}};//缓存十字光标对应的数值
|
|
6101
6069
|
//this.StringFormatX.Value=xValue;
|
|
6102
6070
|
this.StringFormatX.Value=this.CursorIndex;this.StringFormatX.Point={X:x,Y:y};this.StringFormatX.ClientPos=clientPos;this.StringFormatY.Value=yValue;this.StringFormatY.RValue=yValueExtend.RightYValue;//右侧子坐标
|
|
6103
6071
|
this.StringFormatY.FrameID=yValueExtend.FrameID;this.StringFormatY.Point={X:x,Y:y};this.StringFormatY.ClientPos=clientPos;this.Canvas.font=this.Font;var textHeight=this.GetFontHeight();if(textHeight>this.TextHeight)this.TextHeight=textHeight;//Y轴
|
|
6104
6072
|
if((this.ShowTextMode.Left==1&&this.Frame.ChartBorder.Left>=30||this.ShowTextMode.Left==2||this.ShowTextMode.Right==1&&this.Frame.ChartBorder.Right>=30||this.ShowTextMode.Right==2)&&this.StringFormatY.Operator()){//计算右侧文本输出顶部位置
|
|
6105
6073
|
var _Temp_CalculateRightTextBGTop=function _Temp_CalculateRightTextBGTop(rtBG,complexText,defaultTextHeight){if(complexText.ShowType==1){var yValue=defaultTextHeight/2;if(IFrameSplitOperator.IsNonEmptyArray(textSize.Text)&&textSize.Text[0]){var itemSize=textSize.Text[0];if(IFrameSplitOperator.IsNumber(itemSize.Height))yValue=itemSize.Height/2;}rtBG.Top=rtBG.YCenter-yValue;rtBG.Bottom=rtBG.Top+rtBG.Height;}else{rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;}};var text=this.StringFormatY.Text;this.Canvas.font=this.Font;var textWidth=this.Canvas.measureText(text).width;//前后各空2个像素
|
|
6106
6074
|
var textSize={Width:textWidth+4,Height:this.TextHeight,Text:[]};var buttonData={Y:y,YValue:yValue,FrameID:yValueExtend.FrameID};var margin=this.LeftConfig.Margin;var textOffset=this.LeftConfig.TextOffset;var rtBG=null;if(this.Frame.ChartBorder.Left>=30&&this.ShowTextMode.Left==1)//左边
|
|
6107
|
-
{var rtBG={Right:left,Width:textWidth+margin.Left+margin.Right,YCenter:y,Height:textHeight+margin.Top+margin.Bottom};rtBG.Left=rtBG.Right-rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;if(rtBG.Left<0){rtBG.Left=0;rtBG.Right=rtBG.Left+rtBG.Width;}}else if(this.ShowTextMode.Left==2)//在框架内显示
|
|
6108
|
-
{var rtBG={Left:left,Width:textWidth+margin.Left+margin.Right,YCenter:y,Height:textHeight+margin.Top+margin.Bottom};rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;}if(rtBG){this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y);}var complexText={ShowType:0,//0=单行(默认) 1=多行
|
|
6075
|
+
{var rtBG={Right:left,Width:textWidth+margin.Left+margin.Right,YCenter:y,Height:textHeight+margin.Top+margin.Bottom};rtBG.Left=rtBG.Right-rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;if(rtBG.Left<0){rtBG.Left=0;rtBG.Right=rtBG.Left+rtBG.Width;}this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LEFT_TEXT_ID;}else if(this.ShowTextMode.Left==2)//在框架内显示
|
|
6076
|
+
{var rtBG={Left:left,Width:textWidth+margin.Left+margin.Right,YCenter:y,Height:textHeight+margin.Top+margin.Bottom};rtBG.Right=rtBG.Left+rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LEFT_INTER_TEXT_ID;}if(rtBG){this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y);}var complexText={ShowType:0,//0=单行(默认) 1=多行
|
|
6109
6077
|
Font:this.Font,Color:this.TextColor,Text:[{Text:text,Margin:this.RightConfig.Margin,TextOffset:this.RightConfig.TextOffset}]};var yTop=y-this.TextHeight/2;if(this.StringFormatY.PercentageText){if(this.TextFormat.Right==0){text=this.StringFormatY.PercentageText+'%';complexText.Text[0].Text=text;}}if(this.StringFormatY.RText){text=this.StringFormatY.RText;complexText.Text[0].Text=text;}if(this.StringFormatY.RComplexText&&IFrameSplitOperator.IsNonEmptyArray(this.StringFormatY.RComplexText.Text)){complexText=this.StringFormatY.RComplexText;if(!complexText.Font)complexText.Font=this.Font;if(!complexText.Color)complexText.Color=this.TextColor;}this.CalculateComplexTextSize(complexText,textSize);if(this.Frame.ChartBorder.Right>=30&&this.ShowTextMode.Right==1){var isOverlayIndex=false;//是否有叠加子坐标
|
|
6110
6078
|
var overlayIndexInterval=null;//子坐标间距
|
|
6111
6079
|
if(yValueExtend.FrameID>=0){var frame=this.Frame.SubFrame[yValueExtend.FrameID];isOverlayIndex=frame.OverlayIndex.length>0;overlayIndexInterval=null;if(isOverlayIndex){for(var i=0;i<=frame.OverlayIndex.length;++i){var item=frame.OverlayIndex[i];if(!item||!item.Frame)continue;if(item.Frame.IsShow===false)continue;if(!item.Frame.GetXHorizontal)continue;var overlayLeft=item.Frame.GetXHorizontal();overlayIndexInterval=overlayLeft-right;break;}}}//叠加坐标
|
|
6112
6080
|
if(isOverlayIndex&&textSize.Width>overlayIndexInterval&&overlayIndexInterval>0)//大于子坐标宽度
|
|
6113
|
-
{var rtBG={Right:right+overlayIndexInterval,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Left=rtBG.Right-rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);if(rtBG.Right>chartRight){rtBG.Right=chartRight;rtBG.Left=rtBG.Right-rtBG.Width;}var drawRight=right+overlayIndexInterval;if(drawRight>chartRight)drawRight=chartRight;this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);}else{var rtBG={Left:right+1,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Right=rtBG.Left+rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);if(rtBG.Right>chartRight){rtBG.Right=chartRight;rtBG.Left=rtBG.Right-rtBG.Width;}this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);}}else if(this.ShowTextMode.Right==2)//框架内侧显示
|
|
6114
|
-
{var rtBG={Right:right,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Left=rtBG.Right-rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);this.Canvas.fillStyle=this.TextBGColor;this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);}}//X轴 Bottom==8 自定义
|
|
6081
|
+
{var rtBG={Right:right+overlayIndexInterval,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Left=rtBG.Right-rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);if(rtBG.Right>chartRight){rtBG.Right=chartRight;rtBG.Left=rtBG.Right-rtBG.Width;}var drawRight=right+overlayIndexInterval;if(drawRight>chartRight)drawRight=chartRight;this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);}else{var rtBG={Left:right+1,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Right=rtBG.Left+rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);if(rtBG.Right>chartRight){rtBG.Right=chartRight;rtBG.Left=rtBG.Right-rtBG.Width;}this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.RIGHT_TEXT_ID;}}else if(this.ShowTextMode.Right==2)//框架内侧显示
|
|
6082
|
+
{var rtBG={Right:right,Width:textSize.Width,YCenter:y,Height:textSize.Height};rtBG.Left=rtBG.Right-rtBG.Width;_Temp_CalculateRightTextBGTop(rtBG,complexText,this.TextHeight);this.Canvas.fillStyle=this.TextBGColor;this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.DrawComplexRightText(rtBG,complexText,textSize);if(this.RightButton.Enable)this.DrawRightButtonV2(rtBG,complexText,textSize,buttonData);this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.RIGHT_INTER_TEXT_ID;}}//X轴 Bottom==8 自定义
|
|
6115
6083
|
if((this.ShowTextMode.Bottom==1||this.ShowTextMode.Bottom==2||this.ShowTextMode.Bottom==8)&&this.StringFormatX.Operator()){var text=this.StringFormatX.Text;this.Canvas.font=this.Font;this.Canvas.fillStyle=this.TextBGColor;var textWidth=this.Canvas.measureText(text).width;//前后各空2个像素
|
|
6116
6084
|
var margin=this.BottomConfig.Margin;var textOffset=this.BottomConfig.TextOffset;var textAlign=this.BottomConfig.Align;var rtBG={Top:bottom,Height:margin.Top+margin.Bottom+textHeight,XCenter:x,Width:textWidth+margin.Left+margin.Right};rtBG.Bottom=rtBG.Top+rtBG.Height;if(textAlign==1)rtBG.Left=rtBG.XCenter-rtBG.Width/2;else rtBG.Left=rtBG.XCenter;rtBG.Right=rtBG.Left+rtBG.Width;if(rtBG.Left<=0){rtBG.Left=0;rtBG.Right=rtBG.Left+rtBG.Width;}else if(rtBG.Right>=right){rtBG.Right=right;rtBG.Left=rtBG.Right-rtBG.Width;}var bShowText=true;if(this.ShowTextMode.Bottom==2){rtBG.Bottom=bottom;rtBG.Top=rtBG.Bottom-rtBG.Height;}else if(this.ShowTextMode.Bottom==8){var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CUSTOM_CORSSCURSOR_POSITION);if(event&&event.Callback){var sendData={RectText:rtBG,IsShowText:bShowText,X:x,Y:y};event.Callback(event,sendData,this);bShowText=sendData.IsShowText;}}//JSConsole.Chart.Log('[ChartCorssCursor::Draw] ',yCenter);
|
|
6117
|
-
if(bShowText){this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y,textWidth);var buttonData={X:x,Y:y,XValue:xValue,FrameID:yValueExtend.FrameID};if(this.StringFormatX.KItem)buttonData.KItem=this.StringFormatX.KItem;this.BottomButton.Rect=rtBG;this.BottomButton.Data=buttonData;}}//子坐标Y轴
|
|
6085
|
+
if(bShowText){this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y,textWidth);var buttonData={X:x,Y:y,XValue:xValue,FrameID:yValueExtend.FrameID};if(this.StringFormatX.KItem)buttonData.KItem=this.StringFormatX.KItem;this.BottomButton.Rect=rtBG;this.BottomButton.Data=buttonData;this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.BOTTOM_TEXT_ID;}}//子坐标Y轴
|
|
6118
6086
|
if(yValueExtend.FrameID>=0){var frame=this.Frame.SubFrame[yValueExtend.FrameID];var overlayLeft=right;this.Canvas.font=this.Font;for(var i=0;i<frame.OverlayIndex.length;++i){var item=frame.OverlayIndex[i];if(item.Frame.IsShow===false)continue;if(!item.Frame.GetXHorizontal)continue;overlayLeft=item.Frame.GetXHorizontal();//if (overlayLeft+30>chartRight) break;
|
|
6119
6087
|
var yValue=item.Frame.GetYData(y);var text=IFrameSplitOperator.FormatValueString(yValue,2);var textWidth=this.Canvas.measureText(text).width;//前后各空2个像素
|
|
6120
6088
|
var margin=this.RightOverlayConfig.Margin;var textOffset=this.RightOverlayConfig.TextOffset;var rtBG={Left:overlayLeft+1,Width:textWidth+margin.Left+margin.Right,YCenter:y,Height:textHeight+margin.Top+margin.Bottom};rtBG.Right=rtBG.Left-rtBG.Width;rtBG.Top=rtBG.YCenter-rtBG.Height/2;rtBG.Bottom=rtBG.Top+rtBG.Height;this.DrawTextBGRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);/*
|
|
@@ -6124,7 +6092,7 @@ var margin=this.RightOverlayConfig.Margin;var textOffset=this.RightOverlayConfig
|
|
|
6124
6092
|
var textWidth=this.Canvas.measureText(text).width+4; //前后各空2个像素
|
|
6125
6093
|
if (textWidth<frame.Interval) break;
|
|
6126
6094
|
}
|
|
6127
|
-
*/this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y);}}
|
|
6095
|
+
*/this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,rtBG.Left+textOffset.X,rtBG.Bottom+textOffset.Y);}}};this.DrawComplexRightText=function(rtBG,complexText,size){this.Canvas.textAlign="left";this.Canvas.textBaseline="bottom";var showType=0;if(complexText.ShowType==1)showType=complexText.ShowType;if(showType==1)//多行
|
|
6128
6096
|
{var xLeft=rtBG.Left;var yTop=rtBG.Top;//顶
|
|
6129
6097
|
for(var i=0;i<complexText.Text.length;++i){var item=complexText.Text[i];var itemSize=size.Text[i];if(item.Font)this.Canvas.font=item.Font;else this.Canvas.font=complexText.Font;if(item.Color)this.Canvas.fillStyle=item.Color;else this.Canvas.fillStyle=complexText.Color;var y=yTop+itemSize.Height;var x=xLeft;if(item.TextOffset){var textOffset=item.TextOffset;if(IFrameSplitOperator.IsNumber(textOffset.X))x+=textOffset.X;if(IFrameSplitOperator.IsNumber(textOffset.Y))y+=textOffset.Y;}this.Canvas.fillText(item.Text,x,y,itemSize.Width);yTop+=itemSize.Height;}}else//水平 单行
|
|
6130
6098
|
{var xText=rtBG.Left;var yBottom=rtBG.Bottom;for(var i=0;i<complexText.Text.length;++i){var item=complexText.Text[i];var itemSize=size.Text[i];if(item.Font)this.Canvas.font=item.Font;else this.Canvas.font=complexText.Font;if(item.Color)this.Canvas.fillStyle=item.Color;else this.Canvas.fillStyle=complexText.Color;var x=xText;var y=yBottom;if(item.TextOffset){var textOffset=item.TextOffset;if(IFrameSplitOperator.IsNumber(textOffset.X))x+=textOffset.X;if(IFrameSplitOperator.IsNumber(textOffset.Y))y+=textOffset.Y;}this.Canvas.fillText(item.Text,x,y,itemSize.Width);xText+=itemSize.Width;}}};this.CalculateComplexTextSize=function(complexText,size){if(!complexText||!IFrameSplitOperator.IsNonEmptyArray(complexText.Text))return;var showType=0;if(complexText.ShowType==1)showType=complexText.ShowType;if(showType==1)//多行
|
|
@@ -6138,28 +6106,28 @@ textWidth+=itemWidth;if(textHeight<itemHeight)textHeight=itemHeight;}size.Width=
|
|
|
6138
6106
|
this.Canvas.strokeStyle=this.RightButton.PenColor;var x=rtButtom.Left+spaceWidth;var y=rtButtom.Top+spaceWidth;this.Canvas.save();this.Canvas.linewidth=1*pixelRatio;this.Canvas.beginPath();this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(yCenter));this.Canvas.lineTo(ToFixedPoint(x+rtButton.Width-spaceWidth*2),ToFixedPoint(yCenter));this.Canvas.moveTo(ToFixedPoint(xCenter),ToFixedPoint(y));this.Canvas.lineTo(ToFixedPoint(xCenter),ToFixedPoint(y+rtButton.Height-spaceWidth*2));this.Canvas.stroke();this.Canvas.restore();}};this.DrawRightButton=function(drawTop,drawRight,drawWidth,drawHeight,data){this.Canvas.fillStyle=this.RightButton.BGColor;var rtButton={Left:drawRight-drawWidth,Top:drawTop,Width:drawWidth,Height:drawHeight};rtButton.Right=rtButton.Left+rtButton.Width;rtButton.Bottom=rtButton.Top+rtButton.Height;this.RightButton.Rect=rtButton;this.RightButton.Data=data;this.Canvas.fillRect(ToFixedPoint(rtButton.Left+1),ToFixedPoint(rtButton.Top),ToFixedRect(rtButton.Width),ToFixedRect(rtButton.Height));var pixelRatio=GetDevicePixelRatio();var spaceWidth=3;var yCenter=rtButton.Top+spaceWidth+(rtButton.Height-spaceWidth*2)/2;var xCenter=rtButton.Left+spaceWidth+(rtButton.Width-spaceWidth*2)/2;if(this.RightButton.Icon){var icon=this.RightButton.Icon;this.Canvas.font=icon.Size*pixelRatio+'px '+icon.Family;this.Canvas.textAlign="center";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=icon.Color;this.Canvas.fillText('\uE6A3',xCenter,yCenter);}else{//画加号
|
|
6139
6107
|
this.Canvas.strokeStyle=this.RightButton.PenColor;var x=rtButtom.Left+spaceWidth;var y=rtButtom.Top+spaceWidth;this.Canvas.save();this.Canvas.linewidth=1*pixelRatio;this.Canvas.beginPath();this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(yCenter));this.Canvas.lineTo(ToFixedPoint(x+rtButton.Width-spaceWidth*2),ToFixedPoint(yCenter));this.Canvas.moveTo(ToFixedPoint(xCenter),ToFixedPoint(y));this.Canvas.lineTo(ToFixedPoint(xCenter),ToFixedPoint(y+rtButton.Height-spaceWidth*2));this.Canvas.stroke();this.Canvas.restore();}};this.PtInButton=function(x,y){var item=this.PtInRightButton(x,y);if(item)return item;item=this.PtInButtomButton(x,y);if(item)return item;return null;};this.PtInRightButton=function(x,y){if(!this.RightButton.Enable)return null;if(!this.RightButton.Rect)return null;var rect=this.RightButton.Rect;if(x>=rect.Left&&x<=rect.Right&&y>=rect.Top&&y<=rect.Bottom){return{Data:this.RightButton.Data,Rect:rect,Type:1};//Type:1=右侧 2=底部
|
|
6140
6108
|
}return null;};this.PtInButtomButton=function(x,y){if(!this.BottomButton.Enable)return null;if(!this.BottomButton.Rect)return null;var rect=this.BottomButton.Rect;if(x>=rect.Left&&x<=rect.Right&&y>=rect.Top&&y<=rect.Bottom){return{Data:this.BottomButton.Data,Rect:rect,Type:2};//Type:1=右侧 2=底部
|
|
6141
|
-
}return null;};this.DrawTextBGRect=function(x,y,height,width){this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(ToFixedPoint(x),ToFixedPoint(y),ToFixedRect(height),ToFixedRect(width));if(this.BorderColor){this.Canvas.strokeStyle=this.BorderColor;this.Canvas.strokeRect(ToFixedPoint(x),ToFixedPoint(y),ToFixedRect(height),ToFixedRect(width));}};this.HScreenDraw=function(){var x=this.LastPoint.X;var y=this.LastPoint.Y;if(this.IsOnlyDrawKLine)//手机端 十字只能画在K线上
|
|
6109
|
+
}return null;};this.DrawTextBGRect=function(x,y,height,width){this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(ToFixedPoint(x),ToFixedPoint(y),ToFixedRect(height),ToFixedRect(width));if(this.BorderColor){this.Canvas.strokeStyle=this.BorderColor;this.Canvas.strokeRect(ToFixedPoint(x),ToFixedPoint(y),ToFixedRect(height),ToFixedRect(width));}};this.HScreenDraw=function(){this.Status=JSCHART_CORSSCURSOR_STATUS_ID.NONE_ID;var x=this.LastPoint.X;var y=this.LastPoint.Y;if(this.IsOnlyDrawKLine)//手机端 十字只能画在K线上
|
|
6142
6110
|
{y=this.Frame.GetXFromIndex(this.CursorIndex);if(this.IsShowClose){var yPoint=this.GetCloseYPoint(this.CursorIndex);if(yPoint!=null)x=yPoint;}}else if(this.IsOnlyDrawMinute){var yPoint=this.GetMinuteCloseYPoint(this.CursorIndex);if(yPoint!=null)x=yPoint;}var border=this.Frame.ChartBorder.GetHScreenBorder();var left=border.Left;var right=border.Right;var top=border.Top;var bottom=border.Bottom;var bottomWidth=this.Frame.ChartBorder.Bottom;if(this.CallAcutionXOperator){this.CallAcutionXOperator.Value=y;this.CallAcutionXOperator.Point={X:x,Y:y};this.CallAcutionXOperator.ClientPos=this.ClientPos;if(this.CallAcutionXOperator.Operator()){y=this.CallAcutionXOperator.X;}}this.PointY=[[left,y],[right,y]];this.PointX=[[x,top],[x,bottom]];//十字线
|
|
6143
6111
|
if(this.IsShowCorss){var pixel=GetDevicePixelRatio();this.Canvas.save();this.Canvas.strokeStyle=this.HPenColor;if(this.HPenType==0)this.Canvas.setLineDash(this.LineDash);//虚线
|
|
6144
6112
|
//画竖线
|
|
6145
6113
|
this.Canvas.beginPath();this.Canvas.moveTo(ToFixedPoint(x),top);this.Canvas.lineTo(ToFixedPoint(x),bottom);this.Canvas.stroke();this.Canvas.restore();//画横线
|
|
6146
6114
|
this.Canvas.save();this.Canvas.strokeStyle=this.VPenColor;if(this.VPenType==0){this.Canvas.setLineDash(this.LineDash);//虚线
|
|
6147
6115
|
}else if(this.VPenType==2){var barWidth=this.Frame.SubFrame[0].Frame.DataWidth;//和K线一样宽度
|
|
6148
|
-
if(barWidth>2*pixel)this.Canvas.lineWidth=barWidth;}this.Canvas.beginPath();if(this.VLineType==1){this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}else{if(this.Frame.SubFrame.length>0){for(var i in this.Frame.SubFrame){var frame=this.Frame.SubFrame[i].Frame;var subBorder=frame.ChartBorder.GetHScreenBorder();this.Canvas.moveTo(subBorder.Left,ToFixedPoint(y));this.Canvas.lineTo(subBorder.RightEx,ToFixedPoint(y));}}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}}this.Canvas.stroke();this.Canvas.restore();this.Canvas.save();this.DrawCorssPoint(x,y);this.Canvas.restore();}var xValue=this.Frame.GetXData(y);var yValueExtend={};var yValue=this.Frame.GetYData(x,yValueExtend);this.StringFormatX.Value=xValue;this.StringFormatX.Point={X:x,Y:y};this.StringFormatX.ClientPos=this.ClientPos;this.StringFormatY.Value=yValue;this.StringFormatY.FrameID=yValueExtend.FrameID;this.StringFormatY.RValue=yValueExtend.RightYValue;//右侧子坐标
|
|
6116
|
+
if(barWidth>2*pixel)this.Canvas.lineWidth=barWidth;}this.Canvas.beginPath();if(this.VLineType==1){this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}else{if(this.Frame.SubFrame.length>0){for(var i in this.Frame.SubFrame){var frame=this.Frame.SubFrame[i].Frame;var subBorder=frame.ChartBorder.GetHScreenBorder();this.Canvas.moveTo(subBorder.Left,ToFixedPoint(y));this.Canvas.lineTo(subBorder.RightEx,ToFixedPoint(y));}}else{this.Canvas.moveTo(left,ToFixedPoint(y));this.Canvas.lineTo(right,ToFixedPoint(y));}}this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LINE_ID;this.Canvas.stroke();this.Canvas.restore();this.Canvas.save();this.DrawCorssPoint(x,y);this.Canvas.restore();}var xValue=this.Frame.GetXData(y);var yValueExtend={};var yValue=this.Frame.GetYData(x,yValueExtend);this.StringFormatX.Value=xValue;this.StringFormatX.Point={X:x,Y:y};this.StringFormatX.ClientPos=this.ClientPos;this.StringFormatY.Value=yValue;this.StringFormatY.FrameID=yValueExtend.FrameID;this.StringFormatY.RValue=yValueExtend.RightYValue;//右侧子坐标
|
|
6149
6117
|
this.StringFormatY.Point={X:x,Y:y};this.StringFormatY.ClientPos=this.ClientPos;this.Canvas.font=this.Font;var textHeight=this.GetFontHeight();if(textHeight>this.TextHeight)this.TextHeight=textHeight;if((this.ShowTextMode.Left==1&&this.Frame.ChartBorder.Top>=30||this.ShowTextMode.Left==2||this.ShowTextMode.Right==1&&this.Frame.ChartBorder.Bottom>=30||this.ShowTextMode.Right==2)&&this.StringFormatY.Operator()){var text=this.StringFormatY.Text;this.Canvas.font=this.Font;var textWidth=this.Canvas.measureText(text).width+4;//前后各空2个像素
|
|
6150
6118
|
if(this.Frame.ChartBorder.Top>=30&&this.ShowTextMode.Left==1){var xText=x;var yText=top;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6151
|
-
this.Canvas.fillStyle=this.TextBGColor;if(top>=textWidth){this.Canvas.fillRect(0,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,-2,0,textWidth);}else{this.Canvas.fillRect(textWidth-top,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,textWidth-top-2,0,textWidth);}this.Canvas.restore();}else if(this.ShowTextMode.Left==2){var xText=x;var yText=top;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6152
|
-
this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(0,-(this.TextHeight/2),textWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,2,0,textWidth);this.Canvas.restore();}if(this.StringFormatY.RText){text=this.StringFormatY.RText;var textWidth=this.Canvas.measureText(text).width+4;//前后各空2个像素
|
|
6119
|
+
this.Canvas.fillStyle=this.TextBGColor;if(top>=textWidth){this.Canvas.fillRect(0,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,-2,0,textWidth);}else{this.Canvas.fillRect(textWidth-top,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,textWidth-top-2,0,textWidth);}this.Canvas.restore();this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LEFT_TEXT_ID;}else if(this.ShowTextMode.Left==2){var xText=x;var yText=top;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6120
|
+
this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(0,-(this.TextHeight/2),textWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,2,0,textWidth);this.Canvas.restore();this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.LEFT_INTER_TEXT_ID;}if(this.StringFormatY.RText){text=this.StringFormatY.RText;var textWidth=this.Canvas.measureText(text).width+4;//前后各空2个像素
|
|
6153
6121
|
}if(this.Frame.ChartBorder.Bottom>=30&&this.ShowTextMode.Right==1){var xText=x;var yText=bottom;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6154
6122
|
this.Canvas.fillStyle=this.TextBGColor;if(bottomWidth>textWidth){this.Canvas.fillRect(0,-(this.TextHeight/2),textWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,2,0,textWidth);}else{this.Canvas.fillRect(bottomWidth-textWidth,-(this.TextHeight/2),textWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,bottomWidth-textWidth+2,0,textWidth);}if(this.StringFormatY.RExtendText&&this.StringFormatY.RExtendText.length>0){var yOffset=0;for(var i in this.StringFormatY.RExtendText){var item=this.StringFormatY.RExtendText[i];var rText='--.--';if(item.YText)rText=item.YText;else if(IFrameSplitOperator.IsNumber(item.Y))rText=item.Y.toFixed(0);var rTextWidth=this.Canvas.measureText(rText).width+4;//前后各空2个像素
|
|
6155
|
-
this.Canvas.fillStyle=item.TextBGColor;if(bottomWidth>rTextWidth){this.Canvas.fillRect(0,yOffset+this.TextHeight/2,rTextWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(rText,2,yOffset+this.TextHeight,rTextWidth);}else{var rTextLeft=bottomWidth-rTextWidth;this.Canvas.fillRect(rTextLeft,yOffset+this.TextHeight/2,rTextWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(rText,rTextLeft+2,yOffset+this.TextHeight,rTextWidth);}yOffset+=this.TextHeight;}}this.Canvas.restore();}else if(this.ShowTextMode.Right==2){var xText=x;var yText=bottom;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6156
|
-
this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(0,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,-2,0,textWidth);this.Canvas.restore();}}//X轴 Bottom=8 自定义X轴文字位置
|
|
6123
|
+
this.Canvas.fillStyle=item.TextBGColor;if(bottomWidth>rTextWidth){this.Canvas.fillRect(0,yOffset+this.TextHeight/2,rTextWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(rText,2,yOffset+this.TextHeight,rTextWidth);}else{var rTextLeft=bottomWidth-rTextWidth;this.Canvas.fillRect(rTextLeft,yOffset+this.TextHeight/2,rTextWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=item.TextColor;this.Canvas.fillText(rText,rTextLeft+2,yOffset+this.TextHeight,rTextWidth);}yOffset+=this.TextHeight;}}this.Canvas.restore();this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.RIGHT_TEXT_ID;}else if(this.ShowTextMode.Right==2){var xText=x;var yText=bottom;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6124
|
+
this.Canvas.fillStyle=this.TextBGColor;this.Canvas.fillRect(0,-(this.TextHeight/2),-textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,-2,0,textWidth);this.Canvas.restore();this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.RIGHT_INTER_TEXT_ID;}}//X轴 Bottom=8 自定义X轴文字位置
|
|
6157
6125
|
if((this.ShowTextMode.Bottom===1||this.ShowTextMode.Bottom==8)&&this.StringFormatX.Operator()){var text=this.StringFormatX.Text;this.Canvas.font=this.Font;this.Canvas.fillStyle=this.TextBGColor;var textWidth=this.Canvas.measureText(text).width+4;//前后各空2个像素
|
|
6158
6126
|
var xText=left;var bShowText=true;if(this.ShowTextMode.Bottom==8){var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CUSTOM_CORSSCURSOR_POSITION);if(event&&event.Callback){var sendData={XText:xText,Height:this.TextHeight,IsShowText:bShowText};event.Callback(event,sendData,this);xText=sendData.XText;bShowText=sendData.IsShowText;}}if(bShowText){if(y-textWidth/2<3)//左边位置不够了, 顶着左边画
|
|
6159
6127
|
{var yText=y;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6160
6128
|
this.Canvas.fillRect(0,0,textWidth,this.TextHeight);this.Canvas.textAlign="left";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,2,this.TextHeight/2,textWidth);this.Canvas.restore();}else if(y+textWidth/2>=bottom){var yText=y;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6161
6129
|
this.Canvas.fillRect(-textWidth,0,textWidth,this.TextHeight);this.Canvas.textAlign="right";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,-2,this.TextHeight/2,textWidth);this.Canvas.restore();}else{var yText=y;this.Canvas.save();this.Canvas.translate(xText,yText);this.Canvas.rotate(90*Math.PI/180);//数据和框子旋转180度
|
|
6162
|
-
this.Canvas.fillRect(-textWidth/2,0,textWidth,this.TextHeight);this.Canvas.textAlign="center";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,0,this.TextHeight/2,textWidth);this.Canvas.restore();}
|
|
6130
|
+
this.Canvas.fillRect(-textWidth/2,0,textWidth,this.TextHeight);this.Canvas.textAlign="center";this.Canvas.textBaseline="middle";this.Canvas.fillStyle=this.TextColor;this.Canvas.fillText(text,0,this.TextHeight/2,textWidth);this.Canvas.restore();}this.Status|=JSCHART_CORSSCURSOR_STATUS_ID.BOTTOM_TEXT_ID;}}};//data={ e:e, PreventDefault:false, KeyID, Draw:是否需要重绘 }
|
|
6163
6131
|
this.OnKeyDown=function(data){if(!this.EnableKeyboard)return;var keyID=data.KeyID;if(keyID==27)//ESC 隐藏十字线
|
|
6164
6132
|
{if(!this.IsShowCorss)return;this.IsShowCorss=false;data.Draw=true;if(this.OnChangeStatusCallback)this.OnChangeStatusCallback({Type:1,IsShowCorss:this.IsShowCorss},this);}else if(keyID==37||keyID==39)//left, right 显示十字线
|
|
6165
6133
|
{if(this.IsShowCorss)return;this.IsShowCorss=true;data.Draw=true;if(this.OnChangeStatusCallback)this.OnChangeStatusCallback({Type:1,IsShowCorss:this.IsShowCorss},this);}};this.OnDBClick=function(data){if(!this.EnableDBClick)return;if(!IFrameSplitOperator.IsNonEmptyArray(this.Frame.SubFrame))return;//在主图框架内
|
|
@@ -8517,7 +8485,7 @@ chart=new FrameSplitPaint();chart.Canvas=this.Canvas;chart.ChartBorder=this.Fram
|
|
|
8517
8485
|
if(this.ClickModel.IsShowCorssCursor==true&&this.TouchDrawCount>0)bShowCorssCursor=true;if(bShowCorssCursor){this.DelayAutoCloseCorssCursor();//自动延迟关闭十字光标
|
|
8518
8486
|
return;}this.ClickModel.IsShowCorssCursor=false;this.DrawDynamicInfo();return;}if(this.CorssCursorTouchEnd===true)//手势离开十字光标消失
|
|
8519
8487
|
{if(this.TouchDrawCount>0)this.DrawDynamicInfo();return;}for(var i=0;i<this.ExtendChartPaint.length;++i){var item=this.ExtendChartPaint[i];if(item.ClassName==='KLineTooltipPaint'){this.DrawDynamicInfo();}}};//锁|解锁指标 { Index:指标名字,IsLocked:是否要锁上,Callback:回调 }
|
|
8520
|
-
this.LockIndex=function(lockData){if(!lockData)return;if(!lockData.IndexName)return;for(var _i12 in this.WindowIndex){var _item4=this.WindowIndex[_i12];if(!_item4)conintue;if(_item4.Name==lockData.IndexName){_item4.SetLock(lockData);this.Update();break;}}};this.TryClickLock=function(x,y){for(var i=0;i<this.Frame.SubFrame.length;++i){var item=this.Frame.SubFrame[i];if(!item.Frame.IsLocked)continue;if(!item.Frame.LockPaint)continue;var tooltip=new TooltipData();if(!item.Frame.LockPaint.GetTooltipData(x,y,tooltip))continue;tooltip.HQChart=this;if(tooltip.Data.Callback)tooltip.Data.Callback(tooltip);return true;}return false;};this.TryClickIndexTitle=function(x,y){for(var i in this.TitlePaint){var item=this.TitlePaint[i];if(!item.IsClickTitle)continue;if(!item.IsClickTitle(x,y))continue;var data={Point:{X:x,Y:y},Title:item.Title,FrameID:item.Frame.Identify};JSConsole.Chart.Log('[KLineChartContainer::TryClickIndexTitle] click title ',data);var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CLICK_INDEXTITLE);if(event&&event.Callback)event.Callback(event,data,this);return true;}return false;};this.SetSizeChange=function(bChanged){this.Frame.SetSizeChage(bChanged);for(var i in this.ExtendChartPaint){var item=this.ExtendChartPaint[i];item.SizeChange=bChanged;}};this.SetSizeChage=this.SetSizeChange;//单词拼错了, 还没替换完
|
|
8488
|
+
this.LockIndex=function(lockData){if(!lockData)return;if(!lockData.IndexName)return;for(var _i12 in this.WindowIndex){var _item4=this.WindowIndex[_i12];if(!_item4)conintue;if(_item4.Name==lockData.IndexName){_item4.SetLock(lockData);this.Update();break;}}};this.TryClickLock=function(x,y){for(var i=0;i<this.Frame.SubFrame.length;++i){var item=this.Frame.SubFrame[i];if(!item.Frame.IsLocked)continue;if(!item.Frame.LockPaint)continue;var tooltip=new TooltipData();if(!item.Frame.LockPaint.GetTooltipData(x,y,tooltip))continue;tooltip.HQChart=this;var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CLICK_INDEX_LOCK);if(event&&event.Callback){var sendData={FrameID:item.Frame.Identify,Data:tooltip};event.Callback(event,sendData,this);}if(tooltip.Data.Callback)tooltip.Data.Callback(tooltip);return true;}return false;};this.TryClickIndexTitle=function(x,y){for(var i in this.TitlePaint){var item=this.TitlePaint[i];if(!item.IsClickTitle)continue;if(!item.IsClickTitle(x,y))continue;var data={Point:{X:x,Y:y},Title:item.Title,FrameID:item.Frame.Identify};JSConsole.Chart.Log('[KLineChartContainer::TryClickIndexTitle] click title ',data);var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CLICK_INDEXTITLE);if(event&&event.Callback)event.Callback(event,data,this);return true;}return false;};this.SetSizeChange=function(bChanged){this.Frame.SetSizeChage(bChanged);for(var i in this.ExtendChartPaint){var item=this.ExtendChartPaint[i];item.SizeChange=bChanged;}};this.SetSizeChage=this.SetSizeChange;//单词拼错了, 还没替换完
|
|
8521
8489
|
this.Update=function(option)//option: { UpdateCursorIndexType:更新十字光标方式 }
|
|
8522
8490
|
{if(!this.SourceData)return;if(this.BeforeBindMainData)this.BeforeBindMainData('Update');var bindData=new ChartData();bindData.Data=this.SourceData.Data;bindData.Period=this.Period;bindData.Right=this.Right;bindData.DataType=this.SourceData.DataType;bindData.Symbol=this.Symbol;if(bindData.Right>0&&ChartData.IsDayPeriod(bindData.Period,true))//复权(日线数据复权)
|
|
8523
8491
|
{var rightData=bindData.GetRightData(bindData.Right,{AlgorithmType:this.RightFormula});bindData.Data=rightData;}else if(bindData.Right>0&&ChartData.IsMinutePeriod(bindData.Period,true)&&this.RightFormula>=1)//复权(分钟数据复权, 复权因子模式)
|
|
@@ -15506,7 +15474,7 @@ hisData.Symbol=message.symbol;}var stockObj={HQDataType:HQ_DATA_TYPE.KLINE_ID,St
|
|
|
15506
15474
|
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);};}/********************************************************************************
|
|
15507
15475
|
* 版本信息输出
|
|
15508
15476
|
*
|
|
15509
|
-
*/var HQCHART_VERSION="1.1.
|
|
15477
|
+
*/var HQCHART_VERSION="1.1.15103";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();//把给外界调用的方法暴露出来
|
|
15510
15478
|
exports.default=(_jsChartInit$jsChartS={jsChartInit:JSChart.Init,jsChartStyle:JSChart.SetStyle,// IsIndexSymbol:IsIndexSymbol,
|
|
15511
15479
|
// BaseIndex:BaseIndex,
|
|
15512
15480
|
// ChartLine:ChartLine,
|
|
@@ -15533,5 +15501,6 @@ GetDevicePixelRatio:GetDevicePixelRatio},(0,_defineProperty3.default)(_jsChartIn
|
|
|
15533
15501
|
HQMinuteTimeStringFormat:HQMinuteTimeStringFormat,//分时图X轴 十字光标输出格式化
|
|
15534
15502
|
HQDateStringFormat:HQDateStringFormat,//K线图X轴 十字光标输出格式化
|
|
15535
15503
|
HQPriceStringFormat:HQPriceStringFormat//分时图,K线图Y轴 十字光标输出格式化
|
|
15536
|
-
}),(0,_defineProperty3.default)(_jsChartInit$jsChartS,'JS_ID',{JSCHART_EVENT_ID:JSCHART_EVENT_ID,JSCHART_OPERATOR_ID:JSCHART_OPERATOR_ID,JSCHART_DRAG_ID:JSCHART_DRAG_ID,JSCHART_BUTTON_ID:JSCHART_BUTTON_ID,JSCHART_DATA_FIELD_ID:JSCHART_DATA_FIELD_ID,JSCHART_WORKER_MESSAGE_ID:JSCHART_WORKER_MESSAGE_ID,JSCHART_MENU_ID:JSCHART_MENU_ID,JSCHART_TRADE_STATUS_ID:JSCHART_TRADE_STATUS_ID
|
|
15504
|
+
}),(0,_defineProperty3.default)(_jsChartInit$jsChartS,'JS_ID',{JSCHART_EVENT_ID:JSCHART_EVENT_ID,JSCHART_OPERATOR_ID:JSCHART_OPERATOR_ID,JSCHART_DRAG_ID:JSCHART_DRAG_ID,JSCHART_BUTTON_ID:JSCHART_BUTTON_ID,JSCHART_DATA_FIELD_ID:JSCHART_DATA_FIELD_ID,JSCHART_WORKER_MESSAGE_ID:JSCHART_WORKER_MESSAGE_ID,JSCHART_MENU_ID:JSCHART_MENU_ID,JSCHART_TRADE_STATUS_ID:JSCHART_TRADE_STATUS_ID,//交易状态
|
|
15505
|
+
JSCHART_CORSSCURSOR_STATUS_ID:JSCHART_CORSSCURSOR_STATUS_ID//十字光标状态
|
|
15537
15506
|
}),(0,_defineProperty3.default)(_jsChartInit$jsChartS,'HQChartScriptWorker',HQChartScriptWorker),(0,_defineProperty3.default)(_jsChartInit$jsChartS,'JSPopMenu',JSPopMenu),(0,_defineProperty3.default)(_jsChartInit$jsChartS,'JSDialogDrawTool',JSDialogDrawTool),_jsChartInit$jsChartS);
|