From fac720e373924215155f0e138c02df73b2f87441 Mon Sep 17 00:00:00 2001 From: jones2000 Date: Fri, 10 Jun 2022 15:56:55 +0800 Subject: [PATCH] ver 11135 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 11134 增加支持钉钉小程序 11133 小程序指标计算引擎网络请求使用统一函数 11132 小程序网络通讯封装 11130 分时图标题栏显示最有一条数据,新增加格式 11126 成交量分布图-可视范围 增加指标标题数据显示 --- README.md | 3 + umychart_uniapp_h5/umychart.uniapp.h5.js | 111 ++++++++++++++++- vuehqchart/src/jscommon/umychart.js | 111 ++++++++++++++++- .../umychart.vue.build/umychart.vue.export.js | 1 + .../src/jscommon/umychart.vue/umychart.vue.js | 112 +++++++++++++++++- webhqchart.demo/jscommon/umychart.js | 111 ++++++++++++++++- webhqchart/umychart.js | 111 ++++++++++++++++- wechathqchart/umychart.complier.wechat.js | 37 +++--- wechathqchart/umychart.element.wechart.js | 37 ++++++ wechathqchart/umychart.network.wechart.js | 62 ++++++++++ .../umychart.uniapp.canvas.helper.js | 7 +- wechathqchart/umychart.wechat.3.0.js | 43 +++---- 12 files changed, 687 insertions(+), 59 deletions(-) create mode 100644 wechathqchart/umychart.network.wechart.js diff --git a/README.md b/README.md index 59d222f21..71481fe87 100644 --- a/README.md +++ b/README.md @@ -368,6 +368,9 @@ React 例子:[demo-react.md](/教程/demo-react.md)
6. [HQChart实战教程16-K线图风格配色篇-仿火币网H5配色](https://blog.csdn.net/jones2000/article/details/106226272)
7. [HQChart实战教程47-火币网ws数据对接深度图](https://jones2000.blog.csdn.net/article/details/120950486)
+## 欧易对接完整教程(付费文章) +1. [HQChart实战教程54-欧易网http+ws数据对接(vue)](https://blog.csdn.net/jones2000/article/details/125213143)
+ ## 源码收费 1. [HQChart实战教程36-数字货币币安对接-uniapp版本](https://blog.csdn.net/jones2000/article/details/114468807)
2. [HQChart实战教程41-新浪+腾讯A股数据源对接-uniapp版本](https://blog.csdn.net/jones2000/article/details/117139756)
diff --git a/umychart_uniapp_h5/umychart.uniapp.h5.js b/umychart_uniapp_h5/umychart.uniapp.h5.js index 820280483..be2a37f79 100644 --- a/umychart_uniapp_h5/umychart.uniapp.h5.js +++ b/umychart_uniapp_h5/umychart.uniapp.h5.js @@ -4880,6 +4880,9 @@ function JSChart(divElement, bOffscreen) if(IFrameSplitOperator.IsBool(item.IsShowTime)) chart.TitlePaint[0].IsShowTime=item.IsShowTime; if(IFrameSplitOperator.IsBool(item.IsTitleShowLatestData)) chart.IsTitleShowLatestData=item.IsTitleShowLatestData; if(IFrameSplitOperator.IsBool(item.IsAlwaysShowLastData)) chart.TitlePaint[0].IsAlwaysShowLastData=item.IsAlwaysShowLastData; + if(IFrameSplitOperator.IsNumber(item.ShowLastDataFormat)) chart.TitlePaint[0].ShowLastDataFormat=item.ShowLastDataFormat; + + //if(option.KLineTitle.IsShow == false) chart.TitlePaint[0].IsShow = false; } @@ -8050,7 +8053,8 @@ function JSChartContainer(uielement, OffscreenElement) if (!item.IsDynamic) continue; item.CursorIndex=this.CursorIndex; - if (item.ClassName=='DynamicChartTitlePainting') item.OnDrawEvent=eventIndexTitleDraw + item.LastPoint=this.LastPoint; + if (item.ClassName=='DynamicChartTitlePainting') item.OnDrawEvent=eventIndexTitleDraw else item.OnDrawEvent=eventTitleDraw; if (item.OnDrawEvent) @@ -8214,6 +8218,7 @@ function JSChartContainer(uielement, OffscreenElement) if (!item.IsDynamic) continue; item.CursorIndex=this.CursorIndex; + item.LastPoint=this.LastPoint; if (item.OnDrawEvent) { item.OnDrawEvent.FunctionName='DrawDynamicInfo'; @@ -41519,6 +41524,7 @@ function IChartTitlePainting() this.IsDynamic=false; //是否是动态标题 this.Position=0; //标题显示位置 0 框架里的标题 1 框架上面 this.CursorIndex; //数据索引 + this.LastPoint; //鼠标位置 this.Font=g_JSChartResource.TitleFont; this.Title; //固定标题(可以为空) this.TitleColor=g_JSChartResource.DefaultTextColor; @@ -41874,6 +41880,7 @@ function DynamicMinuteTitlePainting() this.OnDrawEvent; this.PointInfo=null; this.IsAlwaysShowLastData=false; //始终显示最后一个数据 + this.ShowLastDataFormat=0; //0=默认 1=更新时间替换时间 this.MultiDayBeforeOpenData; //多日分时图 盘前数据 this.MultiDayAfterCloseData; //多日分时图 收盘数据 @@ -41994,8 +42001,22 @@ function DynamicMinuteTitlePainting() if (this.IsShowDate || this.IsShowTime) { - var text=IFrameSplitOperator.FormatDateTimeString(item.DateTime,this.IsShowDate, this.IsShowTime); - if (!this.DrawText(text,this.DateTimeColor,position)) return; + var bShowUpdateTime=false; //是否显示了更新时间 + if (isLastOne && this.ShowLastDataFormat==1) + { + if (this.Data && this.Data.UpdateTime && IFrameSplitOperator.IsNumber(this.Data.UpdateTime.Date) && IFrameSplitOperator.IsNumber(this.Data.UpdateTime.Time)) + { + var text=IFrameSplitOperator.FormatTimeString(this.Data.UpdateTime.Time, "HH:MM:SS"); + if (!this.DrawText(text,this.DateTimeColor,position)) return; + bShowUpdateTime=true; + } + } + + if (!bShowUpdateTime) + { + var text=IFrameSplitOperator.FormatDateTimeString(item.DateTime,this.IsShowDate, this.IsShowTime); + if (!this.DrawText(text,this.DateTimeColor,position)) return; + } } var close=item.Close; @@ -42051,7 +42072,7 @@ function DynamicMinuteTitlePainting() if (!this.DrawText(text,this.VolColor,position)) return; } - if (isLastOne) //显示数据最后的更新时间 + if (isLastOne && this.ShowLastDataFormat==0) //显示数据最后的更新时间 { if (this.Data && this.Data.UpdateTime && IFrameSplitOperator.IsNumber(this.Data.UpdateTime.Date) && IFrameSplitOperator.IsNumber(this.Data.UpdateTime.Time)) { @@ -42792,6 +42813,78 @@ function DynamicChartTitlePainting() return aryText; } + this.FormatVPVRTitle=function(pt, dataInfo) + { + var chart=dataInfo.Chart; + var aryText=[]; + + if (chart.VolType==0) + { + var item={ Text:" Up/Down ", Color:this.TitleColor }; + aryText.push(item); + } + else + { + var item={ Text:" Total ",Color:this.TitleColor }; + aryText.push(item); + } + + if (!IFrameSplitOperator.IsNumber(pt.Y)) return aryText; + var top=this.Frame.ChartBorder.GetTopEx(); + var bottom=this.Frame.ChartBorder.GetBottomEx(); + if (pt.Ybottom) return aryText; + var yPrice=this.Frame.GetYData(pt.Y); + + var find=null; + for(var i=0; i=item.Price-dataInfo.Data.PriceOffset/2 && yPricebottom) return aryText; + var yPrice=this.Frame.GetYData(pt.Y); + + var find=null; + for(var i=0; i=item.Price-dataInfo.Data.PriceOffset/2 && yPricebottom) return aryText; + var yPrice=this.Frame.GetYData(pt.Y); + + var find=null; + for(var i=0; i=item.Price-dataInfo.Data.PriceOffset/2 && yPricebottom) return aryText; + var yPrice=this.Frame.GetYData(pt.Y); + + var find=null; + for(var i=0; i=item.Price-dataInfo.Data.PriceOffset/2 && yPricebottom) return aryText; + var yPrice=this.Frame.GetYData(pt.Y); + + var find=null; + for(var i=0; i=item.Price-dataInfo.Data.PriceOffset/2 && yPrice JSUniAppCanvasHelper.MeasureText()'); + JSCommonUniApp.JSUniAppCanvasHelper.GetCanvasFont=function(canvas) + { + return canvas.state.font; + } + canvas.measureText = function (text) //uniapp 计算宽度需要自己计算 + { + var width = JSCommonUniApp.JSUniAppCanvasHelper.MeasureText(text, canvas); + return { width: width }; + } + return canvas; + } + if (this.CanvasNode && this.CanvasNode.node) { const width = this.CanvasNode.width; @@ -59,6 +94,8 @@ function JSCanvasElement() } } + + return canvas; } diff --git a/wechathqchart/umychart.network.wechart.js b/wechathqchart/umychart.network.wechart.js new file mode 100644 index 000000000..46fafc3c0 --- /dev/null +++ b/wechathqchart/umychart.network.wechart.js @@ -0,0 +1,62 @@ + +/* + copyright (c) 2018 jones + + http://www.apache.org/licenses/LICENSE-2.0 + + 开源项目 https://github.com/jones2000/HQChart + + jones_2000@163.com + + 网络通讯 +*/ + +function JSNetwork() +{ + +} + +JSNetwork.IsDingTalk=false; +JSNetwork.IsUniApp=false; + +JSNetwork.HttpRequest=function(obj) +{ + if (JSNetwork.IsDingTalk) + { + JSNetwork.DD_httpRequest(obj); + } + else + { + JSNetwork.WX_Reqeust(obj); + } +} + +JSNetwork.WX_Reqeust=function(obj) +{ + wx.request({ + url: obj.url, + data:obj.data, + method: obj.method, + dataType: obj.dataType, + success: obj.success, + error:obj.error + }); +} + + +JSNetwork.DD_httpRequest=function(obj) +{ + dd.httpRequest({ + url: obj.url, + method: obj.method, + data:obj.data, + dataType: obj.dataType, + success: obj.success + }); +} + + +export +{ + JSNetwork +}; \ No newline at end of file diff --git a/wechathqchart/umychart.uniapp.canvas.helper.js b/wechathqchart/umychart.uniapp.canvas.helper.js index 70faa84a8..51962636c 100644 --- a/wechathqchart/umychart.uniapp.canvas.helper.js +++ b/wechathqchart/umychart.uniapp.canvas.helper.js @@ -12,9 +12,14 @@ copyright (c) 2018 jones function JSUniAppCanvasHelper() { } +JSUniAppCanvasHelper.GetCanvasFont=function(canvas) +{ + return canvas.font; +} + JSUniAppCanvasHelper.MeasureText=function(text, canvas) { - var font = canvas.font; + var font= JSUniAppCanvasHelper.GetCanvasFont(canvas); var fontSize = 12; var pos=font.search('px'); if (pos>0) diff --git a/wechathqchart/umychart.wechat.3.0.js b/wechathqchart/umychart.wechat.3.0.js index 145a0bb6a..b382184c1 100644 --- a/wechathqchart/umychart.wechat.3.0.js +++ b/wechathqchart/umychart.wechat.3.0.js @@ -13,6 +13,8 @@ //日志 import { JSConsole } from "./umychart.console.wechat.js" +import { JSNetwork } from "./umychart.network.wechart.js" + import { JSCanvasElement } from "./umychart.element.wechart.js"; //行情数据结构体 及涉及到的行情算法(复权,周期等) @@ -1456,7 +1458,7 @@ function JSChartContainer(uielement) var url=`${atob(value)}?width=${width}&height=${height}&type=uniapp`; if (JSChart.LastVersion!=null) return; //只请求一次 - wx.request({ + JSNetwork.HttpRequest({ url: url, method:"get", dataType: "json", @@ -7587,7 +7589,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.KLineApiUrl, data: { @@ -7721,7 +7723,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.MinuteKLineApiUrl, data: { @@ -7842,7 +7844,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.RealtimeApiUrl, data: { @@ -7981,7 +7983,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.RealtimeApiUrl, data: { @@ -9029,7 +9031,7 @@ function KLineChartContainer(uielement) } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: this.KLineApiUrl, data: { @@ -9446,7 +9448,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.DragMinuteKLineApiUrl, data: postData, method: 'POST', @@ -9553,7 +9555,7 @@ function KLineChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.DragKLineApiUrl, data: postData, method: 'POST', @@ -10513,7 +10515,7 @@ function MinuteChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: self.HistoryMinuteApiUrl, data: { @@ -10689,7 +10691,7 @@ function MinuteChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: this.MinuteApiUrl, data: { @@ -10807,7 +10809,7 @@ function MinuteChartContainer(uielement) //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: self.HistoryMinuteApiUrl, data: { @@ -10898,7 +10900,7 @@ function MinuteChartContainer(uielement) if (obj.PreventDefault == true) return; //已被上层替换,不调用默认的网络请求 } - wx.request({ + JSNetwork.HttpRequest({ url: self.HistoryMinuteApiUrl, data: { @@ -11449,7 +11451,7 @@ function HistoryMinuteChartContainer(uielement) { var self = this; var url = this.HistoryMinuteApiUrl + this.TradeDate.toString() + "/" + this.Symbol + ".json"; - wx.request({ + JSNetwork.HttpRequest({ url: url, method: "get", dataType: "json", @@ -11604,7 +11606,7 @@ function CustomKLineChartContainer(uielement) { this.ChartSplashPaint.SetTitle(this.LoadDataSplashTitle); this.ChartSplashPaint.EnableSplash(true); this.Draw(); - wx.request({ + JSNetwork.HttpRequest({ url: this.CustomKLineApiUrl, data: { @@ -13125,7 +13127,7 @@ function MarketLongShortIndex() { } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: g_JSChartResource.Index.MarketLongShortApiUrl, data: { @@ -13245,7 +13247,7 @@ function MarketTimingIndex() { } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: g_JSChartResource.Index.MarketLongShortApiUrl, data: { @@ -13366,7 +13368,7 @@ function MarketAttentionIndex() { } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: this.ApiUrl, data: { @@ -13498,7 +13500,7 @@ function MarketHeatIndex() { } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: this.ApiUrl, data: { @@ -13638,7 +13640,7 @@ function CustonIndexHeatIndex() { } //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: this.ApiUrl, data: { @@ -13803,7 +13805,7 @@ function BenfordIndex() { } ]; //请求数据 - wx.request({ + JSNetwork.HttpRequest({ url: this.ApiUrl, data: { @@ -13944,6 +13946,7 @@ function IsIndexSymbol(symbol) { var JSCommon= { JSCanvasElement: JSCanvasElement, + JSNetwork:JSNetwork, JSChart: JSChart, Guid: Guid, IFrameSplitOperator: IFrameSplitOperator,