hqchart 1.1.12687 → 1.1.12706

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.
Files changed (228) hide show
  1. package/lib/umychart.vue.js +94 -50
  2. package/package.json +15 -47
  3. package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
  4. package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +409 -115
  5. package/src/jscommon/umychart.vue/umychart.vue.js +409 -115
  6. package/.babelrc +0 -6
  7. package/.vscode/settings.json +0 -4
  8. package/Makefile +0 -9
  9. package/README.md +0 -452
  10. package/index.js +0 -17
  11. package/postcss.config.js +0 -5
  12. package/src/index.html +0 -18
  13. package/src/jscommon/backup/announcement.png +0 -0
  14. package/src/jscommon/backup/announcement2.png +0 -0
  15. package/src/jscommon/backup/blocktrading.png +0 -0
  16. package/src/jscommon/backup/investor.png +0 -0
  17. package/src/jscommon/backup/pforecast.png +0 -0
  18. package/src/jscommon/backup/research.png +0 -0
  19. package/src/jscommon/backup/tradedetail.png +0 -0
  20. package/src/jscommon/backup/umychart - backup.js +0 -17631
  21. package/src/jscommon/backup/umychart.macro.js +0 -4
  22. package/src/jscommon/backup/umychart.macro.vue.js +0 -3
  23. package/src/jscommon/commonindextree.json +0 -92
  24. package/src/jscommon/index.html +0 -13
  25. package/src/jscommon/jschinamapdata.js +0 -3
  26. package/src/jscommon/umychart.NetworkFilterTest.js +0 -48803
  27. package/src/jscommon/umychart.aliYunnetwork.js +0 -47
  28. package/src/jscommon/umychart.cninfo.components/readme.txt +0 -1
  29. package/src/jscommon/umychart.complier.js +0 -25291
  30. package/src/jscommon/umychart.complier.node/umychart.complier.controller.js +0 -559
  31. package/src/jscommon/umychart.complier.node/umychart.complier.node.js +0 -7043
  32. package/src/jscommon/umychart.complier.node/umychart.data.node.js +0 -816
  33. package/src/jscommon/umychart.console.js +0 -12
  34. package/src/jscommon/umychart.deal.js +0 -1452
  35. package/src/jscommon/umychart.dragdiv.js +0 -48
  36. package/src/jscommon/umychart.index.data.js +0 -4132
  37. package/src/jscommon/umychart.js +0 -90257
  38. package/src/jscommon/umychart.keyboard.js +0 -1659
  39. package/src/jscommon/umychart.listctrl.js +0 -690
  40. package/src/jscommon/umychart.mind.js +0 -2203
  41. package/src/jscommon/umychart.network.js +0 -44
  42. package/src/jscommon/umychart.news.js +0 -823
  43. package/src/jscommon/umychart.node.build/buildall.bat +0 -1
  44. package/src/jscommon/umychart.node.build/umychart.node.bat +0 -1
  45. package/src/jscommon/umychart.node.build/umychart.node.export.js +0 -40
  46. package/src/jscommon/umychart.regressiontest.js +0 -400
  47. package/src/jscommon/umychart.report.js +0 -5803
  48. package/src/jscommon/umychart.scrollbar.js +0 -1345
  49. package/src/jscommon/umychart.stock.js +0 -4218
  50. package/src/jscommon/umychart.style.js +0 -618
  51. package/src/jscommon/umychart.testdata.js +0 -150
  52. package/src/jscommon/umychart.uniapp.build/buildall.bat +0 -1
  53. package/src/jscommon/umychart.uniapp.build/umychart.bat +0 -1
  54. package/src/jscommon/umychart.uniapp.build/umychart.export.js +0 -70
  55. package/src/jscommon/umychart.user.js +0 -137
  56. package/src/jscommon/umychart.version.js +0 -30
  57. package/src/jscommon/umychart.vue/umychart.aliYunnetwork.vue.js +0 -56
  58. package/src/jscommon/umychart.vue.build/buildall.bat +0 -4
  59. package/src/jscommon/umychart.vue.build/copy_codemirror.bat +0 -2
  60. package/src/jscommon/umychart.vue.build/umychart.aliYunnetwork.vue.export.js +0 -9
  61. package/src/jscommon/umychart.vue.build/umychart.dragdiv.bat +0 -1
  62. package/src/jscommon/umychart.vue.build/umychart.dragdiv.export.js +0 -6
  63. package/src/jscommon/umychart.vue.build/umychart.index.data.bat +0 -1
  64. package/src/jscommon/umychart.vue.build/umychart.index.data.export.js +0 -4
  65. package/src/jscommon/umychart.vue.build/umychart.listctrl.vue.export.js +0 -15
  66. package/src/jscommon/umychart.vue.build/umychart.regressiontest.vue.export.js +0 -7
  67. package/src/jscommon/umychart.vue.build/umychart.regressiontest.wechat.export.js +0 -12
  68. package/src/jscommon/umychart.vue.build/umychart.stock.bat +0 -1
  69. package/src/jscommon/umychart.vue.build/umychart.stock.vue.export.js +0 -16
  70. package/src/jscommon/umychart.vue.build/umychart.testdata.bat +0 -3
  71. package/src/jscommon/umychart.vue.build/umychart.testdata.vue.export.js +0 -7
  72. package/src/jscommon/umychart.vue.build/umychart.vue.bat +0 -8
  73. package/src/jscommon/umychart.vue.build/umychart.vue.export.js +0 -112
  74. package/src/jscommon/umychart.vue.components/empyt.vue +0 -51
  75. package/src/jscommon/umychart.vue.components/historydayline.vue +0 -240
  76. package/src/jscommon/umychart.vue.components/jsloader.adddialog.vue +0 -315
  77. package/src/jscommon/umychart.vue.components/jsloader.vue +0 -93
  78. package/src/jscommon/umychart.vue.components/jsvuecontainer.vue +0 -160
  79. package/src/jscommon/umychart.vue.components/jsvuecontainer2.0.vue +0 -391
  80. package/src/jscommon/umychart.vue.components/login.vue +0 -178
  81. package/src/jscommon/umychart.vue.components/queryContent.vue +0 -750
  82. package/src/jscommon/umychart.vue.components/readme.txt +0 -8
  83. package/src/jscommon/umychart.vue.components/searchsymbol.vue +0 -299
  84. package/src/jscommon/umychart.vue.components/simulatetrade.vue +0 -1471
  85. package/src/jscommon/umychart.vue.components/stockchart.vue +0 -343
  86. package/src/jscommon/umychart.vue.components/stockchartV2.vue +0 -195
  87. package/src/jscommon/umychart.vue.components/stockdeal.vue +0 -358
  88. package/src/jscommon/umychart.vue.components/stockdealcount.vue +0 -262
  89. package/src/jscommon/umychart.vue.components/stockdeallastest.vue +0 -316
  90. package/src/jscommon/umychart.vue.components/stockdrawtool.vue +0 -343
  91. package/src/jscommon/umychart.vue.components/stockfull.vue +0 -355
  92. package/src/jscommon/umychart.vue.components/stockinfo.demo.vue +0 -153
  93. package/src/jscommon/umychart.vue.components/stockinfo.vue +0 -685
  94. package/src/jscommon/umychart.vue.components/stockkline.demo.vue +0 -1904
  95. package/src/jscommon/umychart.vue.components/stockmultiorder.vue +0 -174
  96. package/src/jscommon/umychart.vue.components/stockmultiperiod.vue +0 -222
  97. package/src/jscommon/umychart.vue.components/stockorder.vue +0 -320
  98. package/src/jscommon/umychart.vue.components/stocktradeinfo.demo.vue +0 -250
  99. package/src/jscommon/umychart.vue.components/stocktradeinfo.vue +0 -1907
  100. package/src/jscommon/umychart.vue.components/test.vue +0 -0
  101. package/src/jscommon/umychart.wechat/getDate.wechat.js +0 -91
  102. package/src/jscommon/umychart.wechat/lighter.news.wechat.js +0 -262
  103. package/src/jscommon/umychart.wechat/readme.txt +0 -3
  104. package/src/jscommon/umychart.wechat/umychart.analyze.wechat.js +0 -551
  105. package/src/jscommon/umychart.wechat/umychart.apidraw.wechat.js +0 -126
  106. package/src/jscommon/umychart.wechat/umychart.bigV.wechat.js +0 -2510
  107. package/src/jscommon/umychart.wechat/umychart.chartframe.wechat.js +0 -2931
  108. package/src/jscommon/umychart.wechat/umychart.chartpaint.wechat.js +0 -9752
  109. package/src/jscommon/umychart.wechat/umychart.charttitle.wechat.js +0 -2023
  110. package/src/jscommon/umychart.wechat/umychart.complier.wechat.js +0 -14726
  111. package/src/jscommon/umychart.wechat/umychart.console.wechat.js +0 -8
  112. package/src/jscommon/umychart.wechat/umychart.coordinatedata.wechat.js +0 -3654
  113. package/src/jscommon/umychart.wechat/umychart.data.wechat.js +0 -2243
  114. package/src/jscommon/umychart.wechat/umychart.element.wechart.js +0 -132
  115. package/src/jscommon/umychart.wechat/umychart.explainer.wechat.js +0 -1077
  116. package/src/jscommon/umychart.wechat/umychart.extendchart.wechat.js +0 -1140
  117. package/src/jscommon/umychart.wechat/umychart.framesplit.wechat.js +0 -2247
  118. package/src/jscommon/umychart.wechat/umychart.hqIndexformula.wechat.js +0 -941
  119. package/src/jscommon/umychart.wechat/umychart.index.data.wechat.js +0 -3628
  120. package/src/jscommon/umychart.wechat/umychart.index.wechat.js +0 -4074
  121. package/src/jscommon/umychart.wechat/umychart.klineinfo.wechat.js +0 -836
  122. package/src/jscommon/umychart.wechat/umychart.markethot.js +0 -50
  123. package/src/jscommon/umychart.wechat/umychart.network.wechart.js +0 -62
  124. package/src/jscommon/umychart.wechat/umychart.news.wechat.js +0 -3568
  125. package/src/jscommon/umychart.wechat/umychart.regressiontest.wechat.js +0 -412
  126. package/src/jscommon/umychart.wechat/umychart.report.wechat.js +0 -3983
  127. package/src/jscommon/umychart.wechat/umychart.resource.wechat.js +0 -919
  128. package/src/jscommon/umychart.wechat/umychart.shareimage.wechat.js +0 -681
  129. package/src/jscommon/umychart.wechat/umychart.simulatetrade.wechat.js +0 -238
  130. package/src/jscommon/umychart.wechat/umychart.stock.wechat.js +0 -4035
  131. package/src/jscommon/umychart.wechat/umychart.style.wechat.js +0 -419
  132. package/src/jscommon/umychart.wechat/umychart.uniapp.canvas.helper.js +0 -99
  133. package/src/jscommon/umychart.wechat/umychart.user.wechat.js +0 -588
  134. package/src/jscommon/umychart.wechat/umychart.userlog.wechat.js +0 -240
  135. package/src/jscommon/umychart.wechat/umychart.vedio.wechat.js +0 -112
  136. package/src/jscommon/umychart.wechat/umychart.version.wechat.js +0 -36
  137. package/src/jscommon/umychart.wechat/umychart.wechat.3.0.js +0 -12051
  138. package/src/jscommon/umychart.wechat/umychart.wechat.js +0 -15460
  139. package/src/jscommon/umychart.worker.js +0 -114
  140. package/src/jscommon/umychart.ws.stock.js +0 -110
  141. package/src/jscommon/umychart_python/.vscode/launch.json +0 -15
  142. package/src/jscommon/umychart_python/__init__.py +0 -4
  143. package/src/jscommon/umychart_python/build.cmd +0 -2
  144. package/src/jscommon/umychart_python/setup.py +0 -25
  145. package/src/jscommon/umychart_python/umychart_cache_testcase.py +0 -165
  146. package/src/jscommon/umychart_python/umychart_complier_data.py +0 -781
  147. package/src/jscommon/umychart_python/umychart_complier_help.py +0 -175
  148. package/src/jscommon/umychart_python/umychart_complier_job.py +0 -193
  149. package/src/jscommon/umychart_python/umychart_complier_jsalgorithm.py +0 -4144
  150. package/src/jscommon/umychart_python/umychart_complier_jscomplier.py +0 -177
  151. package/src/jscommon/umychart_python/umychart_complier_jsexecute.py +0 -517
  152. package/src/jscommon/umychart_python/umychart_complier_jsparser.py +0 -864
  153. package/src/jscommon/umychart_python/umychart_complier_jssymboldata.py +0 -1238
  154. package/src/jscommon/umychart_python/umychart_complier_jssymboldata_cache.py +0 -146
  155. package/src/jscommon/umychart_python/umychart_complier_jssymboldata_json.py +0 -106
  156. package/src/jscommon/umychart_python/umychart_complier_pandas_help.py +0 -80
  157. package/src/jscommon/umychart_python/umychart_complier_scanner.py +0 -554
  158. package/src/jscommon/umychart_python/umychart_complier_testcase.py +0 -362
  159. package/src/jscommon/umychart_python/umychart_complier_util.py +0 -30
  160. package/src/jscommon/umychart_python/umychart_webtemplate.py +0 -131
  161. package/src/jscommon/umychart_python/updatehqchartweb.bat +0 -5
  162. package/src/jscommon/vendor.js +0 -2
  163. package/src/pages/block.list.demo.page/App.vue +0 -117
  164. package/src/pages/block.list.demo.page/index.js +0 -12
  165. package/src/pages/brushTool.demo.page/App.vue +0 -19
  166. package/src/pages/brushTool.demo.page/index.js +0 -12
  167. package/src/pages/container.demo.page/App.vue +0 -118
  168. package/src/pages/container.demo.page/index.js +0 -18
  169. package/src/pages/dataZoom.demo.page/App.vue +0 -265
  170. package/src/pages/dataZoom.demo.page/components/dataZoom.vue +0 -303
  171. package/src/pages/dataZoom.demo.page/index.js +0 -12
  172. package/src/pages/historydayline.demo.page/App.vue +0 -57
  173. package/src/pages/historydayline.demo.page/index.js +0 -12
  174. package/src/pages/hq.demo.page/App.vue +0 -163
  175. package/src/pages/hq.demo.page/index.js +0 -12
  176. package/src/pages/hqchart.black/App.vue +0 -90
  177. package/src/pages/hqchart.black/components/searchsymbol.vue +0 -299
  178. package/src/pages/hqchart.black/components/stockdrawtool.vue +0 -300
  179. package/src/pages/hqchart.black/components/stockfull.vue +0 -313
  180. package/src/pages/hqchart.black/components/stockinfo.vue +0 -428
  181. package/src/pages/hqchart.black/components/stockkline.demo.vue +0 -1652
  182. package/src/pages/hqchart.black/components/stocktradeinfo.vue +0 -1337
  183. package/src/pages/hqchart.black/index.js +0 -30
  184. package/src/pages/hqchart.black/router/candlestickChart.vue +0 -108
  185. package/src/pages/hqchart.black/router/pricePointsTable.vue +0 -294
  186. package/src/pages/hqchart.black/router/stockDeallas.vue +0 -417
  187. package/src/pages/hqchart.black/router/timeShareChart.vue +0 -108
  188. package/src/pages/hqchart.page/App.vue +0 -101
  189. package/src/pages/hqchart.page/index.js +0 -18
  190. package/src/pages/index/App.vue +0 -1408
  191. package/src/pages/index/index.js +0 -7
  192. package/src/pages/indexHq/App.vue +0 -110
  193. package/src/pages/indexHq/index.js +0 -18
  194. package/src/pages/login.demo.page/App.vue +0 -22
  195. package/src/pages/login.demo.page/index.js +0 -12
  196. package/src/pages/queryContent.demo.page/App.vue +0 -29
  197. package/src/pages/queryContent.demo.page/index.js +0 -18
  198. package/src/pages/ranking.black/App.vue +0 -199
  199. package/src/pages/ranking.black/index.js +0 -18
  200. package/src/pages/search.demo.page/App.vue +0 -28
  201. package/src/pages/search.demo.page/index.js +0 -12
  202. package/src/pages/simulatetrade.demo.page/app.vue +0 -121
  203. package/src/pages/simulatetrade.demo.page/index.js +0 -17
  204. package/src/pages/stockdeal.demo.page/App.vue +0 -63
  205. package/src/pages/stockdeal.demo.page/index.js +0 -19
  206. package/src/pages/stockdealcount.demo.page/App.vue +0 -37
  207. package/src/pages/stockdealcount.demo.page/index.js +0 -12
  208. package/src/pages/stockdeallastest.demo.page/App.vue +0 -74
  209. package/src/pages/stockdeallastest.demo.page/index.js +0 -18
  210. package/src/pages/stockinfo.demo.page/App.vue +0 -92
  211. package/src/pages/stockinfo.demo.page/index.html +0 -13
  212. package/src/pages/stockinfo.demo.page/index.js +0 -19
  213. package/src/pages/stockkline.demo.page/App.vue +0 -55
  214. package/src/pages/stockkline.demo.page/index.js +0 -18
  215. package/src/pages/stockmultiorder.demo.page/App.vue +0 -149
  216. package/src/pages/stockmultiorder.demo.page/index.js +0 -18
  217. package/src/pages/stockmultiperiod.demo.page/App.vue +0 -87
  218. package/src/pages/stockmultiperiod.demo.page/index.js +0 -18
  219. package/src/pages/stockorder.demo.page/App.vue +0 -69
  220. package/src/pages/stockorder.demo.page/index.js +0 -18
  221. package/src/pages/test/App.vue +0 -22
  222. package/src/pages/test/index.js +0 -7
  223. package/src/pages/tradeinfopage/app.vue +0 -40
  224. package/src/pages/tradeinfopage/index.js +0 -7
  225. package/src/pages/tradeinfopage/tradeinfo.html +0 -12
  226. package/src/utils/urlObj.js +0 -81
  227. package/src/vendor.js +0 -2
  228. package/webpack.config.js +0 -104
@@ -1,2023 +0,0 @@
1
- /*
2
- copyright (c) 2018 jones
3
-
4
- http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- 开源项目 https://github.com/jones2000/HQChart
7
-
8
- jones_2000@163.com
9
-
10
- 标题画法
11
- */
12
-
13
- import
14
- {
15
- g_JSChartResource,
16
- JSCHART_LANGUAGE_ID,
17
- g_JSChartLocalization,
18
- } from './umychart.resource.wechat.js'
19
-
20
- import
21
- {
22
- ChartData, HistoryData,
23
- SingleData, MinuteData,
24
- CUSTOM_DAY_PERIOD_START,
25
- CUSTOM_DAY_PERIOD_END,
26
- CUSTOM_MINUTE_PERIOD_START,
27
- CUSTOM_MINUTE_PERIOD_END,
28
- CUSTOM_SECOND_PERIOD_START,
29
- CUSTOM_SECOND_PERIOD_END,
30
- JSCHART_EVENT_ID,
31
- } from "./umychart.data.wechat.js";
32
-
33
- import
34
- {
35
- JSCommonCoordinateData
36
- } from "./umychart.coordinatedata.wechat.js";
37
-
38
- import
39
- {
40
- KLINE_INFO_TYPE,
41
- } from "./umychart.klineinfo.wechat.js";
42
-
43
- import
44
- {
45
- IFrameSplitOperator,
46
- } from './umychart.framesplit.wechat.js'
47
-
48
- var MARKET_SUFFIX_NAME = JSCommonCoordinateData.MARKET_SUFFIX_NAME;
49
-
50
- function ToFixedPoint(value)
51
- {
52
- //return value;
53
- return parseInt(value) + 0.5;
54
- }
55
-
56
- function ToFixedRect(value)
57
- {
58
- var rounded;
59
- return rounded = (0.5 + value) << 0;
60
- }
61
-
62
- //标题画法基类
63
- function IChartTitlePainting()
64
- {
65
- this.Frame;
66
- this.Data = new Array();
67
- this.Canvas; //画布
68
- this.IsDynamic = false; //是否是动态标题
69
- this.Position = 0; //标题显示位置 0 框架里的标题 1 框架上面
70
- this.CursorIndex; //数据索引
71
- this.Font = g_JSChartResource.DynamicTitleFont;//"12px 微软雅黑";
72
- this.Title; //固定标题(可以为空)
73
- this.TitleColor = g_JSChartResource.DefaultTextColor;
74
- this.LanguageID = JSCHART_LANGUAGE_ID.LANGUAGE_CHINESE_ID;
75
- this.UpdateUICallback; //通知外面更新标题(老接口废弃)
76
- this.OnDrawEvent; //外部事件通知
77
- this.GetEventCallback; //事件回调,新的版本同意都用这个
78
- }
79
-
80
- var PERIOD_NAME = ["日线", "周线", "月线", "年线", "1分", "5分", "15分", "30分", "60分", "季线", "分笔", "2小时", "4小时", "", ""];
81
- var RIGHT_NAME = ['不复权', '前复权', '后复权'];
82
- //K线标题
83
- function DynamicKLineTitlePainting()
84
- {
85
- this.newMethod = IChartTitlePainting; //派生
86
- this.newMethod();
87
- delete this.newMethod;
88
-
89
- this.ClassName ='DynamicKLineTitlePainting';
90
- this.IsDynamic = true;
91
- this.IsShow = true; //是否显示
92
- this.LineCount = 1; //默认显示1行
93
- this.SpaceWidth = 1; //空格宽度
94
- this.TextSpace=-1; //文字之间的间距
95
-
96
- this.DateTimeSpace=2; //日期时间向后间距
97
- this.PeriodSpace=1; //周期向后间距
98
- this.NameSpace=1; //名字向后间距
99
-
100
- this.Period; //周期
101
-
102
- this.UpColor = g_JSChartResource.UpTextColor;
103
- this.DownColor = g_JSChartResource.DownTextColor;
104
- this.UnchagneColor = g_JSChartResource.UnchagneTextColor;
105
-
106
- this.VolColor=g_JSChartResource.Title.VolColor;
107
- this.AmountColor=g_JSChartResource.Title.AmountColor;
108
- this.DateTimeColor=g_JSChartResource.Title.DateTimeColor;
109
- this.NameColor = g_JSChartResource.Title.NameColor;
110
- this.SettingColor=g_JSChartResource.Title.SettingColor; //周期 复权
111
- this.PositionColor=g_JSChartResource.Title.PositionColor; //持仓
112
-
113
- this.Symbol;
114
- this.UpperSymbol;
115
- this.Name;
116
- this.InfoData;
117
- this.InfoTextHeight = 15;
118
- this.InfoTextColor = g_JSChartResource.KLine.Info.TextColor;
119
- this.InfoTextBGColor = g_JSChartResource.KLine.Info.TextBGColor;
120
-
121
- this.IsShowName = true; //是否显示股票名称
122
- this.IsShowSettingInfo = true; //是否显示设置信息(周期 复权)
123
- this.HQChart;
124
-
125
- this.GetCurrentKLineData = function () //获取当天鼠标位置所在的K线数据
126
- {
127
- if (this.CursorIndex == null || !this.Data) return null;
128
- if (this.Data.length <= 0) return null;
129
-
130
- var index = this.CursorIndex;
131
- index = parseInt(index.toFixed(0));
132
- var dataIndex = this.Data.DataOffset + index;
133
- if (dataIndex >= this.Data.Data.length) dataIndex = this.Data.Data.length - 1;
134
- if (dataIndex < 0) return null;
135
-
136
- var item = this.Data.Data[dataIndex];
137
- return item;
138
- }
139
-
140
- this.GetDataIndex=function()
141
- {
142
- if (this.CursorIndex == null || !this.Data) return null;
143
- if (this.Data.length <= 0) return null;
144
-
145
- var index = this.CursorIndex;
146
- index = parseInt(index.toFixed(0));
147
- var dataIndex = this.Data.DataOffset + index;
148
- if (dataIndex >= this.Data.Data.length) dataIndex = this.Data.Data.length - 1;
149
- if (dataIndex < 0) return null;
150
-
151
- return dataIndex;
152
- }
153
-
154
- this.SendUpdateUIMessage = function (funcName) //通知外面 标题变了
155
- {
156
- if (!this.UpdateUICallback) return;
157
-
158
- var sendData = {
159
- TitleName: 'K线标题', CallFunction: funcName, Stock: { Name: this.Name, Symbol: this.Symbol, },
160
- Rect:
161
- {
162
- Left: this.Frame.ChartBorder.GetLeft(), Right: this.Frame.ChartBorder.GetRight(),
163
- Top: 0, Bottom: this.Frame.ChartBorder.GetTop(),
164
- }
165
- };
166
-
167
- //有数据
168
- if (this.Data && this.Data.Data && this.Data.Data.length > 0) {
169
- let index = this.Data.Data.length - 1; //默认最后一天的数据
170
- if (this.CursorIndex) {
171
- let cursorIndex = Math.abs(this.CursorIndex - 0.5);
172
- cursorIndex = parseInt(cursorIndex.toFixed(0));
173
- index = this.Data.DataOffset + cursorIndex;
174
- if (index >= this.Data.Data.length) index = this.Data.Data.length - 1;
175
- }
176
-
177
- if (index >= 0) {
178
- let item = this.Data.Data[index];
179
- sendData.Stock.Data =
180
- {
181
- Date: item.Date,
182
- YClose: item.YClose, Open: item.Open, High: item.High, Low: item.Low, Close: item.Close,
183
- Vol: item.Vol, Amount: item.Amount
184
- }
185
- if (item.Time) sendData.Stock.Time = item.Time; //分钟K线才有时间
186
- }
187
-
188
- if (this.Data.Period != null) sendData.Stock.PeriodName = this.GetPeriodName(this.Data.Period); //周期名字
189
- if (this.Data.Right != null) sendData.Stock.RightName = RIGHT_NAME[this.Data.Right]; //复权名字
190
- }
191
-
192
- //console.log('[DynamicKLineTitlePainting::SendUpdateUIMessage', sendData);
193
- this.UpdateUICallback(sendData);
194
- }
195
-
196
- this.GetPeriodName = function (period)
197
- {
198
- var name = '';
199
- if (period > CUSTOM_MINUTE_PERIOD_START && period <= CUSTOM_MINUTE_PERIOD_END)
200
- name = (period - CUSTOM_MINUTE_PERIOD_START) + g_JSChartLocalization.GetText('自定义分钟', this.LanguageID);
201
- else if (period > CUSTOM_DAY_PERIOD_START && period <= CUSTOM_DAY_PERIOD_END)
202
- name = (period - CUSTOM_DAY_PERIOD_START) + g_JSChartLocalization.GetText('自定义日线',this.LanguageID);
203
- else if (period > CUSTOM_SECOND_PERIOD_START && period <= CUSTOM_SECOND_PERIOD_END)
204
- name = (period - CUSTOM_SECOND_PERIOD_START) + g_JSChartLocalization.GetText('自定义秒', this.LanguageID);
205
- else
206
- name = g_JSChartLocalization.GetText(ChartData.GetPeriodName(period), this.LanguageID);
207
- return name;
208
- }
209
-
210
- this.GetRightName = function (rightID, periodID)
211
- {
212
- if (!MARKET_SUFFIX_NAME.IsEnableRight(periodID, this.Symbol, this.HQChart.RightFormula)) return null;
213
-
214
- var rightName = RIGHT_NAME[rightID];
215
- return rightName
216
- }
217
-
218
- this.FullDraw=function()
219
- {
220
- if (!this.IsShow) return;
221
- this.UpperSymbol=this.Symbol ? this.Symbol.toUpperCase():'';
222
- if (this.CursorIndex == null || !this.Data || this.Data.length <= 0)
223
- {
224
- this.OnDrawEventCallback(null, 'DynamicKLineTitlePainting::FullDraw');
225
- return;
226
- }
227
-
228
- if (this.TextSpace>=0)
229
- {
230
- this.SpaceWidth=this.TextSpace;
231
- }
232
- else
233
- {
234
- this.Canvas.font = this.Font;
235
- this.SpaceWidth = this.Canvas.measureText(' ').width;
236
- }
237
- var index = this.CursorIndex;
238
- index = parseInt(index.toFixed(0));
239
- var dataIndex = this.Data.DataOffset + index;
240
- if (dataIndex >= this.Data.Data.length) dataIndex=-1;
241
- if (dataIndex < 0)
242
- {
243
- this.OnDrawEventCallback(null, 'DynamicKLineTitlePainting::FullDraw');
244
- return;
245
- }
246
-
247
- var item = this.Data.Data[dataIndex];
248
- this.OnDrawEventCallback(item, 'DynamicKLineTitlePainting::FullDraw');
249
-
250
- //console.log('[FullDraw]', item);
251
-
252
- if (this.Frame.IsHScreen === true)
253
- {
254
- this.Canvas.save();
255
- if (this.LineCount > 1) this.DrawMulitLine(item);
256
- else this.DrawSingleLine(item,true);
257
- this.Canvas.restore();
258
- if (!item.Time && item.Date && this.InfoData) this.HSCreenKLineInfoDraw(item.Date);
259
- }
260
- else
261
- {
262
- if (this.LineCount > 1) this.DrawMulitLine(item);
263
- else this.DrawSingleLine(item, true);
264
- if (!item.Time && item.Date && this.InfoData) this.KLineInfoDraw(item.Date);
265
- }
266
- }
267
-
268
- this.DrawTitle = function ()
269
- {
270
- this.UpperSymbol=this.Symbol ? this.Symbol.toUpperCase():'';
271
- this.SendUpdateUIMessage('DrawTitle');
272
- this.OnDrawEventCallback(null, 'DynamicKLineTitlePainting::DrawTitle');
273
-
274
- if (!this.IsShow) return;
275
- if (!this.IsShowName && !this.IsShowSettingInfo) return;
276
- if (this.LineCount > 1) return;
277
-
278
- if (this.Frame.IsHScreen === true)
279
- {
280
- this.Canvas.save();
281
- this.HScreenDrawTitle();
282
- this.Canvas.restore();
283
- return;
284
- }
285
-
286
- var left = this.Frame.ChartBorder.GetLeft();
287
- var bottom = this.Frame.ChartBorder.GetTop();
288
- var right = this.Frame.ChartBorder.GetRight();
289
- if (bottom < 5) return;
290
-
291
- this.Canvas.textAlign = "left";
292
- this.Canvas.textBaseline = "bottom";
293
- this.Canvas.font = this.Font;
294
- var position = { Left: left, Bottom: bottom, IsHScreen: false };
295
-
296
- if (this.IsShowName && this.Name)
297
- {
298
- if (!this.DrawKLineText(this.Name, this.NameColor, position)) return;
299
- }
300
-
301
- if (this.IsShowSettingInfo && this.Data.Period != null && this.Data.Right != null)
302
- {
303
- var periodName = this.GetPeriodName(this.Data.Period);
304
- var rightName = this.GetRightName(this.Data.Right,this.Data.Period);
305
- var text = "(" + periodName + ")";
306
- if (rightName) text = "(" + periodName + " " + rightName + ")";
307
- if (!this.DrawKLineText(text, this.SettingColor, position)) return;
308
- }
309
- }
310
-
311
- this.HScreenDrawTitle = function ()
312
- {
313
- var xText = this.Frame.ChartBorder.GetRight();
314
- var yText = this.Frame.ChartBorder.GetTop();
315
- var right = this.Frame.ChartBorder.GetHeight();
316
- if (this.Frame.ChartBorder.Right < 10) return;
317
-
318
- this.Canvas.translate(xText, yText);
319
- this.Canvas.rotate(90 * Math.PI / 180);
320
-
321
- this.Canvas.textAlign = "left";
322
- this.Canvas.textBaseline = "bottom";
323
- this.Canvas.font = this.Font;
324
-
325
- var left = 2;
326
- var bottom = -2;
327
- var position = { Left: left, Bottom: bottom, IsHScreen: false };
328
- if (this.IsShowName && this.Name)
329
- {
330
- if (!this.DrawKLineText(this.Name, this.NameColor, position)) return;
331
- }
332
-
333
- if (this.IsShowSettingInfo && this.Data.Period != null && this.Data.Right != null)
334
- {
335
- var periodName = this.GetPeriodName(this.Data.Period);
336
- var rightName = this.GetRightName(this.Data.Right,this.Data.Period);
337
- var text = "(" + periodName + ")";
338
- if (rightName) text = "(" + periodName + " " + rightName + ")";
339
- if (!this.DrawKLineText(text, this.SettingColor, position)) return;
340
- }
341
- }
342
-
343
- this.DrawMulitLine = function (item) //画多行
344
- {
345
- var isHScreen = this.Frame.IsHScreen === true;
346
- var leftSpace = 1;
347
- var bottomSpace = 1;
348
- var left = this.Frame.ChartBorder.GetLeft() + leftSpace;;
349
- var width = this.Frame.ChartBorder.GetWidth();
350
- var height = this.Frame.ChartBorder.GetTop();
351
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);//价格小数位数
352
- if (isHScreen)
353
- {
354
- var left = leftSpace;;
355
- var width = this.Frame.ChartBorder.GetHeight();
356
- var height = this.Frame.ChartBorder.Right;
357
- var xText = this.Frame.ChartBorder.GetChartWidth();
358
- var yText = this.Frame.ChartBorder.GetTop();
359
-
360
- this.Canvas.translate(xText, yText);
361
- this.Canvas.rotate(90 * Math.PI / 180);
362
- }
363
-
364
- var itemHeight = (height - bottomSpace) / this.LineCount;
365
- var itemWidth = (width - leftSpace) / 4;
366
- var bottom = itemHeight;
367
-
368
- this.Canvas.textAlign = "left";
369
- this.Canvas.textBaseline = "bottom";
370
- this.Canvas.font = this.Font;
371
-
372
- var text = IFrameSplitOperator.FormatDateString(item.Date);
373
- this.Canvas.fillStyle = this.DateTimeColor;
374
- this.Canvas.fillText(text, left, bottom, itemWidth);
375
- left += itemWidth;
376
-
377
- this.Canvas.textAlign = "left";
378
- this.Canvas.fillStyle = this.GetColor(item.Open, item.YClose);
379
- var text = g_JSChartLocalization.GetText('Tooltip-Open', this.LanguageID) + item.Open.toFixed(defaultfloatPrecision);
380
- this.Canvas.fillText(text, left, bottom, itemWidth);
381
- left += itemWidth;
382
-
383
- this.Canvas.fillStyle = this.GetColor(item.High, item.YClose);
384
- var text = g_JSChartLocalization.GetText('Tooltip-High', this.LanguageID) + item.High.toFixed(defaultfloatPrecision);
385
- this.Canvas.fillText(text, left, bottom, itemWidth);
386
- left += itemWidth;
387
-
388
- var value = (item.Close - item.YClose) / item.YClose * 100;
389
- this.Canvas.fillStyle = this.GetColor(value, 0);
390
- var text = g_JSChartLocalization.GetText('Tooltip-Increase', this.LanguageID) + value.toFixed(2) + '%';
391
- this.Canvas.fillText(text, left, bottom, itemWidth);
392
- left += itemWidth;
393
-
394
- bottom += itemHeight; //换行
395
- var left = this.Frame.ChartBorder.GetLeft() + leftSpace;
396
- if (isHScreen) left = leftSpace;
397
- if (ChartData.IsMinutePeriod(this.Period, true) && item.Time)
398
- {
399
- this.Canvas.fillStyle = this.DateTimeColor;
400
- var text = IFrameSplitOperator.FormatTimeString(item.Time);
401
- this.Canvas.fillText(text, left, bottom, itemWidth);
402
- }
403
- else if (ChartData.IsSecondPeriod(this.Period) && item.Time)
404
- {
405
- this.Canvas.fillStyle = this.SettingColor;
406
- var text = IFrameSplitOperator.FormatTimeString(item.Time, 'HH:MM:SS');
407
- this.Canvas.fillText(text, left, bottom, itemWidth);
408
- }
409
- left += itemWidth;
410
-
411
- this.Canvas.fillStyle = this.GetColor(item.Close, item.YClose);
412
- var text = g_JSChartLocalization.GetText('Tooltip-Close', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
413
- this.Canvas.fillText(text, left, bottom, itemWidth);
414
- left += itemWidth;
415
-
416
- this.Canvas.fillStyle = this.GetColor(item.Low, item.YClose);
417
- var text = g_JSChartLocalization.GetText('Tooltip-Low', this.LanguageID) + item.Low.toFixed(defaultfloatPrecision);
418
- this.Canvas.fillText(text, left, bottom, itemWidth);
419
- left += itemWidth;
420
-
421
- this.Canvas.fillStyle = this.AmountColor;
422
- var text = g_JSChartLocalization.GetText('Tooltip-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
423
- this.Canvas.fillText(text, left, bottom, itemWidth);
424
- left += itemWidth;
425
- }
426
-
427
- this.GetFormatTitle=function(data)
428
- {
429
- if (!data || !data.Data) return null;
430
-
431
- var aryText=[];
432
- var item=data.Data;
433
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);//价格小数位数
434
-
435
- if (this.IsShowName) //名称
436
- aryText.push({Text:this.Name, Color:this.NameColor, LeftSpace:this.NameSpace});
437
-
438
- if (this.IsShowSettingInfo) //周期 复权信息
439
- {
440
- var periodName = this.GetPeriodName(this.Data.Period);
441
- var rightName = this.GetRightName(this.Data.Right,this.Data.Period);
442
- var text = "(" + periodName + ")";
443
- if (rightName) text = "(" + periodName + " " + rightName + ")";
444
- aryText.push({Text:text, Color:this.SettingColor, LeftSpace:this.PeriodSpace});
445
- }
446
-
447
- var text = IFrameSplitOperator.FormatDateString(item.Date); //日期
448
- if (ChartData.IsDayPeriod(this.Period, true))
449
- {
450
- aryText.push({Text:text, Color:this.DateTimeColor, LeftSpace:this.DateTimeSpace});
451
- }
452
- else if (ChartData.IsMinutePeriod(this.Period, true))
453
- {
454
- if (IFrameSplitOperator.IsNumber(item.Time))
455
- {
456
- var timeText = IFrameSplitOperator.FormatTimeString(item.Time,"HH:MM");
457
- text=`${text} ${timeText}`;
458
- }
459
-
460
- aryText.push({Text:text, Color:this.DateTimeColor, LeftSpace:this.DateTimeSpace});
461
- }
462
- else if (ChartData.IsSecondPeriod(this.Period) )
463
- {
464
- if (IFrameSplitOperator.IsNumber(item.Time))
465
- {
466
- var timeText = IFrameSplitOperator.FormatTimeString(item.Time, "HH:MM:SS");
467
- text=`${text} ${timeText}`;
468
- }
469
-
470
- aryText.push({Text:text, Color:this.DateTimeColor, LeftSpace:this.DateTimeSpace});
471
- }
472
-
473
- //开
474
- if (IFrameSplitOperator.IsNumber(item.Open))
475
- {
476
- var color = this.GetColor(item.Open, item.YClose);
477
- var text = g_JSChartLocalization.GetText('KTitle-Open', this.LanguageID) + item.Open.toFixed(defaultfloatPrecision);
478
- aryText.push({Text:text, Color:color});
479
- }
480
-
481
- //高
482
- if (IFrameSplitOperator.IsNumber(item.High))
483
- {
484
- var color = this.GetColor(item.High, item.YClose);
485
- var text = g_JSChartLocalization.GetText('KTitle-High', this.LanguageID) + item.High.toFixed(defaultfloatPrecision);
486
- aryText.push({Text:text, Color:color});
487
- }
488
-
489
- //低
490
- if (IFrameSplitOperator.IsNumber(item.Low))
491
- {
492
- var color = this.GetColor(item.Low, item.YClose);
493
- var text = g_JSChartLocalization.GetText('KTitle-Low', this.LanguageID) + item.Low.toFixed(defaultfloatPrecision);
494
- aryText.push({Text:text, Color:color});
495
- }
496
-
497
- //收
498
- if (IFrameSplitOperator.IsNumber(item.Close))
499
- {
500
- var color = this.GetColor(item.Close, item.YClose);
501
- var text = g_JSChartLocalization.GetText('KTitle-Close', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
502
- aryText.push({Text:text, Color:color});
503
- }
504
-
505
- if (IFrameSplitOperator.IsNumber(item.Vol))
506
- {
507
- var text = g_JSChartLocalization.GetText('KTitle-Vol', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Vol, 2, this.LanguageID);
508
- aryText.push({Text:text, Color:this.VolColor});
509
- }
510
-
511
- if (IFrameSplitOperator.IsNumber(item.Amount))
512
- {
513
- var text = g_JSChartLocalization.GetText('KTitle-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
514
- aryText.push({Text:text, Color:this.AmountColor});
515
- }
516
-
517
- if (MARKET_SUFFIX_NAME.IsChinaFutures(this.UpperSymbol) && IFrameSplitOperator.IsNumber(item.Position))
518
- {
519
- var text = g_JSChartLocalization.GetText('KTitle-Position', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Position, 2, this.LanguageID);
520
- aryText.push({Text:text, Color:this.PositionColor});
521
- }
522
-
523
- return { AryText:aryText };
524
- }
525
-
526
- this.DrawSingleLine = function (item,bDrawTitle) //画单行
527
- {
528
- var isHScreen = this.Frame.IsHScreen === true;
529
- var left = this.Frame.ChartBorder.GetLeft();
530
- //var bottom=this.Frame.ChartBorder.GetTop()-this.Frame.ChartBorder.Top/2;
531
- var bottom = this.Frame.ChartBorder.GetTop();
532
- var right = this.Frame.ChartBorder.GetRight();
533
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);//价格小数位数
534
-
535
- if (isHScreen)
536
- {
537
- right = this.Frame.ChartBorder.GetHeight();
538
- if (this.Frame.ChartBorder.Right < 5) return;
539
- left = 2;
540
- bottom = -2;
541
- var xText = this.Frame.ChartBorder.GetRight();
542
- var yText = this.Frame.ChartBorder.GetTop();
543
- this.Canvas.translate(xText, yText);
544
- this.Canvas.rotate(90 * Math.PI / 180);
545
- }
546
- else
547
- {
548
- if (bottom < 5) return;
549
- }
550
-
551
- this.Canvas.textAlign = "left";
552
- this.Canvas.textBaseline = "bottom";
553
- this.Canvas.font = this.Font;
554
-
555
- var position = { Left: left, Bottom: bottom, IsHScreen: isHScreen };
556
- var titleData=this.GetFormatTitle({ Data:item });
557
-
558
- if (titleData && IFrameSplitOperator.IsNonEmptyArray(titleData.AryText))
559
- {
560
- for(var i=0;i<titleData.AryText.length;++i)
561
- {
562
- var item=titleData.AryText[i];
563
- if (!this.DrawKLineText(item.Text, item.Color, position, bDrawTitle==true)) break;
564
- if (IFrameSplitOperator.IsNumber(item.LeftSpace)) position.Left+=item.LeftSpace;
565
- }
566
- }
567
-
568
- /*
569
- if (this.IsShowName) //名称
570
- {
571
- if (!this.DrawKLineText(this.Name, this.NameColor, position, bDrawTitle==true)) return;
572
- position.Left+=this.NameSpace;
573
- }
574
-
575
- if (this.IsShowSettingInfo) //周期 复权信息
576
- {
577
- var periodName = this.GetPeriodName(this.Data.Period);
578
- var rightName = this.GetRightName(this.Data.Right,this.Data.Period);
579
- var text = "(" + periodName + ")";
580
- if (rightName) text = "(" + periodName + " " + rightName + ")";
581
- if (!this.DrawKLineText(text, this.SettingColor, position, bDrawTitle==true)) return;
582
- position.Left+=this.PeriodSpace;
583
- }
584
-
585
- var text = IFrameSplitOperator.FormatDateString(item.Date); //日期
586
- if (ChartData.IsDayPeriod(this.Period, true))
587
- {
588
- if (!this.DrawKLineText(text, this.DateTimeColor, position)) return;
589
- position.Left+=this.DateTimeSpace;
590
- }
591
- else if (ChartData.IsMinutePeriod(this.Period, true))
592
- {
593
- if (IFrameSplitOperator.IsNumber(item.Time))
594
- {
595
- var timeText = IFrameSplitOperator.FormatTimeString(item.Time,"HH:MM");
596
- text=`${text} ${timeText}`;
597
- }
598
-
599
- if (!this.DrawKLineText(text, this.DateTimeColor, position)) return;
600
- position.Left+=this.DateTimeSpace;
601
- }
602
- else if (ChartData.IsSecondPeriod(this.Period) )
603
- {
604
- if (IFrameSplitOperator.IsNumber(item.Time))
605
- {
606
- var timeText = IFrameSplitOperator.FormatTimeString(item.Time, "HH:MM:SS");
607
- text=`${text} ${timeText}`;
608
- }
609
-
610
- if (!this.DrawKLineText(text, this.DateTimeColor, position)) return;
611
- position.Left+=this.DateTimeSpace;
612
- }
613
-
614
- var color = this.GetColor(item.Open, item.YClose);
615
- var text = g_JSChartLocalization.GetText('KTitle-Open', this.LanguageID) + item.Open.toFixed(defaultfloatPrecision);
616
- if (!this.DrawKLineText(text, color, position)) return;
617
-
618
- var color = this.GetColor(item.High, item.YClose);
619
- var text = g_JSChartLocalization.GetText('KTitle-High', this.LanguageID) + item.High.toFixed(defaultfloatPrecision);
620
- if (!this.DrawKLineText(text, color, position)) return;
621
-
622
- var color = this.GetColor(item.Low, item.YClose);
623
- var text = g_JSChartLocalization.GetText('KTitle-Low', this.LanguageID) + item.Low.toFixed(defaultfloatPrecision);
624
- if (!this.DrawKLineText(text, color, position)) return;
625
-
626
- var color = this.GetColor(item.Close, item.YClose);
627
- var text = g_JSChartLocalization.GetText('KTitle-Close', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
628
- if (!this.DrawKLineText(text, color, position)) return;
629
-
630
- if (IFrameSplitOperator.IsNumber(item.Vol))
631
- {
632
- var text = g_JSChartLocalization.GetText('KTitle-Vol', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Vol, 2, this.LanguageID);
633
- if (!this.DrawKLineText(text, this.VolColor, position)) return;
634
- }
635
-
636
- if (IFrameSplitOperator.IsNumber(item.Amount))
637
- {
638
- var text = g_JSChartLocalization.GetText('KTitle-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
639
- if (!this.DrawKLineText(text, this.AmountColor, position)) return;
640
- }
641
-
642
- if (MARKET_SUFFIX_NAME.IsChinaFutures(this.UpperSymbol) && IFrameSplitOperator.IsNumber(item.Position))
643
- {
644
- var text = g_JSChartLocalization.GetText('KTitle-Position', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Position, 2, this.LanguageID);
645
- if (!this.DrawKLineText(text, this.PositionColor, position)) return;
646
- }
647
- */
648
- }
649
-
650
- this.OnDrawEventCallback = function (drawData, explain)
651
- {
652
- if (!this.OnDrawEvent || !this.OnDrawEvent.Callback) return;
653
- var data = { Draw: drawData, Name: this.ClassName, Explain: explain };
654
- if (this.Data && this.Data.Data)
655
- {
656
- if (IFrameSplitOperator.IsNumber(this.CursorIndex))
657
- {
658
- var index = this.CursorIndex;
659
- index = parseInt(index.toFixed(0));
660
- var dataIndex = this.Data.DataOffset + index;
661
- }
662
- else
663
- {
664
- dataIndex=this.Data.Data.length-1;
665
- }
666
-
667
- var dataCount=this.Data.Data.length;
668
- data.DataIndex=dataIndex;
669
- data.DataCount=dataCount;
670
- }
671
- this.OnDrawEvent.Callback(this.OnDrawEvent, data, this);
672
- }
673
-
674
- this.Draw = function ()
675
- {
676
- this.UpperSymbol = this.Symbol ? this.Symbol.toUpperCase() : '';
677
- this.SendUpdateUIMessage('Draw');
678
-
679
- if (!this.IsShow) return;
680
- if (this.CursorIndex == null || !this.Data || this.Data.length <= 0)
681
- {
682
- this.OnDrawEventCallback(null, 'DynamicKLineTitlePainting::Draw');
683
- return;
684
- }
685
-
686
- this.SpaceWidth = this.Canvas.measureText(' ').width;
687
- var index = this.CursorIndex;
688
- index = parseInt(index.toFixed(0));
689
- var dataIndex = this.Data.DataOffset + index;
690
- if (dataIndex >= this.Data.Data.length) dataIndex = this.Data.Data.length - 1;
691
- if (dataIndex < 0)
692
- {
693
- this.OnDrawEventCallback(null, 'DynamicKLineTitlePainting::Draw');
694
- return;
695
- }
696
-
697
- var item = this.Data.Data[dataIndex];
698
- this.OnDrawEventCallback(item, 'DynamicKLineTitlePainting::Draw');
699
-
700
- if (this.Frame.IsHScreen === true)
701
- {
702
- this.Canvas.save();
703
- if (this.LineCount > 1) this.DrawMulitLine(item);
704
- else this.DrawSingleLine(item);
705
- this.Canvas.restore();
706
- if (!item.Time && item.Date && this.InfoData) this.HSCreenKLineInfoDraw(item.Date);
707
- }
708
- else
709
- {
710
- if (this.LineCount > 1) this.DrawMulitLine(item);
711
- else this.DrawSingleLine(item);
712
-
713
- if (!item.Time && item.Date && this.InfoData) this.KLineInfoDraw(item.Date);
714
- }
715
- }
716
-
717
-
718
- this.KLineInfoDraw = function (date) {
719
- var info = this.InfoData.get(date.toString());
720
- if (!info) return;
721
- var invesotrCount = 0; //互动易统计
722
- var researchCouunt = 0;
723
- var reportCount = 0;
724
- var blockTradeCount = 0; //大宗交易次数
725
- var tradeDetailCount = 0; //龙虎榜上榜次数
726
- var policyData = null;
727
- var reportTitle = null, pforecastTitle = null;
728
- //console.log(info);
729
- for (var i in info.Data) {
730
- var item = info.Data[i];
731
- switch (item.InfoType) {
732
- case KLINE_INFO_TYPE.INVESTOR:
733
- ++invesotrCount;
734
- break;
735
- case KLINE_INFO_TYPE.PFORECAST:
736
- pforecastTitle = item.Title;
737
- break;
738
- case KLINE_INFO_TYPE.ANNOUNCEMENT:
739
- ++reportCount;
740
- break;
741
- case KLINE_INFO_TYPE.ANNOUNCEMENT_QUARTER_1:
742
- case KLINE_INFO_TYPE.ANNOUNCEMENT_QUARTER_2:
743
- case KLINE_INFO_TYPE.ANNOUNCEMENT_QUARTER_3:
744
- case KLINE_INFO_TYPE.ANNOUNCEMENT_QUARTER_4:
745
- reportTitle = item.Title;
746
- break;
747
- case KLINE_INFO_TYPE.RESEARCH:
748
- ++researchCouunt;
749
- break;
750
- case KLINE_INFO_TYPE.BLOCKTRADING:
751
- ++blockTradeCount;
752
- break;
753
- case KLINE_INFO_TYPE.TRADEDETAIL:
754
- ++tradeDetailCount;
755
- break;
756
- case KLINE_INFO_TYPE.POLICY:
757
- policyData = item;
758
- break;
759
- }
760
- }
761
-
762
- var isHScreen = (this.Frame.IsHScreen === true);
763
- var right = this.Frame.ChartBorder.GetRight() - 4;
764
- var top = this.Frame.ChartBorder.GetTopEx();
765
- if (isHScreen) {
766
- right = this.Frame.ChartBorder.GetBottom() - 4;
767
- top = this.Frame.ChartBorder.GetRightEx();
768
- this.Canvas.translate(top, right);
769
- this.Canvas.rotate(90 * Math.PI / 180);
770
- right = 0; top = 0;
771
- }
772
-
773
- this.Canvas.font = this.Font;
774
-
775
- var aryTitle = [];
776
- var position = { Top: top, Right: right, IsHScreen: isHScreen };
777
-
778
- aryTitle.push(IFrameSplitOperator.FormatDateString(date));
779
- if (reportTitle) aryTitle.push(reportTitle); //季报
780
- if (pforecastTitle) aryTitle.push(pforecastTitle); //业绩预告
781
- if (reportCount > 0) aryTitle.push('公告数量:' + reportCount);
782
- if (researchCouunt > 0) aryTitle.push('机构调研次数:' + researchCouunt);
783
- if (tradeDetailCount > 0) aryTitle.push('龙虎榜上榜次数:' + tradeDetailCount);
784
- if (invesotrCount > 0) aryTitle.push('互动易数量:' + invesotrCount);
785
- if (blockTradeCount > 0) aryTitle.push('大宗交易次数:' + blockTradeCount);
786
- if (policyData) //策略选股
787
- {
788
- for (let i in policyData.ExtendData) //显示满足的策略
789
- {
790
- aryTitle.push(policyData.ExtendData[i].Name);
791
- }
792
- }
793
-
794
- var maxWidth = 0, textBGHeight = 0;
795
- for (let i in aryTitle) {
796
- var item = aryTitle[i];
797
- var textWidth = this.Canvas.measureText(item).width + 2; //后空2个像素
798
- if (maxWidth < textWidth) maxWidth = textWidth;
799
- textBGHeight += this.InfoTextHeight;
800
- }
801
-
802
- this.Canvas.fillStyle = this.InfoTextBGColor;
803
- if (isHScreen) this.Canvas.fillRect(position.Right - maxWidth, position.Top, maxWidth + 2, textBGHeight + 2);
804
- else this.Canvas.fillRect(position.Right - maxWidth, position.Top, maxWidth + 2, textBGHeight + 2);
805
-
806
- for (let i in aryTitle) {
807
- var item = aryTitle[i];
808
- this.DrawInfoText(item, position);
809
- }
810
- }
811
-
812
- this.HSCreenKLineInfoDraw = function (date) {
813
- this.Canvas.save();
814
- this.KLineInfoDraw(date);
815
- this.Canvas.restore();
816
- }
817
-
818
- this.GetColor = function (price, yclse) {
819
- if (price > yclse) return this.UpColor;
820
- else if (price < yclse) return this.DownColor;
821
- else return this.UnchagneColor;
822
- }
823
-
824
- this.DrawInfoText = function (title, position) {
825
- if (!title) return true;
826
-
827
- this.Canvas.textAlign = "right";
828
- this.Canvas.textBaseline = "top";
829
- this.Canvas.fillStyle = this.InfoTextColor;
830
- this.Canvas.fillText(title, position.Right, position.Top);
831
- position.Top += this.InfoTextHeight;
832
- return true;
833
- }
834
-
835
- this.DrawKLineText = function (title, color, position, isShow)
836
- {
837
- if (!title) return true;
838
-
839
- var isHScreen = this.Frame.IsHScreen === true;
840
- var right = this.Frame.ChartBorder.GetRight();
841
- if (isHScreen) right = this.Frame.ChartBorder.GetHeight();
842
-
843
- this.Canvas.fillStyle = color;
844
- var textWidth = this.Canvas.measureText(title).width;
845
- if (position.Left + textWidth > right) return false;
846
- if (!(isShow === false)) this.Canvas.fillText(title, position.Left, position.Bottom, textWidth);
847
-
848
- position.Left += textWidth + this.SpaceWidth;
849
- return true;
850
- }
851
-
852
- }
853
-
854
- //分时图标题
855
- function DynamicMinuteTitlePainting()
856
- {
857
- this.newMethod = DynamicKLineTitlePainting; //派生
858
- this.newMethod();
859
- delete this.newMethod;
860
-
861
- this.YClose;
862
- this.IsShowDate = false; //标题是否显示日期
863
- this.IsShowName = true; //标题是否显示股票名字
864
- this.Symbol;
865
- this.UpperSymbol;
866
- this.LastShowData; //保存最后显示的数据 给tooltip用
867
- this.ClassName ='DynamicMinuteTitlePainting';
868
- this.SpaceWidth = 2;
869
- this.IsShowAveragePrice=true; //是否显示均线价格
870
-
871
- this.GetCurrentKLineData = function () //获取当天鼠标位置所在的K线数据
872
- {
873
- if (this.LastShowData) return this.LastShowData;
874
- if (this.CursorIndex == null || !this.Data) return null;
875
- if (this.Data.length <= 0) return null;
876
-
877
- var index = Math.abs(this.CursorIndex);
878
- index = parseInt(index.toFixed(0));
879
- var dataIndex = this.Data.DataOffset + index;
880
- if (dataIndex >= this.Data.Data.length) dataIndex = this.Data.Data.length - 1;
881
- if (dataIndex < 0) return null;
882
-
883
- var item = this.Data.Data[dataIndex];
884
- return item;
885
- }
886
-
887
- this.SendUpdateUIMessage = function (funcName) //通知外面 标题变了
888
- {
889
- if (!this.UpdateUICallback) return;
890
-
891
- var sendData =
892
- {
893
- TitleName: '分钟标题', CallFunction: funcName, Stock: { Name: this.Name, Symbol: this.Symbol, },
894
- Rect:
895
- {
896
- Left: this.Frame.ChartBorder.GetLeft(), Right: this.Frame.ChartBorder.GetRight(),
897
- Top: 0, Bottom: this.Frame.ChartBorder.GetTop(),
898
- }
899
- };
900
-
901
- //有数据
902
- if (this.Data && this.Data.Data && this.Data.Data.length > 0) {
903
- let index = this.Data.Data.length - 1; //默认最后1分钟的数据
904
- if (this.CursorIndex) {
905
- let cursorIndex = Math.abs(this.CursorIndex - 0.5);
906
- cursorIndex = parseInt(cursorIndex.toFixed(0));
907
- index = this.Data.DataOffset + cursorIndex;
908
- if (index >= this.Data.Data.length) index = this.Data.Data.length - 1;
909
- }
910
-
911
- if (index >= 0) {
912
- let item = this.Data.Data[index];
913
- this.LastShowData = item;
914
- sendData.Stock.Data =
915
- {
916
- Time: item.Time, Close: item.Close, AvPrice: item.AvPrice,
917
- Vol: item.Vol, Amount: item.Amount
918
- }
919
- if (item.Time) sendData.Stock.Time = item.Time; //分钟K线才有时间
920
- }
921
- }
922
- this.UpdateUICallback(sendData);
923
- }
924
-
925
- this.DrawTitle = function ()
926
- {
927
- this.UpperSymbol = this.Symbol ? this.Symbol.toUpperCase() : '';
928
- this.SendUpdateUIMessage('DrawTitle');
929
- this.OnDrawEventCallback(null, "DynamicMinuteTitlePainting::DrawTitle");
930
- }
931
-
932
- this.GetDecimal = function (symbol)
933
- {
934
- return JSCommonCoordinateData.GetfloatPrecision(symbol);//价格小数位数
935
- }
936
-
937
- this.DrawMulitLine = function (item) //画多行
938
- {
939
- var leftSpace = 5;
940
- var bottomSpace = 2;
941
- var left = this.Frame.ChartBorder.GetLeft() + leftSpace;;
942
- var right = this.Frame.ChartBorder.GetRight();
943
- var width = this.Frame.ChartBorder.GetWidth();
944
- var height = this.Frame.ChartBorder.GetTop();
945
-
946
- var defaultfloatPrecision = this.GetDecimal(this.Symbol); //价格小数位数
947
- var itemHeight = (height - bottomSpace) / this.LineCount;
948
- var bottom = itemHeight;
949
-
950
- this.Canvas.textAlign = "left";
951
- this.Canvas.textBaseline = "bottom";
952
- this.Canvas.font = this.Font;
953
- this.Canvas.fillStyle = this.UnchagneColor;
954
-
955
- this.Canvas.fillStyle = this.UnchagneColor;
956
- var text = IFrameSplitOperator.FormatDateTimeString(item.DateTime, this.IsShowDate ? 'YYYY-MM-DD' : 'HH-MM');
957
- var timeWidth = this.Canvas.measureText(text).width + 5; //后空5个像素
958
- this.Canvas.fillText(text, left, bottom, timeWidth);
959
-
960
- if (this.IsShowDate) {
961
- var text = IFrameSplitOperator.FormatDateTimeString(item.DateTime, 'HH-MM');
962
- this.Canvas.fillText(text, left, bottom + itemHeight, timeWidth);
963
- }
964
-
965
- var itemWidth = (width - leftSpace - timeWidth) / 2;
966
- left += timeWidth;
967
-
968
- if (item.Close != null) {
969
- this.Canvas.fillStyle = this.GetColor(item.Close, this.YClose);
970
- var text = g_JSChartLocalization.GetText('Tooltip-Price', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
971
- this.Canvas.fillText(text, left, bottom, itemWidth);
972
- left += itemWidth;
973
- }
974
-
975
- if (item.Increase != null) {
976
- this.Canvas.fillStyle = this.GetColor(item.Increase, 0);
977
- var text = g_JSChartLocalization.GetText('Tooltip-Increase', this.LanguageID) + item.Increase.toFixed(2) + '%';
978
- this.Canvas.fillText(text, left, bottom, itemWidth);
979
- left += itemWidth;
980
- }
981
-
982
- bottom += itemHeight; //换行
983
- var left = this.Frame.ChartBorder.GetLeft() + leftSpace + timeWidth;
984
-
985
- this.Canvas.fillStyle = this.VolColor;
986
- var text = g_JSChartLocalization.GetText('Tooltip-Vol', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Vol, 2, this.LanguageID);
987
- this.Canvas.fillText(text, left, bottom, itemWidth);
988
- left += itemWidth;
989
-
990
- this.Canvas.fillStyle = this.AmountColor;
991
- var text = g_JSChartLocalization.GetText('Tooltip-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
992
- this.Canvas.fillText(text, left, bottom, itemWidth);
993
- left += itemWidth;
994
- }
995
-
996
- this.GetFormatTitle=function(data)
997
- {
998
- if (!data || !data.Data) return null;
999
-
1000
- var item=data.Data;
1001
- var defaultfloatPrecision = this.GetDecimal(this.Symbol); //价格小数位数
1002
- var upperSymbol=this.Symbol.toUpperCase();
1003
- var isFutures=MARKET_SUFFIX_NAME.IsFutures(upperSymbol); //期货
1004
- var aryText=[];
1005
- var yClose=item.YClose;
1006
- if (isFutures && IFrameSplitOperator.IsNumber(item.YClearing)) yClose=item.YClearing;
1007
- if (this.IsShowName) aryText.push({ Text:this.Name, Color:this.NameColor });
1008
-
1009
- var text = IFrameSplitOperator.FormatDateTimeString(item.DateTime, this.IsShowDate ? 'YYYY-MM-DD HH-MM' : 'HH-MM');
1010
- aryText.push({ Text:text, Color:this.DateTimeColor });
1011
-
1012
- if (IFrameSplitOperator.IsNumber(item.Close))
1013
- {
1014
- var color = this.GetColor(item.Close, yClose);
1015
- var text = g_JSChartLocalization.GetText('MTitle-Close', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
1016
- aryText.push({ Text:text, Color:color });
1017
- }
1018
-
1019
- if (IFrameSplitOperator.IsNumber(item.Increase))
1020
- {
1021
- var color = this.GetColor(item.Increase, 0);
1022
- var text = g_JSChartLocalization.GetText('MTitle-Increase', this.LanguageID) + item.Increase.toFixed(2) + '%';
1023
- aryText.push({ Text:text, Color:color });
1024
- }
1025
-
1026
- if (IFrameSplitOperator.IsNumber(item.AvPrice) && this.IsShowAveragePrice==true)
1027
- {
1028
- var color = this.GetColor(item.AvPrice, yClose);
1029
- var text = g_JSChartLocalization.GetText('MTitle-AvPrice', this.LanguageID) + item.AvPrice.toFixed(defaultfloatPrecision);
1030
- aryText.push({ Text:text, Color:color });
1031
- }
1032
-
1033
- if (IFrameSplitOperator.IsNumber(item.Vol))
1034
- {
1035
- var text = g_JSChartLocalization.GetText('MTitle-Vol', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Vol, 2, this.LanguageID);
1036
- aryText.push({ Text:text, Color:this.VolColor });
1037
- }
1038
-
1039
- if (IFrameSplitOperator.IsNumber(item.Amount))
1040
- {
1041
- var text = g_JSChartLocalization.GetText('MTitle-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
1042
- aryText.push({ Text:text, Color:this.AmountColor });
1043
- }
1044
-
1045
- if (MARKET_SUFFIX_NAME.IsChinaFutures(this.UpperSymbol) && IFrameSplitOperator.IsNumber(item.Position))
1046
- {
1047
- var text = g_JSChartLocalization.GetText('MTitle-Position', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Position, 2, this.LanguageID);
1048
- aryText.push({ Text:text, Color:this.VolColor });
1049
- }
1050
-
1051
- return { AryText:aryText };
1052
- }
1053
-
1054
- this.DrawItem = function (item)
1055
- {
1056
- var isHScreen = this.Frame.IsHScreen === true;
1057
- var left = this.Frame.ChartBorder.GetLeft();;
1058
- var bottom = this.Frame.ChartBorder.GetTop() - this.Frame.ChartBorder.Top / 2;
1059
- var right = this.Frame.ChartBorder.GetRight();
1060
- var defaultfloatPrecision = this.GetDecimal(this.Symbol); //价格小数位数
1061
-
1062
- if (isHScreen)
1063
- {
1064
- if (this.Frame.ChartBorder.Right < 5) return;
1065
- var left = 2;
1066
- var bottom = this.Frame.ChartBorder.Right / 2; //上下居中显示
1067
- var right = this.Frame.ChartBorder.GetHeight();
1068
- var xText = this.Frame.ChartBorder.GetChartWidth();
1069
- var yText = this.Frame.ChartBorder.GetTop();
1070
- this.Canvas.translate(xText, yText);
1071
- this.Canvas.rotate(90 * Math.PI / 180);
1072
- }
1073
- else
1074
- {
1075
- if (bottom < 5) return;
1076
- }
1077
-
1078
- this.Canvas.textAlign = "left";
1079
- this.Canvas.textBaseline = "middle";
1080
- this.Canvas.font = this.Font;
1081
- var position = { Left: left, Bottom: bottom, IsHScreen: isHScreen };
1082
- var titleData=this.GetFormatTitle({ Data:item });
1083
-
1084
- if (titleData && IFrameSplitOperator.IsNonEmptyArray(titleData.AryText))
1085
- {
1086
- for(var i=0;i<titleData.AryText.length;++i)
1087
- {
1088
- var item=titleData.AryText[i];
1089
- if (!this.DrawMinuteText(item.Text, item.Color, position, true)) break;
1090
- if (IFrameSplitOperator.IsNumber(item.LeftSpace)) position.Left+=item.LeftSpace;
1091
- }
1092
- }
1093
-
1094
- /*
1095
- if (this.IsShowName)
1096
- {
1097
- if (!this.DrawMinuteText(this.Name, this.NameColor, position, true)) return;
1098
- }
1099
-
1100
- this.Canvas.fillStyle = this.UnchagneColor;
1101
- var text = IFrameSplitOperator.FormatDateTimeString(item.DateTime, this.IsShowDate ? 'YYYY-MM-DD HH-MM' : 'HH-MM');
1102
- if (!this.DrawMinuteText(text, this.DateTimeColor, position)) return;
1103
-
1104
- if (IFrameSplitOperator.IsNumber(item.Close))
1105
- {
1106
- var color = this.GetColor(item.Close, this.YClose);
1107
- var text = g_JSChartLocalization.GetText('MTitle-Close', this.LanguageID) + item.Close.toFixed(defaultfloatPrecision);
1108
- if (!this.DrawMinuteText(text, color, position)) return;
1109
- }
1110
-
1111
- if (IFrameSplitOperator.IsNumber(item.Increase))
1112
- {
1113
- var color = this.GetColor(item.Increase, 0);
1114
- var text = g_JSChartLocalization.GetText('MTitle-Increase', this.LanguageID) + item.Increase.toFixed(2) + '%';
1115
- if (!this.DrawMinuteText(text, color, position)) return;
1116
- }
1117
-
1118
- if (IFrameSplitOperator.IsNumber(item.AvPrice) && this.IsShowAveragePrice==true)
1119
- {
1120
- var color = this.GetColor(item.AvPrice, this.YClose);
1121
- var text = g_JSChartLocalization.GetText('MTitle-AvPrice', this.LanguageID) + item.AvPrice.toFixed(defaultfloatPrecision);
1122
- if (!this.DrawMinuteText(text, color, position)) return;
1123
- }
1124
-
1125
- if (IFrameSplitOperator.IsNumber(item.Vol))
1126
- {
1127
- var text = g_JSChartLocalization.GetText('MTitle-Vol', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Vol, 2, this.LanguageID);
1128
- if (!this.DrawMinuteText(text, this.VolColor, position)) return;
1129
- }
1130
-
1131
- if (IFrameSplitOperator.IsNumber(item.Amount))
1132
- {
1133
- var text = g_JSChartLocalization.GetText('MTitle-Amount', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Amount, 2, this.LanguageID);
1134
- if (!this.DrawMinuteText(text, this.AmountColor, position)) return;
1135
- }
1136
-
1137
- if (MARKET_SUFFIX_NAME.IsChinaFutures(this.UpperSymbol) && IFrameSplitOperator.IsNumber(item.Position))
1138
- {
1139
- var text = g_JSChartLocalization.GetText('MTitle-Position', this.LanguageID) + IFrameSplitOperator.FormatValueString(item.Position, 2, this.LanguageID);
1140
- if (!this.DrawMinuteText(text, this.VolColor, position)) return;
1141
- }
1142
- */
1143
- }
1144
-
1145
- this.FullDraw=function()
1146
- {
1147
- this.Draw();
1148
- }
1149
-
1150
- this.Draw = function ()
1151
- {
1152
- this.UpperSymbol = this.Symbol ? this.Symbol.toUpperCase() : '';
1153
- this.LastShowData = null;
1154
- this.SendUpdateUIMessage('Draw');
1155
- if (!this.IsShow) return;
1156
- if (this.CursorIndex == null || !this.Data || !this.Data.Data || this.Data.Data.length <= 0)
1157
- {
1158
- this.OnDrawEventCallback(null,"DynamicMinuteTitlePainting::Draw");
1159
- return;
1160
- }
1161
-
1162
- if (this.TextSpace>=0)
1163
- {
1164
- this.SpaceWidth=this.TextSpace;
1165
- }
1166
- else
1167
- {
1168
- this.Canvas.font = this.Font;
1169
- this.SpaceWidth = this.Canvas.measureText(' ').width;
1170
- }
1171
-
1172
- var index = this.CursorIndex;
1173
- index = parseInt(index.toFixed(0));
1174
- var dataIndex = index + this.Data.DataOffset;
1175
- if (dataIndex >= this.Data.Data.length) dataIndex = this.Data.Data.length - 1;
1176
-
1177
- var item = this.Data.Data[dataIndex];
1178
- this.LastShowData = item;
1179
- this.OnDrawEventCallback(item, "DynamicMinuteTitlePainting::Draw");
1180
-
1181
- if (this.LineCount > 1 && !(this.Frame.IsHScreen === true))
1182
- {
1183
- this.DrawMulitLine(item);
1184
- return;
1185
- }
1186
-
1187
- this.Canvas.save();
1188
- this.DrawItem(item);
1189
- this.Canvas.restore();
1190
- }
1191
-
1192
- this.DrawMinuteText = function (title, color, position, isShow)
1193
- {
1194
- if (!title) return true;
1195
-
1196
- var isHScreen = this.Frame.IsHScreen === true;
1197
- var right = this.Frame.ChartBorder.GetRight();
1198
- if (isHScreen) right = this.Frame.ChartBorder.GetHeight();
1199
-
1200
- this.Canvas.fillStyle = color;
1201
- var textWidth = this.Canvas.measureText(title).width;
1202
- if (position.Left + textWidth > right) return false;
1203
- if (!(isShow === false)) this.Canvas.fillText(title, position.Left, position.Bottom, textWidth);
1204
-
1205
- position.Left += textWidth + this.SpaceWidth;
1206
- return true;
1207
- }
1208
- }
1209
-
1210
- //字符串输出格式
1211
- var STRING_FORMAT_TYPE =
1212
- {
1213
- DEFAULT: 1, //默认 2位小数 单位自动转化 (万 亿)
1214
- ORIGINAL: 2, //原始数据
1215
- THOUSANDS: 21, //千分位分割
1216
- };
1217
-
1218
- function DynamicTitleData(data, name, color) //指标标题数据
1219
- {
1220
- this.Data = data;
1221
- this.Name = name;
1222
- this.Color = color; //字体颜色
1223
- this.DataType; //数据类型
1224
- this.ChartClassName;
1225
- this.StringFormat = STRING_FORMAT_TYPE.DEFAULT; //字符串格式
1226
- this.FloatPrecision = 2; //小数位数
1227
- this.GetTextCallback; //自定义数据转文本回调
1228
- this.IsShow=true;
1229
- }
1230
-
1231
- //指标标题
1232
- function DynamicChartTitlePainting()
1233
- {
1234
- this.newMethod = IChartTitlePainting; //派生
1235
- this.newMethod();
1236
- delete this.newMethod;
1237
-
1238
- this.IsDynamic = true;
1239
- this.Data = new Array();
1240
- this.Explain;
1241
- this.TitleBG; //标题背景色
1242
- this.TitleBGHeight = 20; //标题背景色高度
1243
- this.TitleAlign = 'middle';//对其方式
1244
- this.TitleBottomDistance = 1; //标题靠底部输出的时候 字体和底部的间距
1245
- this.Text = new Array(); //副标题 Text:'文本', Color:'颜色'
1246
- this.EraseRect;
1247
- this.EraseColor = g_JSChartResource.BGColor; //用来擦出的背景色
1248
-
1249
- this.TitleRect; //指标名字显示区域
1250
- this.IsDrawTitleBG=false; //是否绘制指标名字背景色
1251
- this.BGColor=g_JSChartResource.IndexTitleBGColor; //指标名字背景颜色
1252
- this.BGBorderColor=g_JSChartResource.IndexTitleBorderColor;
1253
- this.TitleColor = g_JSChartResource.IndexTitleColor; //指标名字颜色
1254
- this.ArgumentsText; //参数信息
1255
-
1256
- this.IsShowIndexName = true; //是否显示指标名字
1257
- this.IsShowNameArrow=false;
1258
- this.ParamSpace = 2; //参数显示的间距
1259
- this.TitleSpace=2; //指标名字和参数之间的间距
1260
- this.OutName=null; //动态标题
1261
- this.IsFullDraw=true; //手势离开屏幕以后是否显示最后的价格
1262
-
1263
- this.OverlayIndex=new Map(); //叠加指标 key=Identify value={ Data:数据, Title:标题, Identify:标识}
1264
- this.IsShowOverlayIndexName=true;
1265
- this.OverlayIndexType={ LineSpace:1, BGColor:g_JSChartResource.OverlayIndexTitleBGColor }; //Position 0=主图指标后面显示 1=叠加指标单行显示
1266
-
1267
- this.DynamicTitle={ OutName:null, OutValue:null };
1268
- this.OverlayDynamicTitle=new Map(); //key , value={ OutName, OutValue }
1269
-
1270
- this.SetDynamicTitleData=function(outName, args, data)
1271
- {
1272
- if (!data.OutName) data.OutName=new Map();
1273
- else data.OutName.clear();
1274
-
1275
- if (!data.OutValue) data.OutValue=new Map();
1276
- else data.OutValue.clear();
1277
-
1278
- var mapArgs=new Map();
1279
- for(var i in args)
1280
- {
1281
- var item=args[i];
1282
- mapArgs.set(`{${item.Name}}`, item);
1283
- }
1284
-
1285
- for(var i in outName)
1286
- {
1287
- var item=outName[i];
1288
- if (item.DynamicName)
1289
- {
1290
- var aryFond = item.DynamicName.match(/{\w*}/i);
1291
- if (!aryFond || aryFond.length<=0)
1292
- {
1293
- data.OutName.set(item.Name, item.DynamicName);
1294
- }
1295
- else
1296
- {
1297
- var dyName=item.DynamicName;
1298
- var bFind=true;
1299
- for(var j=0;j<aryFond.length;++j)
1300
- {
1301
- var findItem=aryFond[j];
1302
- if (mapArgs.has(findItem))
1303
- {
1304
- var value=mapArgs.get(findItem).Value;
1305
- dyName=dyName.replace(findItem,value.toString());
1306
- }
1307
- else
1308
- {
1309
- bFind=false;
1310
- break;
1311
- }
1312
- }
1313
-
1314
- if (bFind) data.OutName.set(item.Name, dyName);
1315
- }
1316
-
1317
- }
1318
-
1319
- if (item.DynamicValue)
1320
- {
1321
- data.OutValue.set(item.Name, item.DynamicValue);
1322
- }
1323
- }
1324
- }
1325
-
1326
- this.SetDynamicTitle=function(outName, args, overlayID)
1327
- {
1328
- if (IFrameSplitOperator.IsString(overlayID))
1329
- {
1330
- var dynamicTitle=null;
1331
- if (this.OverlayDynamicTitle.has(overlayID))
1332
- {
1333
- dynamicTitle=this.OverlayDynamicTitle.get(overlayID);
1334
- }
1335
- else
1336
- {
1337
- dynamicTitle={ OutName:null, OutValue:null };
1338
- this.OverlayDynamicTitle.set(overlayID, dynamicTitle);
1339
- }
1340
-
1341
- this.SetDynamicTitleData(outName, args, dynamicTitle);
1342
- }
1343
- else
1344
- {
1345
- this.SetDynamicTitleData(outName, args, this.DynamicTitle);
1346
- }
1347
- }
1348
-
1349
- this.GetDynamicOutName=function(key, overlayID)
1350
- {
1351
- if (IFrameSplitOperator.IsString(overlayID))
1352
- {
1353
- if (!this.OverlayDynamicTitle.has(overlayID)) return null;
1354
- var dynamicTitle=this.OverlayDynamicTitle.get(overlayID);
1355
- var outName=dynamicTitle.OutName;
1356
- }
1357
- else
1358
- {
1359
- var outName=this.DynamicTitle.OutName;
1360
- }
1361
-
1362
- if (!outName || outName.size<=0) return null;
1363
- if (!outName.has(key)) return null;
1364
-
1365
- return outName.get(key);
1366
- }
1367
-
1368
- this.IsClickTitle=function(x,y) //是否点击了指标标题
1369
- {
1370
- if (!this.TitleRect) return false;
1371
-
1372
- if (x>this.TitleRect.Left && x<this.TitleRect.Left+this.TitleRect.Width && y>this.TitleRect.Top && y<this.TitleRect.Top+this.TitleRect.Height)
1373
- {
1374
- return true;
1375
- }
1376
-
1377
- return false;
1378
- }
1379
-
1380
- this.FormatValue = function (value, item)
1381
- {
1382
- if (item.StringFormat == STRING_FORMAT_TYPE.DEFAULT)
1383
- return IFrameSplitOperator.FormatValueString(value, item.FloatPrecision, this.LanguageID);
1384
- else if (item.StringFormat = STRING_FORMAT_TYPE.THOUSANDS)
1385
- return IFrameSplitOperator.FormatValueThousandsString(value, item.FloatPrecision);
1386
- else if (item.StringFormat == STRING_FORMAT_TYPE.ORIGINAL)
1387
- return value.toFixed(item.FloatPrecision).toString();
1388
- }
1389
-
1390
- this.FormatMultiReport = function (data, format)
1391
- {
1392
- var text = "";
1393
- for (var i in data) {
1394
- var item = data[i];
1395
- let quarter = item.Quarter;
1396
- let year = item.Year;
1397
- let value = item.Value;
1398
-
1399
- if (text.length > 0) text += ',';
1400
-
1401
- text += year.toString();
1402
- switch (quarter) {
1403
- case 1:
1404
- text += '一季报 ';
1405
- break;
1406
- case 2:
1407
- text += '半年报 ';
1408
- break;
1409
- case 3:
1410
- text += '三季报 ';
1411
- break;
1412
- case 4:
1413
- text += '年报 ';
1414
- break;
1415
- }
1416
-
1417
- text += this.FormatValue(value, format);
1418
- }
1419
-
1420
- return text;
1421
- }
1422
-
1423
- //多变量输出
1424
- this.FromatStackedBarTitle=function(aryBar, dataInfo)
1425
- {
1426
- if (!IFrameSplitOperator.IsNonEmptyArray(aryBar)) return null;
1427
- if (!IFrameSplitOperator.IsNonEmptyArray(dataInfo.Color)) return null;
1428
-
1429
- var aryText=[];
1430
- for(var i=0;i<aryBar.length;++i)
1431
- {
1432
- var value=aryBar[i];
1433
- if (!IFrameSplitOperator.IsNumber(value)) continue;
1434
-
1435
- var item={ Text:value.toFixed(2) };
1436
- if (dataInfo.Name && dataInfo.Name[i]) item.Name=dataInfo.Name[i];
1437
- item.Color=dataInfo.Color[i];
1438
-
1439
- aryText.push(item);
1440
- }
1441
-
1442
- if (aryText.length<=0) return null;
1443
-
1444
- return aryText;
1445
- }
1446
-
1447
- this.SendUpdateUIMessage = function (funcName) //通知外面 标题变了
1448
- {
1449
- if (!this.UpdateUICallback) return;
1450
-
1451
- var sendData = {
1452
- TitleName: '指标标题', CallFunction: funcName,
1453
- TitleData: { Title: this.Title, Identify: this.Frame.Identify, Data: [] },
1454
- Rect: //标题的位置
1455
- {
1456
- Top: this.Frame.ChartBorder.GetTop(), Left: this.Frame.ChartBorder.GetLeft(),
1457
- Right: this.Frame.ChartBorder.GetRight(), Bottom: this.Frame.ChartBorder.GetBottom()
1458
- }
1459
- };
1460
-
1461
- for (var i in this.Data) {
1462
- var item = this.Data[i];
1463
- if (!item || !item.Data || !item.Data.Data) continue;
1464
- if (item.Data.Data.length <= 0) continue;
1465
-
1466
- var titleItem = { Name: item.Name, Color: item.Color };
1467
- if (item.DataType) titleItem.DataType = item.DataType;
1468
-
1469
- if (item.DataType == "StraightLine") //直线只有1个数据
1470
- {
1471
- titleItem.Value = item.Data.Data[0];
1472
- }
1473
- else {
1474
- var index = item.Data.Data.length - 1;
1475
- if (this.CursorIndex != null) {
1476
- var cursorIndex = Math.abs(this.CursorIndex - 0.5);
1477
- cursorIndex = parseInt(cursorIndex.toFixed(0));
1478
- index = item.Data.DataOffset + cursorIndex
1479
- }
1480
- if (index >= item.Data.Data.length) index = item.Data.Data.length - 1;
1481
-
1482
- titleItem.Value = item.Data.Data[index];
1483
- }
1484
-
1485
- sendData.TitleData.Data.push(titleItem);
1486
- }
1487
-
1488
- //console.log('[DynamicChartTitlePainting::SendUpdateUIMessage', sendData);
1489
- this.UpdateUICallback(sendData);
1490
- }
1491
-
1492
- this.FullDraw=function()
1493
- {
1494
- this.EraseRect = null;
1495
- this.TitleRect=null;
1496
- if (this.Frame.IsMinSize) return;
1497
-
1498
- this.OnDrawTitleEvent();
1499
-
1500
- if (this.Frame.ChartBorder.TitleHeight < 5) return;
1501
- if (this.Frame.IsShowTitle == false) return;
1502
- this.IsDrawTitleBG=this.Frame.IsDrawTitleBG;
1503
- this.IsShowIndexName = this.Frame.IsShowIndexName;
1504
- this.IsShowNameArrow=this.Frame.IsShowNameArrow;
1505
- this.ParamSpace = this.Frame.IndexParamSpace;
1506
- this.TitleSpace=this.Frame.IndexTitleSpace;
1507
-
1508
- if (this.Frame.IsHScreen === true)
1509
- {
1510
- this.Canvas.save();
1511
- this.DrawItem(true,true);
1512
- this.DrawOverlayIndexSingleLine();
1513
- this.Canvas.restore();
1514
-
1515
- /*
1516
- //测试用
1517
- if (this.TitleRect)
1518
- {
1519
- this.Canvas.strokeStyle='rgba(200,0,50,1)';
1520
- this.Canvas.strokeRect(ToFixedPoint(this.TitleRect.Left),ToFixedPoint(this.TitleRect.Top),ToFixedRect(this.TitleRect.Width),ToFixedRect(this.TitleRect.Height));
1521
- }
1522
- */
1523
-
1524
- return;
1525
- }
1526
-
1527
- this.DrawItem(true,true);
1528
- this.DrawOverlayIndexSingleLine();
1529
- }
1530
-
1531
- this.DrawTitle = function ()
1532
- {
1533
- this.IsDrawTitleBG=this.Frame.IsDrawTitleBG;
1534
- this.EraseRect = null;
1535
- this.TitleRect=null;
1536
- this.SendUpdateUIMessage('DrawTitle');
1537
- if (this.Frame.ChartBorder.TitleHeight < 5) return;
1538
- if (this.Frame.IsShowTitle == false) return;
1539
-
1540
- this.IsShowIndexName = this.Frame.IsShowIndexName;
1541
- this.ParamSpace = this.Frame.IndexParamSpace;
1542
-
1543
- if (this.Frame.IsHScreen === true)
1544
- {
1545
- this.Canvas.save();
1546
- this.DrawItem(true,false);
1547
- this.Canvas.restore();
1548
- return;
1549
- }
1550
-
1551
- this.DrawItem(true,false);
1552
- }
1553
-
1554
- this.EraseTitle = function ()
1555
- {
1556
- if (!this.EraseRect) return;
1557
- this.Canvas.fillStyle = this.EraseColor;
1558
- this.Canvas.fillRect(this.EraseRect.Left, this.EraseRect.Top, this.EraseRect.Width, this.EraseRect.Height);
1559
- }
1560
-
1561
- this.Draw = function ()
1562
- {
1563
- this.TitleRect=null;
1564
- this.SendUpdateUIMessage('Draw');
1565
-
1566
- if (this.CursorIndex == null) return;
1567
- if (!this.Data) return;
1568
- if (this.Frame.ChartBorder.TitleHeight < 5) return;
1569
- if (this.Frame.IsShowTitle == false) return;
1570
-
1571
- this.IsShowIndexName = this.Frame.IsShowIndexName;
1572
- this.IsShowNameArrow=this.Frame.IsShowNameArrow;
1573
- this.ParamSpace = this.Frame.IndexParamSpace;
1574
- this.TitleSpace=this.Frame.IndexTitleSpace;
1575
-
1576
- if (this.Frame.IsHScreen === true)
1577
- {
1578
- this.Canvas.save();
1579
- this.DrawItem(false,true);
1580
- this.Canvas.restore();
1581
- return;
1582
- }
1583
-
1584
- this.DrawItem(false,true);
1585
- }
1586
-
1587
- this.GetTitleItem=function(item, isShowLastData)
1588
- {
1589
- if (!item || !item.Data || !item.Data.Data) return null;
1590
- if (item.Data.Data.length <= 0) return null;
1591
- if (item.IsShow==false) return null;
1592
-
1593
- var valueText = null;
1594
- var aryText=null;
1595
-
1596
- var value = null;
1597
- if (item.DataType == "StraightLine") //直线只有1个数据
1598
- {
1599
- value = item.Data.Data[0];
1600
- valueText = this.FormatValue(value, item);
1601
- }
1602
- else
1603
- {
1604
- var index = this.CursorIndex - 0.5;
1605
- if (index<0) index=0;
1606
- index = parseInt(index.toFixed(0));
1607
- if (item.Data.DataOffset + index >= item.Data.Data.length) return null;
1608
-
1609
- value = item.Data.Data[item.Data.DataOffset + index];
1610
- if (value == null) return null;
1611
-
1612
- if (item.DataType == "HistoryData-Vol")
1613
- {
1614
- value = value.Vol;
1615
- valueText = this.FormatValue(value, item);
1616
- }
1617
- else if (item.DataType == "MultiReport")
1618
- {
1619
- valueText = this.FormatMultiReport(value, item);
1620
- }
1621
- else if (item.DataType=="ChartStackedBar")
1622
- {
1623
- aryText=this.FromatStackedBarTitle(value, item);
1624
- if (!aryText) return null;
1625
- }
1626
- else
1627
- {
1628
- if (item.GetTextCallback) valueText = item.GetTextCallback(value, item);
1629
- else valueText = this.FormatValue(value, item);
1630
- }
1631
- }
1632
-
1633
- if (!valueText && !aryText) return null;
1634
-
1635
- return { Text:valueText, ArrayText:aryText };
1636
- }
1637
-
1638
- this.DrawItem=function(bDrawTitle, bDrawValue)
1639
- {
1640
- var isHScreen=(this.Frame.IsHScreen === true);
1641
- var left = this.Frame.ChartBorder.GetLeft() + 1;
1642
- var bottom = this.Frame.ChartBorder.GetTop() + this.Frame.ChartBorder.TitleHeight / 2; //上下居中显示
1643
- if (this.TitleAlign == 'bottom') bottom = this.Frame.ChartBorder.GetTopEx() - this.TitleBottomDistance;
1644
- var right = this.Frame.ChartBorder.GetRight();
1645
- var textWidth;
1646
-
1647
- if (isHScreen)
1648
- {
1649
- let xText = this.Frame.ChartBorder.GetRightTitle();
1650
- let yText = this.Frame.ChartBorder.GetTop();
1651
- this.Canvas.translate(xText, yText);
1652
- this.Canvas.rotate(90 * Math.PI / 180);
1653
- left = 1;
1654
- bottom = -(this.Frame.ChartBorder.TitleHeight / 2); //上下居中显示
1655
- if (this.TitleAlign == 'bottom') bottom = -this.TitleBottomDistance;
1656
- right = this.Frame.ChartBorder.GetHeight();
1657
- }
1658
-
1659
- this.EraseTitle();
1660
-
1661
- this.Canvas.textAlign = "left";
1662
- this.Canvas.textBaseline = this.TitleAlign;
1663
- this.Canvas.font = this.Font;
1664
-
1665
- if (this.TitleBG && this.Title) //指标名称
1666
- {
1667
- textWidth = this.Canvas.measureText(this.Title).width + 2;
1668
- let height = this.Frame.ChartBorder.TitleHeight;
1669
- let top = this.Frame.ChartBorder.GetTop();
1670
- if (height > 20)
1671
- {
1672
- top += (height - 20) / 2 + (height - 45) / 2;
1673
- height = 20;
1674
- }
1675
-
1676
- if (this.TitleAlign == 'bottom') //底部输出文字
1677
- {
1678
- top = this.Frame.ChartBorder.GetTopEx() - 20;
1679
- if (top < 0) top = 0;
1680
- }
1681
- if (bDrawTitle)
1682
- {
1683
- this.Canvas.fillStyle = this.TitleBG;
1684
- this.Canvas.fillRect(left, top, textWidth, height);
1685
- }
1686
- }
1687
-
1688
- if (this.Title && this.IsShowIndexName) //指标参数
1689
- {
1690
- const metrics = this.Canvas.measureText(this.Title);
1691
- textWidth = metrics.width + 2;
1692
- if (bDrawTitle)
1693
- {
1694
- if (this.IsDrawTitleBG) //绘制指标名背景色
1695
- {
1696
- var title=this.Title;
1697
- if (this.IsShowNameArrow) title+='▼';
1698
- var textWidth=this.Canvas.measureText(title).width;
1699
- var bgHeight=this.Canvas.measureText("擎").width+2;
1700
- var bgWidth=textWidth+4;
1701
-
1702
- this.Canvas.fillStyle=this.BGColor;
1703
- if (isHScreen)
1704
- {
1705
- this.TitleRect=
1706
- {
1707
- Top:this.Frame.ChartBorder.GetTop(),
1708
- Left:this.Frame.ChartBorder.GetRightTitle()+this.Frame.ChartBorder.TitleHeight/2-bgHeight/2,
1709
- Width:bgHeight ,Height:bgWidth
1710
- }; //保存下标题的坐标
1711
- let drawRect={Left:left, Top:-bgHeight-2, Width:bgWidth, Height:bgHeight};
1712
- this.Canvas.fillRect(drawRect.Left,drawRect.Top,drawRect.Width,drawRect.Height);
1713
-
1714
- if (this.BGBorderColor)
1715
- {
1716
- this.Canvas.strokeStyle=this.BGBorderColor;
1717
- this.Canvas.strokeRect(ToFixedPoint(drawRect.Left),ToFixedPoint(drawRect.Top),ToFixedRect(drawRect.Width),ToFixedRect(drawRect.Height));
1718
- }
1719
- }
1720
- else
1721
- {
1722
- this.TitleRect={ Left:left, Top:bottom-bgHeight/2-1, Width:bgWidth, Height:bgHeight }; //保存下标题的坐标
1723
- this.Canvas.fillRect(this.TitleRect.Left,this.TitleRect.Top,this.TitleRect.Width,this.TitleRect.Height);
1724
-
1725
- if (this.BGBorderColor)
1726
- {
1727
- this.Canvas.strokeStyle=this.BGBorderColor;
1728
- this.Canvas.strokeRect(ToFixedPoint(this.TitleRect.Left),ToFixedPoint(this.TitleRect.Top),ToFixedRect(this.TitleRect.Width),ToFixedRect(this.TitleRect.Height));
1729
- }
1730
- }
1731
-
1732
- this.Canvas.fillStyle = this.TitleColor;
1733
- this.Canvas.fillText(title, left+1, bottom, textWidth);
1734
-
1735
- textWidth=bgWidth+2;
1736
- }
1737
- else
1738
- {
1739
- this.Canvas.fillStyle = this.TitleColor;
1740
- this.Canvas.fillText(this.Title, left, bottom, textWidth);
1741
- }
1742
- }
1743
- left += textWidth;
1744
- left+=this.TitleSpace;
1745
- }
1746
-
1747
- //指标参数
1748
- if (this.ArgumentsText && this.IsShowIndexName)
1749
- {
1750
- var textWidth=this.Canvas.measureText(this.ArgumentsText).width+2;
1751
- this.Canvas.fillStyle=this.TitleColor;
1752
- this.Canvas.fillText(this.ArgumentsText, left, bottom, textWidth);
1753
-
1754
- left += textWidth;
1755
- left+=this.TitleSpace;
1756
- }
1757
-
1758
- if (this.Text && this.Text.length > 0)
1759
- {
1760
- for (let i in this.Text)
1761
- {
1762
- let item = this.Text[i];
1763
- this.Canvas.fillStyle = item.Color;
1764
- textWidth = this.Canvas.measureText(item.Text).width + 2;
1765
- this.Canvas.fillText(item.Text, left, bottom, textWidth);
1766
- left += textWidth;
1767
- }
1768
- }
1769
-
1770
- if (bDrawValue)
1771
- {
1772
- for (var i in this.Data)
1773
- {
1774
- var item = this.Data[i];
1775
- var outText=this.GetTitleItem(item, false);
1776
- if (!outText) continue;
1777
-
1778
- var valueText=outText.Text;
1779
- var aryText=outText.ArrayText;
1780
-
1781
- if (aryText)
1782
- {
1783
- var text;
1784
- for(var k=0;k<aryText.length;++k)
1785
- {
1786
- var titleItem=aryText[k];
1787
- if (titleItem.Name) text=titleItem.Name+":"+titleItem.Text;
1788
- else text=titleItem.Text;
1789
-
1790
- var textWidth=this.Canvas.measureText(text).width+this.ParamSpace;
1791
- if ((left+textWidth)>right) break;
1792
-
1793
- this.Canvas.fillStyle=titleItem.Color;
1794
- this.Canvas.fillText(text,left,bottom,textWidth);
1795
- left+=textWidth;
1796
- }
1797
- }
1798
- else
1799
- {
1800
- var text=valueText;
1801
- if (item.Name)
1802
- {
1803
- var dyTitle=this.GetDynamicOutName(item.Name);
1804
- if (dyTitle) text=dyTitle+ ":" + valueText;
1805
- else text = item.Name + ":" + valueText;
1806
- }
1807
-
1808
- textWidth = this.Canvas.measureText(text).width + this.ParamSpace; //后空2个像素
1809
- if (textWidth+left>right) break; //画不下了就不画了
1810
- this.Canvas.fillStyle = item.Color;
1811
- this.Canvas.fillText(text, left, bottom, textWidth);
1812
- left += textWidth;
1813
- }
1814
-
1815
- }
1816
- }
1817
- else
1818
- {
1819
- left += 4;
1820
- var eraseRight = left, eraseLeft = left;
1821
- for (var i in this.Data)
1822
- {
1823
- var item = this.Data[i];
1824
- if (!item || !item.Data || !item.Data.Data) continue;
1825
- if (item.Data.Data.length <= 0) continue;
1826
-
1827
- var indexName = '●' + item.Name;
1828
- this.Canvas.fillStyle = item.Color;
1829
- textWidth = this.Canvas.measureText(indexName).width + this.ParamSpace;
1830
- if (left + textWidth >= right) break;
1831
- this.Canvas.fillText(indexName, left, bottom, textWidth);
1832
- left += textWidth;
1833
- eraseRight = left;
1834
- }
1835
-
1836
- if (eraseRight > eraseLeft)
1837
- {
1838
- if (isHScreen)
1839
- {
1840
- this.EraseRect =
1841
- {
1842
- Left: eraseLeft, Right: eraseRight, Top: -(this.Frame.ChartBorder.TitleHeight - 1),
1843
- Width: eraseRight - eraseLeft, Height: this.Frame.ChartBorder.TitleHeight - 2
1844
- };
1845
- }
1846
- else
1847
- {
1848
- this.EraseRect =
1849
- {
1850
- Left: eraseLeft, Right: eraseRight, Top: (this.Frame.ChartBorder.GetTop() + 1),
1851
- Width: eraseRight - eraseLeft, Height: this.Frame.ChartBorder.TitleHeight - 2
1852
- };
1853
- }
1854
- }
1855
- }
1856
- }
1857
-
1858
- this.OnDrawTitleEvent=function()
1859
- {
1860
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_INDEXTITLE_DRAW);
1861
- if (!event) return;
1862
-
1863
- var data={ Index:null, Data:this.Data ,Title:this.Title, FrameID:this.Frame.Identify };
1864
- if (IFrameSplitOperator.IsNumber(this.CursorIndex))
1865
- {
1866
- var index=Math.abs(this.CursorIndex);
1867
- index=parseInt(index.toFixed(0));
1868
- data.Index=index; //当前屏数据索引
1869
- }
1870
-
1871
- var border=this.Frame.GetBorder();
1872
- data.Left=border.LeftEx;
1873
- data.Top=border.Top;
1874
- data.Right=border.RightEx;
1875
-
1876
- event.Callback(event,data,this);
1877
- }
1878
-
1879
- this.DrawOverlayIndexSingleLine=function() //叠加指标1个指标一行
1880
- {
1881
- if (this.OverlayIndex.size<=0) return;
1882
-
1883
- var isHScreen=(this.Frame.IsHScreen === true);
1884
- var border=this.Frame.GetBorder();
1885
-
1886
- var lineSpace=this.OverlayIndexType.LineSpace;
1887
- this.Canvas.textAlign="left";
1888
- this.Canvas.textBaseline="middle";
1889
- this.Canvas.font=this.Font;
1890
- var fontHeight=this.Canvas.measureText("擎").width;
1891
-
1892
- if (isHScreen)
1893
- {
1894
- var left = 1;
1895
- var top = lineSpace; //上下居中显示
1896
- var right = this.Frame.ChartBorder.GetHeight();
1897
- }
1898
- else
1899
- {
1900
- var top=border.TopTitle+2;
1901
- var left=border.Left+1;
1902
- var right=border.Right;
1903
- var bottom=border.Bottom;
1904
- }
1905
-
1906
- var x=left, y=top;
1907
- y=top+fontHeight/2;
1908
- for(var item of this.OverlayIndex)
1909
- {
1910
- var overlayItem=item[1];
1911
- var overlayID=item[0];
1912
- x=left;
1913
-
1914
- if (overlayItem.Title && this.IsShowOverlayIndexName)
1915
- {
1916
- var textWidth=this.Canvas.measureText(overlayItem.Title).width+2;
1917
- if ((x+textWidth)<right)
1918
- {
1919
- if (this.OverlayIndexType.BGColor)
1920
- {
1921
- this.Canvas.fillStyle=this.OverlayIndexType.BGColor;
1922
- var rtBG={Left:x, Top:y-fontHeight/2, Width:textWidth, Height: fontHeight+lineSpace }; //保存下标题的坐标
1923
- this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
1924
- }
1925
-
1926
- this.Canvas.fillStyle=this.TitleColor;
1927
- this.Canvas.fillText(overlayItem.Title,x,y,textWidth);
1928
- }
1929
- x+=textWidth;
1930
- }
1931
-
1932
- for(var i=0; i<overlayItem.Data.length; ++i)
1933
- {
1934
- var item=overlayItem.Data[i];
1935
- var outText=this.GetTitleItem(item, false);
1936
- if (!outText) continue;
1937
-
1938
- var valueText=outText.Text;
1939
- var aryText=outText.ArrayText;
1940
-
1941
- if (aryText)
1942
- {
1943
- var text;
1944
- for(var k=0;k<aryText.length;++k)
1945
- {
1946
- var titleItem=aryText[k];
1947
- if (titleItem.Name) text=titleItem.Name+":"+titleItem.Text;
1948
- else text=titleItem.Text;
1949
-
1950
- var textWidth=this.Canvas.measureText(text).width+this.ParamSpace;
1951
- if ((left+textWidth)>right) break;
1952
-
1953
- this.Canvas.fillStyle=titleItem.Color;
1954
- this.Canvas.fillText(text,x,y,textWidth);
1955
- x+=textWidth;
1956
- }
1957
- }
1958
- else
1959
- {
1960
- var text=valueText;
1961
- if (item.Name)
1962
- {
1963
- var dyTitle=this.GetDynamicOutName(item.Name);
1964
- if (dyTitle) text=dyTitle+ ":" + valueText;
1965
- else text = item.Name + ":" + valueText;
1966
- }
1967
-
1968
- textWidth = this.Canvas.measureText(text).width + this.ParamSpace; //后空2个像素
1969
- if (textWidth+left>right) break; //画不下了就不画了
1970
-
1971
- if (this.OverlayIndexType.BGColor)
1972
- {
1973
- this.Canvas.fillStyle=this.OverlayIndexType.BGColor;
1974
- var rtBG={Left:x, Top:y-fontHeight/2, Width:textWidth, Height: fontHeight+lineSpace }; //保存下标题的坐标
1975
- this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
1976
- }
1977
-
1978
- this.Canvas.fillStyle = item.Color;
1979
- this.Canvas.fillText(text, x, y, textWidth);
1980
- x += textWidth;
1981
- }
1982
- }
1983
-
1984
- y+=fontHeight+lineSpace;
1985
-
1986
- }
1987
- }
1988
- }
1989
-
1990
-
1991
-
1992
- //导出统一使用JSCommon命名空间名
1993
- export
1994
- {
1995
- IChartTitlePainting,
1996
- DynamicKLineTitlePainting,
1997
- DynamicMinuteTitlePainting,
1998
- DynamicChartTitlePainting,
1999
- DynamicTitleData,
2000
- STRING_FORMAT_TYPE,
2001
- };
2002
- /*
2003
- module.exports =
2004
- {
2005
- JSCommonChartTitle:
2006
- {
2007
- IChartTitlePainting: IChartTitlePainting,
2008
- DynamicKLineTitlePainting: DynamicKLineTitlePainting,
2009
- DynamicMinuteTitlePainting: DynamicMinuteTitlePainting,
2010
- DynamicChartTitlePainting: DynamicChartTitlePainting,
2011
- DynamicTitleData: DynamicTitleData,
2012
- STRING_FORMAT_TYPE: STRING_FORMAT_TYPE,
2013
- },
2014
-
2015
- //单个类导出
2016
- JSCommonChartTitle_IChartTitlePainting: IChartTitlePainting,
2017
- JSCommonChartTitle_DynamicKLineTitlePainting: DynamicKLineTitlePainting,
2018
- JSCommonChartTitle_DynamicMinuteTitlePainting: DynamicMinuteTitlePainting,
2019
- JSCommonChartTitle_DynamicChartTitlePainting: DynamicChartTitlePainting,
2020
- JSCommonChartTitle_DynamicTitleData: DynamicTitleData,
2021
- JSCommonChartTitle_STRING_FORMAT_TYPE: STRING_FORMAT_TYPE,
2022
- };
2023
- */