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,2247 +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
- ChartData, HistoryData,
22
- SingleData, MinuteData,
23
- JSCHART_EVENT_ID,
24
- } from "./umychart.data.wechat.js";
25
-
26
- import { JSCommonCoordinateData } from "./umychart.coordinatedata.wechat.js";
27
- var MARKET_SUFFIX_NAME = JSCommonCoordinateData.MARKET_SUFFIX_NAME;
28
-
29
- var WEEK_NAME=["日","一","二","三","四","五","六"];
30
-
31
- //坐标信息
32
- function CoordinateInfo()
33
- {
34
- this.Value; //坐标数据
35
- this.Message = new Array(); //坐标输出文字信息
36
- this.TextColor = g_JSChartResource.FrameSplitTextColor //文字颜色
37
- this.Font = g_JSChartResource.FrameSplitTextFont; //字体
38
- this.LineColor = g_JSChartResource.FrameSplitPen; //线段颜色
39
- this.LineDash=null; //当线段类型==2时 可以设置虚线样式
40
- this.LineType = 1; //线段类型 -1=不画线段, 2=虚线
41
- }
42
-
43
- /////////////////////////////////////////////////////////////////////////////////////////////////////
44
- //坐标分割
45
- //
46
- //
47
- ////////////////////////////////////////////////////////////////////////////////////////////////////
48
- function IFrameSplitOperator()
49
- {
50
- this.ChartBorder; //边框信息
51
- this.Frame; //框架信息
52
- this.FrameSplitData; //坐标轴分割方法
53
- this.SplitCount = 5; //刻度个数
54
- this.StringFormat = 0; //刻度字符串格式 -1 刻度文字全部不显示 -2 刻度文字右边不显示
55
- this.IsShowLeftText = true; //显示左边刻度
56
- this.IsShowRightText = true; //显示右边刻度
57
- this.LanguageID = JSCHART_LANGUAGE_ID.LANGUAGE_CHINESE_ID;
58
- this.GetEventCallback; //事件回调
59
-
60
- //////////////////////
61
- // data.Min data.Max data.Interval data.Count
62
- //
63
- this.IntegerCoordinateSplit = function (data)
64
- {
65
- var splitItem = this.FrameSplitData.Find(data.Interval);
66
- if (!splitItem) return false;
67
- if (data.Interval == splitItem.Interval) return true;
68
-
69
- var fixMax=data.Max, fixMin=data.Min;
70
- var maxValue=data.Max/splitItem.FixInterval;
71
- var minValue=data.Min/splitItem.FixInterval;
72
- //调整到整数倍数,不能整除的 +1
73
- if (IFrameSplitOperator.IsFloat(maxValue)) fixMax=parseInt((maxValue+0.5).toFixed(0))*splitItem.FixInterval;
74
- if (IFrameSplitOperator.IsFloat(minValue)) fixMin=parseInt((minValue-0.5).toFixed(0))*splitItem.FixInterval;
75
- if (data.Min == 0) fixMin = 0; //最小值是0 不用调整了.
76
- if (fixMin < 0 && data.Min > 0) fixMin = 0; //都是正数的, 最小值最小调整为0
77
-
78
- var count = 0;
79
- for (var i = fixMin; (i - fixMax) < 0.00000001; i += splitItem.FixInterval)
80
- {
81
- ++count;
82
- }
83
-
84
- data.Interval = splitItem.FixInterval;
85
- data.Max = fixMax;
86
- data.Min = fixMin;
87
- data.Count = count;
88
-
89
- return true;
90
- }
91
-
92
- this.Filter = function (aryInfo, keepZero) //keepZero 保留0轴
93
- {
94
- if (this.SplitCount <= 0 || aryInfo.length <= 0 || aryInfo.length <= this.SplitCount) return aryInfo;
95
-
96
- //分割线比预设的多, 过掉一些
97
- var filter = parseInt(aryInfo.length / this.SplitCount);
98
- if (filter <= 1) filter = 2;
99
- var data = [];
100
-
101
- for (var i = 0; i < aryInfo.length; i += filter)
102
- {
103
- if (i + filter >= aryInfo.length && i != aryInfo.length - 1) //最后一个数据放进去
104
- {
105
- data.push(aryInfo[aryInfo.length - 1]);
106
- }
107
- else {
108
- data.push(aryInfo[i]);
109
- }
110
- }
111
-
112
- if (this.SplitCount == 2 && data.length > 2) //之显示第1个和最后一个刻度
113
- {
114
- for (var i = 1; i < data.length - 1; ++i)
115
- {
116
- var item = data[i];
117
- item.Message[0] = null;
118
- item.Message[1] = null;
119
- }
120
- }
121
-
122
- if (keepZero) //如果不存在0轴,增加一个0轴,刻度信息部显示
123
- {
124
- var bExsitZero = false;
125
- for (var i = 0; i < data.length; ++i)
126
- {
127
- var item = data[i];
128
- if (Math.abs(item.Value) < 0.00000001)
129
- {
130
- bExsitZero = true;
131
- break;
132
- }
133
- }
134
-
135
- if (bExsitZero == false)
136
- {
137
- var zeroCoordinate = new CoordinateInfo();
138
- zeroCoordinate.Value = 0;
139
- zeroCoordinate.Message[0] = null
140
- zeroCoordinate.Message[1] = null;
141
- data.push(zeroCoordinate);
142
- }
143
- }
144
-
145
- return data;
146
- }
147
-
148
- this.RemoveZero = function (aryInfo) //移除小数后面多余的0
149
- {
150
- //所有的数字小数点后面都0,才会去掉
151
- var isAllZero = [true, true];
152
- for (var i in aryInfo) {
153
- var item = aryInfo[i];
154
- var message = item.Message[0];
155
- if (!this.IsDecimalZeroEnd(message)) isAllZero[0] = false;
156
-
157
- var message = item.Message[1];
158
- if (!this.IsDecimalZeroEnd(message)) isAllZero[1] = false;
159
- }
160
-
161
- if (isAllZero[0] == false && isAllZero[1] == false) return;
162
- for (var i in aryInfo)
163
- {
164
- var item = aryInfo[i];
165
- if (isAllZero[0])
166
- {
167
- var message = item.Message[0];
168
- if (message != null)
169
- {
170
- if (typeof (message) == 'number') message = message.toString();
171
- item.Message[0] = message.replace(/[.][0]+/g, '');
172
- }
173
- }
174
-
175
- if (isAllZero[1])
176
- {
177
- var message = item.Message[1];
178
- if (message != null)
179
- {
180
- if (typeof (message) == 'number') message = message.toString();
181
- item.Message[1] = message.replace(/[.][0]+/g, '');
182
- }
183
- }
184
- }
185
- }
186
-
187
- this.IsDecimalZeroEnd = function (text) //是否是0结尾的小数
188
- {
189
- if (text == null) return true;
190
- if (text == '0') return true;
191
- if (typeof (text) == 'number') text = text.toString();
192
-
193
- var pos = text.search(/[.]/);
194
- if (pos < 0) return false;
195
-
196
- for (var i = pos + 1; i < text.length; ++i)
197
- {
198
- var char = text.charAt(i);
199
- if (char >= '1' && char <= '9') return false;
200
- }
201
-
202
- return true;
203
- }
204
- }
205
-
206
- //字符串格式化 千分位分割
207
- IFrameSplitOperator.FormatValueThousandsString=function(value,floatPrecision)
208
- {
209
- if (value==null || isNaN(value))
210
- {
211
- if (floatPrecision>0)
212
- {
213
- var nullText='-.';
214
- for(var i=0;i<floatPrecision;++i)
215
- nullText+='-';
216
- return nullText;
217
- }
218
-
219
- return '--';
220
- }
221
-
222
- var result='';
223
- var num=value.toFixed(floatPrecision);
224
- if(floatPrecision>0){
225
- var numFloat = num.split('.')[1];
226
- var numM = num.split('.')[0];
227
- while (numM.length > 3)
228
- {
229
- result = ',' + numM.slice(-3) + result;
230
- numM = numM.slice(0, numM.length - 3);
231
- }
232
- if (numM) { result = numM + result + '.' + numFloat; }
233
- }else{
234
- while (num.length > 3)
235
- {
236
- result = ',' + num.slice(-3) + result;
237
- num = num.slice(0, num.length - 3);
238
- }
239
- if (num) { result = num + result; }
240
- }
241
-
242
- return result;
243
- }
244
-
245
- //数据输出格式化 floatPrecision=小数位数
246
- IFrameSplitOperator.FormatValueString=function(value, floatPrecision,languageID)
247
- {
248
- if (value==null || isNaN(value))
249
- {
250
- if (floatPrecision>0)
251
- {
252
- var nullText='-.';
253
- for(var i=0;i<floatPrecision;++i)
254
- nullText+='-';
255
- return nullText;
256
- }
257
-
258
- return '--';
259
- }
260
-
261
- if (value<0.00000000001 && value>-0.00000000001)
262
- {
263
- return "0";
264
- }
265
-
266
- var absValue = Math.abs(value);
267
- if (languageID===JSCHART_LANGUAGE_ID.LANGUAGE_ENGLISH_ID)
268
- {
269
- if (absValue < 10000)
270
- return value.toFixed(floatPrecision);
271
- else if (absValue < 1000000)
272
- return (value/1000).toFixed(floatPrecision)+"K";
273
- else if (absValue < 1000000000)
274
- return (value/1000000).toFixed(floatPrecision)+"M";
275
- else if (absValue < 1000000000000)
276
- return (value/1000000000).toFixed(floatPrecision)+"B";
277
- else
278
- return (value/1000000000000).toFixed(floatPrecision)+"T";
279
- }
280
- else if (languageID===JSCHART_LANGUAGE_ID.LANGUAGE_TRADITIONAL_CHINESE_ID) //繁体
281
- {
282
- if (absValue < 10000)
283
- return value.toFixed(floatPrecision);
284
- else if (absValue < 100000000)
285
- return (value/10000).toFixed(floatPrecision)+"萬";
286
- else if (absValue < 1000000000000)
287
- return (value/100000000).toFixed(floatPrecision)+"億";
288
- else
289
- return (value/1000000000000).toFixed(floatPrecision)+"萬億";
290
- }
291
- else
292
- {
293
- if (absValue < 10000)
294
- return value.toFixed(floatPrecision);
295
- else if (absValue < 100000000)
296
- return (value/10000).toFixed(floatPrecision)+"万";
297
- else if (absValue < 1000000000000)
298
- return (value/100000000).toFixed(floatPrecision)+"亿";
299
- else
300
- return (value/1000000000000).toFixed(floatPrecision)+"万亿";
301
- }
302
-
303
- return '';
304
- }
305
-
306
- //整形输出格式化 floatPrecision=小数位数
307
- IFrameSplitOperator.FromatIntegerString=function(value, floatPrecision,languageID)
308
- {
309
- if (value<10000 && IFrameSplitOperator.IsInteger(value)) floatPrecision=0; //<10000的整形 去掉小数位数
310
- return IFrameSplitOperator.FormatValueString(value, floatPrecision,languageID);
311
- }
312
-
313
- IFrameSplitOperator.NumberToString=function(value)
314
- {
315
- if (value<10) return '0'+value.toString();
316
- return value.toString();
317
- }
318
-
319
- IFrameSplitOperator.FormatDateString=function(value,format,languageID)
320
- {
321
- var year=parseInt(value/10000);
322
- var month=parseInt(value/100)%100;
323
- var day=value%100;
324
-
325
- switch(format)
326
- {
327
- case 'MM-DD':
328
- return IFrameSplitOperator.NumberToString(month) + '-' + IFrameSplitOperator.NumberToString(day);
329
- case "YYYY-MM":
330
- return `${year}-${IFrameSplitOperator.NumberToString(month)}`;
331
- case "YYYY/MM/DD":
332
- return year.toString() + '/' + IFrameSplitOperator.NumberToString(month) + '/' + IFrameSplitOperator.NumberToString(day);
333
- case "YYYY/MM/DD/W":
334
- {
335
- var date=new Date(year,month-1,day);
336
- var week=g_JSChartLocalization.GetText(WEEK_NAME[date.getDay()],languageID);
337
- return year.toString() + '/' + IFrameSplitOperator.NumberToString(month) + '/' + IFrameSplitOperator.NumberToString(day)+"/"+ week.toString();
338
- }
339
- case "DD/MM/YYYY":
340
- return IFrameSplitOperator.NumberToString(day) + '/' + IFrameSplitOperator.NumberToString(month) + '/' + year.toString();
341
- default:
342
- return year.toString() + '-' + IFrameSplitOperator.NumberToString(month) + '-' + IFrameSplitOperator.NumberToString(day);
343
- }
344
- }
345
-
346
- IFrameSplitOperator.FormatTimeString=function(value, format) //format hh:mm:ss
347
- {
348
- if (format=='HH:MM:SS')
349
- {
350
- var hour=parseInt(value/10000);
351
- var minute=parseInt((value%10000)/100);
352
- var second=value%100;
353
- return IFrameSplitOperator.NumberToString(hour)+':'+ IFrameSplitOperator.NumberToString(minute) + ':' + IFrameSplitOperator.NumberToString(second);
354
- }
355
- else if (format == 'HH:MM')
356
- {
357
- var hour = parseInt(value / 100);
358
- var minute = value % 100;
359
- return IFrameSplitOperator.NumberToString(hour) + ':' + IFrameSplitOperator.NumberToString(minute);
360
- }
361
- else
362
- {
363
- if (value < 10000)
364
- {
365
- var hour = parseInt(value / 100);
366
- var minute = value % 100;
367
- return IFrameSplitOperator.NumberToString(hour) + ':' + IFrameSplitOperator.NumberToString(minute);
368
- }
369
- else
370
- {
371
- var hour = parseInt(value / 10000);
372
- var minute = parseInt((value % 10000) / 100);
373
- var second = value % 100;
374
- return IFrameSplitOperator.NumberToString(hour) + ':' + IFrameSplitOperator.NumberToString(minute) + ':' + IFrameSplitOperator.NumberToString(second);
375
- }
376
-
377
- }
378
- }
379
-
380
- //报告格式化
381
- IFrameSplitOperator.FormatReportDateString=function(value)
382
- {
383
- var year=parseInt(value/10000);
384
- var month=parseInt(value/100)%100;
385
- var monthText;
386
- switch(month)
387
- {
388
- case 3:
389
- monthText="一季度报";
390
- break;
391
- case 6:
392
- monthText="半年报";
393
- break;
394
- case 9:
395
- monthText="三季度报";
396
- break;
397
- case 12:
398
- monthText="年报";
399
- break;
400
- }
401
-
402
- return year.toString()+ monthText;
403
- }
404
-
405
- IFrameSplitOperator.FormatDateTimeString=function(value,isShowDate)
406
- {
407
- var aryValue=value.split(' ');
408
- if (aryValue.length<2) return "";
409
- var time=parseInt(aryValue[1]);
410
- var minute=time%100;
411
- var hour=parseInt(time/100);
412
- var text=(hour<10? ('0'+hour.toString()):hour.toString()) + ':' + (minute<10?('0'+minute.toString()):minute.toString());
413
-
414
- if (isShowDate==true)
415
- {
416
- var date=parseInt(aryValue[0]);
417
- var year=parseInt(date/10000);
418
- var month=parseInt(date%10000/100);
419
- var day=date%100;
420
- text=year.toString() +'-'+ (month<10? ('0'+month.toString()) :month.toString()) +'-'+ (day<10? ('0'+day.toString()):day.toString()) +" " +text;
421
- }
422
-
423
- return text;
424
- }
425
-
426
- //字段颜色格式化
427
- IFrameSplitOperator.FormatValueColor = function (value, value2)
428
- {
429
- if (value != null && value2 == null) //只传一个值的 就判断value正负
430
- {
431
- if (value == 0) return 'PriceNull';
432
- else if (value > 0) return 'PriceUp';
433
- else return 'PriceDown';
434
- }
435
-
436
- //2个数值对比 返回颜色
437
- if (value == null || value2 == null) return 'PriceNull';
438
- if (value == value2) return 'PriceNull';
439
- else if (value > value2) return 'PriceUp';
440
- else return 'PriceDown';
441
- }
442
-
443
- //成交量显示
444
- IFrameSplitOperator.FormatVolString=function(value,languageID)
445
- {
446
- var absValue = Math.abs(value);
447
- if (absValue<100000)
448
- return value.toFixed(0);
449
- else if (absValue<10000000)
450
- return (value/10000).toFixed(1)+"万";
451
- else if (absValue<100000000)
452
- return (value/10000).toFixed(0)+"万";
453
- else if (absValue<1000000000)
454
- return (value/100000000).toFixed(2)+"亿";
455
- else if (absValue < 1000000000000)
456
- return (value/100000000).toFixed(1)+"亿";
457
- else
458
- return (value/1000000000000).toFixed(1)+"万亿";
459
- }
460
-
461
- IFrameSplitOperator.IsNumber=function(value)
462
- {
463
- if (value==null) return false;
464
- if (isNaN(value)) return false;
465
-
466
- return typeof(value)=='number';
467
- }
468
-
469
- //判断是否是正数
470
- IFrameSplitOperator.IsPlusNumber=function(value)
471
- {
472
- if (value==null) return false;
473
- if (isNaN(value)) return false;
474
-
475
- return value>0;
476
- }
477
-
478
- //是否是整形
479
- IFrameSplitOperator.IsInteger=function(x)
480
- {
481
- return (typeof x === 'number') && (x % 1 === 0);
482
- }
483
-
484
- //是否有效
485
- IFrameSplitOperator.IsVaild=function(value)
486
- {
487
- if (isNaN(value)) return false;
488
- if (value==null) return false;
489
- if (value===undefined) return false;
490
-
491
- return true;
492
- }
493
-
494
- //判断字段是否存在
495
- IFrameSplitOperator.IsObjectExist=function(obj)
496
- {
497
- if (obj===undefined) return false;
498
- if (obj==null) return false;
499
-
500
- return true;
501
- }
502
-
503
- //是否时bool
504
- IFrameSplitOperator.IsBool=function(value)
505
- {
506
- if (value===true || value===false) return true;
507
- return false;
508
- }
509
-
510
- IFrameSplitOperator.IsString=function(value)
511
- {
512
- var type=typeof(value);
513
- if (type=='string') return true;
514
- return false;
515
- }
516
-
517
- IFrameSplitOperator.IsFloat=function(value)
518
- {
519
- if (value===undefined) return false;
520
- if (value==null) return false;
521
- if (isNaN(value)) return false;
522
-
523
- return value!=parseInt(value);
524
- }
525
-
526
- //是否是非空的数组
527
- IFrameSplitOperator.IsNonEmptyArray=function(ary)
528
- {
529
- if (!ary) return;
530
- if (!Array.isArray(ary)) return;
531
-
532
- return ary.length>0;
533
- }
534
-
535
- //K线Y轴分割
536
- function FrameSplitKLinePriceY()
537
- {
538
- this.newMethod = IFrameSplitOperator; //派生
539
- this.newMethod();
540
- delete this.newMethod;
541
-
542
- this.CoordinateType = 0; //坐标类型 0=普通坐标 1=百分比坐标 (右边坐标刻度)
543
- this.Symbol;
544
- this.Data; //K线数据 (计算百分比坐标)
545
- this.FrameSplitData2; //坐标轴分割方法(计算百分比刻度)
546
- this.FloatPrecision = null; //小数位数 (设置了就使用这个位数,否则使用品种对应的小数位数)
547
-
548
- this.Custom = []; //[{Type:0}]; 定制刻度 0=显示最后的价格刻度
549
- this.SplitType = 0; //0=自动分割 1=固定分割
550
- this.DefaultSplitType=0;
551
-
552
- this.Operator = function ()
553
- {
554
- var splitData = {};
555
- splitData.Max = this.Frame.HorizontalMax;
556
- splitData.Min = this.Frame.HorizontalMin;
557
- splitData.Count = this.SplitCount;
558
-
559
- if (this.Frame.YMaxMin) //原始的数据范围
560
- {
561
- var item=this.Frame.YMaxMin;
562
- if (IFrameSplitOperator.IsNumber(item.Max) && IFrameSplitOperator.IsNumber(item.Min))
563
- {
564
- splitData.Max=item.Max;
565
- splitData.Min=item.Min;
566
- }
567
- }
568
-
569
- if (splitData.Max==splitData.Min) //如果一样上下扩大下
570
- {
571
- splitData.Max+=splitData.Max*0.01;
572
- splitData.Min-=splitData.Min*0.01
573
- }
574
- splitData.Interval = (splitData.Max - splitData.Min) / (splitData.Count - 1);
575
-
576
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
577
- if (JSCommonCoordinateData.MARKET_SUFFIX_NAME.IsSHSZIndex(this.Symbol)) defaultfloatPrecision = 0; //手机端指数不显示小数位数
578
- if (this.FloatPrecision != null) defaultfloatPrecision = this.FloatPrecision;
579
-
580
- var bFilter=true;
581
- if (FrameSplitKLinePriceY.SplitCustom)
582
- {
583
- FrameSplitKLinePriceY.SplitCustom(this,splitData,defaultfloatPrecision); //自定义分割
584
- bFilter=false;
585
- }
586
- else
587
- {
588
- switch (this.CoordinateType)
589
- {
590
- case 1:
591
- this.SplitPercentage(splitData, defaultfloatPrecision);
592
- break;
593
- default:
594
- if (this.SplitType == 1) this.SplitFixed(splitData, defaultfloatPrecision);
595
- else this.SplitDefault(splitData, defaultfloatPrecision);
596
- this.CustomCoordinate(defaultfloatPrecision);
597
- break;
598
- }
599
- }
600
-
601
- if (bFilter) this.Frame.HorizontalInfo = this.Filter(this.Frame.HorizontalInfo, false);
602
- this.Frame.HorizontalMax = splitData.Max;
603
- this.Frame.HorizontalMin = splitData.Min;
604
-
605
- if (this.GetEventCallback)
606
- {
607
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_SPLIT_YCOORDINATE);
608
- if (event && event.Callback)
609
- {
610
- var data={ID:this.Frame.Identify, Frame:this.Frame };
611
- event.Callback(event,data,this);
612
- }
613
- }
614
- }
615
-
616
- this.SplitDefault = function (splitData, floatPrecision) //默认坐标
617
- {
618
- this.IntegerCoordinateSplit(splitData);
619
-
620
- this.Frame.HorizontalInfo = [];
621
- for (var i = 0, value = splitData.Min; i < splitData.Count; ++i, value += splitData.Interval)
622
- {
623
- this.Frame.HorizontalInfo[i] = new CoordinateInfo();
624
- this.Frame.HorizontalInfo[i].Value = value;
625
- if (this.IsShowLeftText) this.Frame.HorizontalInfo[i].Message[0] = value.toFixed(floatPrecision);
626
- if (this.IsShowRightText) this.Frame.HorizontalInfo[i].Message[1] = value.toFixed(floatPrecision);
627
- }
628
- }
629
-
630
- this.SplitPercentage = function (splitData, floatPrecision) //百分比坐标
631
- {
632
- var firstOpenPrice = this.GetFirstOpenPrice();
633
- splitData.Max = (splitData.Max - firstOpenPrice) / firstOpenPrice;
634
- splitData.Min = (splitData.Min - firstOpenPrice) / firstOpenPrice;
635
- splitData.Interval = (splitData.Max - splitData.Min) / (splitData.Count - 1);
636
- this.IntegerCoordinateSplit2(splitData);
637
-
638
- var maxValue=(1 + splitData.Max) * firstOpenPrice;
639
- var minValue=(1 + splitData.Min) * firstOpenPrice;
640
-
641
- this.Frame.HorizontalInfo = [];
642
- for (var i = 0, value = splitData.Min; i < splitData.Count; ++i, value += splitData.Interval)
643
- {
644
- var price = (value + 1) * firstOpenPrice;
645
- if (price<minValue || price>maxValue) continue;
646
-
647
- this.Frame.HorizontalInfo[i] = new CoordinateInfo();
648
- this.Frame.HorizontalInfo[i].Value = price;
649
- if (this.IsShowLeftText) this.Frame.HorizontalInfo[i].Message[0] = price.toFixed(floatPrecision); //左边价格坐标
650
- if (this.IsShowRightText) this.Frame.HorizontalInfo[i].Message[1] = (value * 100).toFixed(2) + '%'; //右边百分比
651
- }
652
-
653
- splitData.Min = (1 + splitData.Min) * firstOpenPrice; //最大最小值调整
654
- splitData.Max = (1 + splitData.Max) * firstOpenPrice;
655
- }
656
-
657
- this.SplitFixed = function (splitData, floatPrecision) //固定分割坐标
658
- {
659
- this.Frame.HorizontalInfo = [];
660
- for (var i = 0, value = splitData.Min; i < splitData.Count; ++i, value += splitData.Interval) {
661
- this.Frame.HorizontalInfo[i] = new CoordinateInfo();
662
- this.Frame.HorizontalInfo[i].Value = value;
663
- if (this.IsShowLeftText) this.Frame.HorizontalInfo[i].Message[0] = value.toFixed(floatPrecision);
664
- if (this.IsShowRightText) this.Frame.HorizontalInfo[i].Message[1] = value.toFixed(floatPrecision);
665
- }
666
- }
667
-
668
- this.CustomCoordinate = function (floatPrecision)
669
- {
670
- this.Frame.CustomHorizontalInfo = [];
671
- for (var i=0;i<this.Custom.length; ++i)
672
- {
673
- var item = this.Custom[i];
674
- if (item.Type == 0 || item.Type==3 || item.Type==2 ) //最新价格刻度
675
- {
676
- var dec=floatPrecision;
677
- //外部设置小数位数
678
- if (IFrameSplitOperator.IsNumber(item.FloatPrecision) && item.FloatPrecision>=0) dec=item.FloatPrecision;
679
- var latestItem = this.GetLatestPrice(dec, item);
680
- if (latestItem) this.Frame.CustomHorizontalInfo.push(latestItem);
681
- }
682
- else if (item.Type == 1) //固定价格刻度
683
- {
684
- this.CustomFixedCoordinate(item);
685
- }
686
- }
687
- }
688
-
689
- this.GetLatestPrice = function (floatPrecision, option)
690
- {
691
- if (!this.Data || !this.Data.Data) return null;
692
- if (this.Data.Data.length <= 0) return null;
693
- var latestItem = this.Data.Data[this.Data.Data.length - 1];
694
- var info = new CoordinateInfo();
695
- info.Type = 0;
696
- if (option && IFrameSplitOperator.IsNumber(option.Type)) info.Type=option.Type;
697
- info.Value = latestItem.Close;
698
- info.TextColor = g_JSChartResource.FrameLatestPrice.TextColor;
699
- info.LineType = 2; //虚线
700
- if (option.Position == 'left') info.Message[0] = latestItem.Close.toFixed(floatPrecision);
701
- else info.Message[1] = latestItem.Close.toFixed(floatPrecision);
702
- if (latestItem.Close > latestItem.Open) info.LineColor = g_JSChartResource.FrameLatestPrice.UpBarColor;
703
- else if (latestItem.Close < latestItem.Open) info.LineColor = g_JSChartResource.FrameLatestPrice.DownBarColor;
704
- else info.LineColor = g_JSChartResource.FrameLatestPrice.UnchagneBarColor;
705
-
706
- if (IFrameSplitOperator.IsNumber(option.LineType)) info.LineType=option.LineType;
707
- if (option.IsShowLine == false) info.LineType = -1;
708
- if (option.CountDown===true) info.CountDown=true; //倒计时设置
709
- if (option.PositionEx===1) info.ExtendData={ Custom:{ Position:1 } }; //强制画在内部
710
- return info;
711
- }
712
-
713
- this.GetFirstOpenPrice = function () //获取显示第1个数据的开盘价
714
- {
715
- if (!this.Data) return null;
716
- var xPointCount = this.Frame.XPointCount;
717
- for (var i = this.Data.DataOffset, j = 0; i < this.Data.Data.length && j < xPointCount; ++i, ++j)
718
- {
719
- var data = this.Data.Data[i];
720
- if (data.Open == null || data.High == null || data.Low == null || data.Close == null) continue;
721
-
722
- return data.Open;
723
- }
724
- return null;
725
- }
726
-
727
- this.CustomFixedCoordinate = function (option) //固定坐标刻度
728
- {
729
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
730
- for (var i=0; i<option.Data.length; ++i)
731
- {
732
- var item = option.Data[i];
733
- var info = new CoordinateInfo();
734
- info.Type = 1;
735
- info.TextColor = item.TextColor;
736
- info.LineColor = item.Color;
737
- info.LineType = 2; //虚线
738
- if (IFrameSplitOperator.IsNumber(option.LineType)) info.LineType=option.LineType;
739
- if (option.IsShowLine == false) info.LineType = -1;
740
-
741
- info.Value = item.Value;
742
- var text;
743
- if (item.Text) text = item.Text;
744
- else text = info.Value.toFixed(defaultfloatPrecision);
745
- if (option.Position == 'left') info.Message[0] = text;
746
- else info.Message[1] = text;
747
- if (option.PositionEx===1) info.ExtendData={ Custom:{ Position:1 } }; //强制画在内部
748
- this.Frame.CustomHorizontalInfo.push(info);
749
- }
750
- }
751
-
752
-
753
- //////////////////////
754
- // data.Min data.Max data.Interval data.Count
755
- //
756
- this.IntegerCoordinateSplit2 = function (data)
757
- {
758
- var splitItem = this.FrameSplitData2.Find(data.Interval);
759
- if (!splitItem) return false;
760
- if (data.Interval == splitItem.FixInterval) return true;
761
-
762
- var fixMax=data.Max, fixMin=data.Min;
763
- var maxValue=data.Max/splitItem.FixInterval;
764
- var minValue=data.Min/splitItem.FixInterval;
765
- //调整到整数倍数,不能整除的 +1
766
- if (IFrameSplitOperator.IsFloat(maxValue)) fixMax=parseInt((maxValue+0.5).toFixed(0))*splitItem.FixInterval;
767
- if (IFrameSplitOperator.IsFloat(minValue)) fixMin=parseInt((minValue-0.5).toFixed(0))*splitItem.FixInterval;
768
- if (data.Min == 0) fixMin = 0; //最小值是0 不用调整了.
769
- if (fixMin < 0 && data.Min > 0) fixMin = 0; //都是正数的, 最小值最小调整为0
770
-
771
- var count = 0;
772
- for (var i = fixMin; (i - fixMax) < 0.00000001; i += splitItem.FixInterval)
773
- {
774
- ++count;
775
- }
776
-
777
- data.Interval = splitItem.FixInterval;
778
- data.Max = fixMax;
779
- data.Min = fixMin;
780
- data.Count = count;
781
-
782
- return true;
783
- }
784
-
785
- }
786
-
787
- //一般的Y轴分割
788
- function FrameSplitY()
789
- {
790
- this.newMethod = IFrameSplitOperator; //派生
791
- this.newMethod();
792
- delete this.newMethod;
793
- this.SplitType=0; //0=自动分割 1=固定分割 2=百分比(0-100)
794
- this.DefaultSplitType=0;
795
- this.FloatPrecision = 2; //坐标小数位数(默认2)
796
- this.FLOATPRECISION_RANGE = [1, 0.1, 0.01, 0.001, 0.0001];
797
- this.IgnoreYValue = null; //在这个数组里的数字不显示在刻度上
798
- this.LineType=null; //线段样式
799
-
800
- this.IsShowYZero = true;
801
- this.IntegerSplitData = null;
802
-
803
- this.Operator = function ()
804
- {
805
- var splitData = {};
806
- splitData.Max = this.Frame.HorizontalMax;
807
- splitData.Min = this.Frame.HorizontalMin;
808
-
809
- if (this.Frame.YMaxMin) //原始的数据范围
810
- {
811
- var item=this.Frame.YMaxMin;
812
- if (IFrameSplitOperator.IsNumber(item.Max) && IFrameSplitOperator.IsNumber(item.Min))
813
- {
814
- splitData.Max=item.Max;
815
- splitData.Min=item.Min;
816
- }
817
- }
818
-
819
- if (splitData.Max==splitData.Min) //如果一样上下扩大下
820
- {
821
- if (splitData.Max==0)
822
- {
823
- splitData.Max=1;
824
- splitData.Min=-1;
825
- }
826
- else
827
- {
828
- splitData.Max+=splitData.Max*0.01;
829
- splitData.Min-=splitData.Min*0.01;
830
- }
831
- }
832
-
833
- if (this.Frame.YSpecificMaxMin)
834
- {
835
- splitData.Count = this.Frame.YSpecificMaxMin.Count;
836
- splitData.Interval = (splitData.Max - splitData.Min) / (splitData.Count - 1);
837
- }
838
- else if (this.SplitType==1)
839
- {
840
- splitData.Count=this.SplitCount;
841
- splitData.Interval=(splitData.Max-splitData.Min)/(splitData.Count-1);
842
- }
843
- else if (this.SplitType==2)
844
- {
845
- splitData.Max=100;
846
- splitData.Min=0;
847
- splitData.Count=this.SplitCount;
848
- splitData.Interval=(splitData.Max-splitData.Min)/(splitData.Count-1);
849
- }
850
- else
851
- {
852
- splitData.Count = this.SplitCount * 2; //放大两倍
853
- if (this.FloatPrecision == 0) //页面配置了纵坐标小数位数FloatPrecision=0时执行
854
- {
855
- splitData.Interval = (splitData.Max - splitData.Min) / (splitData.Count - 1);
856
- this.IntegerCoordinateSplit2(splitData);
857
- }
858
- else {
859
- splitData.Interval = (splitData.Max - splitData.Min) / (splitData.Count - 1);
860
- this.IntegerCoordinateSplit(splitData);
861
- }
862
- }
863
-
864
- this.Frame.HorizontalInfo = [];
865
- if (this.Frame.YSplitScale)
866
- {
867
- for (var i in this.Frame.YSplitScale)
868
- {
869
- var value = this.Frame.YSplitScale[i];
870
- var coordinate = new CoordinateInfo();
871
- coordinate.Value = value;
872
- if (IFrameSplitOperator.IsNumber(this.LineType)) coordinate.LineType=this.LineType;
873
-
874
- var absValue = Math.abs(value);
875
- var floatPrecision = this.FloatPrecision; //数据比小数位数还小, 调整小数位数
876
- if (absValue < 0.0000000001)
877
- coordinate.Message[1] = 0;
878
- else if (absValue < this.FLOATPRECISION_RANGE[this.FLOATPRECISION_RANGE.length - 1])
879
- coordinate.Message[1] = value.toExponential(2).toString();
880
- else
881
- {
882
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
883
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
884
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
885
- coordinate.Message[1] = IFrameSplitOperator.FormatValueString(value, floatPrecision, this.LanguageID);
886
- }
887
- coordinate.Message[0] = coordinate.Message[1];
888
-
889
- if (this.StringFormat == -2) coordinate.Message[1] = null; //刻度右边不显示
890
- else if (this.StringFormat == -3) coordinate.Message[0] = null; //刻度左边不显示
891
- else if (this.StringFormat == -1) coordinate.Message[0] = coordinate.Message[1] = null; //刻度左右都不显示
892
-
893
- this.Frame.HorizontalInfo.push(coordinate);
894
- }
895
- }
896
- else
897
- {
898
- for (var i = 0, value = splitData.Min; i < splitData.Count; ++i, value += splitData.Interval)
899
- {
900
- var coordinate=new CoordinateInfo();
901
- this.Frame.HorizontalInfo[i] = coordinate;
902
- coordinate.Value=value;
903
- if (IFrameSplitOperator.IsNumber(this.LineType)) coordinate.LineType=this.LineType;
904
-
905
- if (this.StringFormat == 1) //手机端格式 如果有万,亿单位了 去掉小数
906
- {
907
- var floatPrecision = this.FloatPrecision;
908
- if (!isNaN(value) && Math.abs(value) > 1000) floatPrecision = 0;
909
- this.Frame.HorizontalInfo[i].Message[1] = IFrameSplitOperator.FormatValueString(value, floatPrecision, this.LanguageID);
910
- }
911
- else if (this.StringFormat == -1) //刻度不显示
912
- {
913
-
914
- }
915
- else
916
- {
917
- var absValue = Math.abs(value);
918
- var floatPrecision = this.FloatPrecision; //数据比小数位数还小, 调整小数位数
919
- if (absValue < 0.0000000001)
920
- this.Frame.HorizontalInfo[i].Message[1] = 0;
921
- else if (absValue < this.FLOATPRECISION_RANGE[this.FLOATPRECISION_RANGE.length - 1])
922
- this.Frame.HorizontalInfo[i].Message[1] = value.toExponential(2).toString();
923
- else {
924
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
925
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
926
- if (floatPrecision < this.FLOATPRECISION_RANGE.length && absValue < this.FLOATPRECISION_RANGE[floatPrecision])++floatPrecision;
927
- this.Frame.HorizontalInfo[i].Message[1] = IFrameSplitOperator.FormatValueString(value, floatPrecision, this.LanguageID);
928
- }
929
- }
930
-
931
- this.Frame.HorizontalInfo[i].Message[0] = this.Frame.HorizontalInfo[i].Message[1];
932
-
933
- if (this.StringFormat == -2) this.Frame.HorizontalInfo[i].Message[1] = null; //刻度右边不显示
934
- else if (this.StringFormat == -3) this.Frame.HorizontalInfo[i].Message[0] = null; //刻度左边不显示
935
- }
936
- }
937
-
938
- this.FilterIgnoreYValue();
939
- this.Frame.HorizontalInfo = this.Filter(this.Frame.HorizontalInfo, (splitData.Max > 0 && splitData.Min < 0 && this.IsShowYZero));
940
- this.RemoveZero(this.Frame.HorizontalInfo);
941
- this.DynamicMessageText();
942
- this.Frame.HorizontalMax = splitData.Max;
943
- this.Frame.HorizontalMin = splitData.Min;
944
-
945
- if (this.GetEventCallback)
946
- {
947
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_SPLIT_YCOORDINATE);
948
- if (event && event.Callback)
949
- {
950
- var data={ID:this.Frame.Identify, Frame:this.Frame };
951
- event.Callback(event,data,this);
952
- }
953
- }
954
- }
955
-
956
- this.FilterIgnoreYValue = function ()
957
- {
958
- if (!this.IgnoreYValue || this.IgnoreYValue.length <= 0) return;
959
-
960
- var setValue = new Set(this.IgnoreYValue);
961
- this.Frame.HorizontalInfo = this.Frame.HorizontalInfo.filter(item => !setValue.has(item.Value));
962
- this.IsShowYZero = !setValue.has(0); //是否显示0刻度
963
- }
964
-
965
- this.DynamicMessageText=function()
966
- {
967
- if (this.SplitType==2)
968
- {
969
- for(var i=0;i<this.Frame.HorizontalInfo.length; ++i)
970
- {
971
- var item=this.Frame.HorizontalInfo[i];
972
- if (item.Message[0]) item.Message[0]+='%';
973
- if (item.Message[1]) item.Message[1]+='%';
974
- }
975
- }
976
- }
977
-
978
- this.IntegerCoordinateSplit2 = function (data) //整数分割
979
- {
980
- if (this.IntegerSplitData == null) this.IntegerSplitData = new IntegerSplitData();
981
- var splitItem = this.IntegerSplitData.Find(data.Interval);
982
- if (!splitItem) return false;
983
- if (data.Interval == splitItem.FixInterval) return true;
984
-
985
- var fixMax=data.Max, fixMin=data.Min;
986
- var maxValue=data.Max/splitItem.FixInterval;
987
- var minValue=data.Min/splitItem.FixInterval;
988
- //调整到整数倍数,不能整除的 +1
989
- if (IFrameSplitOperator.IsFloat(maxValue)) fixMax=parseInt((maxValue+0.5).toFixed(0))*splitItem.FixInterval;
990
- if (IFrameSplitOperator.IsFloat(minValue)) fixMin=parseInt((minValue-0.5).toFixed(0))*splitItem.FixInterval;
991
- if (data.Min == 0) fixMin = 0; //最小值是0 不用调整了.
992
- if (fixMin < 0 && data.Min > 0) fixMin = 0; //都是正数的, 最小值最小调整为0
993
-
994
- var count = 0;
995
- for (var i = fixMin; (i - fixMax) < 0.00000001; i += splitItem.FixInterval)
996
- {
997
- ++count;
998
- }
999
-
1000
- data.Interval = splitItem.FixInterval;
1001
- data.Max = fixMax;
1002
- data.Min = fixMin;
1003
- data.Count = count;
1004
-
1005
- return true;
1006
- }
1007
- }
1008
-
1009
- function FrameSplitKLineX()
1010
- {
1011
- this.newMethod = IFrameSplitOperator; //派生
1012
- this.newMethod();
1013
- delete this.newMethod;
1014
-
1015
- this.ShowText = true; //是否显示坐标信息
1016
- this.MinDistance = 12; //刻度间隔
1017
- this.Period; //周期
1018
- this.Symbol; //股票代码
1019
- this.MinTextDistance = 50;
1020
-
1021
- this.SplitDateTime = function () //根据时间分割
1022
- {
1023
- this.Frame.VerticalInfo = [];
1024
- var itemWidth = this.Frame.DistanceWidth + this.Frame.DataWidth;
1025
- var xOffset = this.Frame.Data.DataOffset;
1026
- var xPointCount = this.Frame.XPointCount;
1027
- var lastYear = null, lastMonth = null;
1028
- var textDistance = 0;
1029
-
1030
- for (var i = 0, index = xOffset; i < xPointCount && index < this.Frame.Data.Data.length; ++i, ++index)
1031
- {
1032
- textDistance += itemWidth;
1033
- var infoData = null;
1034
- if (i == 0)
1035
- {
1036
- var date = IFrameSplitOperator.FormatDateString(this.Frame.Data.Data[index].Date, 'MM-DD');
1037
- infoData = { Value: index - xOffset, Text: date };
1038
- }
1039
- else if (textDistance > this.MinTextDistance)
1040
- {
1041
- var time = IFrameSplitOperator.FormatTimeString(this.Frame.Data.Data[index].Time);
1042
- infoData = { Value: index - xOffset, Text: time };
1043
- }
1044
-
1045
- if (infoData)
1046
- {
1047
- var info = new CoordinateInfo();
1048
- info.Value = infoData.Value;
1049
- if (this.ShowText) info.Message[0] = infoData.Text;
1050
- if (info.Value==0) info.LineType=-1; //第1个分割线不画
1051
- this.Frame.VerticalInfo.push(info);
1052
- textDistance = 0;
1053
- if (i == 0) textDistance = -(this.MinTextDistance / 2);
1054
- }
1055
- }
1056
- }
1057
-
1058
- this.SplitSecond = function () //根据时间分割
1059
- {
1060
- this.Frame.VerticalInfo = [];
1061
- var itemWidth = this.Frame.DistanceWidth + this.Frame.DataWidth;
1062
- var xOffset = this.Frame.Data.DataOffset;
1063
- var xPointCount = this.Frame.XPointCount;
1064
- var lastYear = null, lastMonth = null;
1065
- var textDistance = 0;
1066
-
1067
- for (var i = 0, index = xOffset; i < xPointCount && index < this.Frame.Data.Data.length; ++i, ++index)
1068
- {
1069
- textDistance += itemWidth;
1070
- var infoData = null;
1071
- if (i == 0)
1072
- {
1073
- var date = IFrameSplitOperator.FormatDateString(this.Frame.Data.Data[index].Date, 'MM-DD');
1074
- infoData = { Value: index - xOffset, Text: date };
1075
- }
1076
- else if (textDistance > this.MinTextDistance)
1077
- {
1078
- var time = IFrameSplitOperator.FormatTimeString(this.Frame.Data.Data[index].Time,"HH:MM:SS");
1079
- infoData = { Value: index - xOffset, Text: time };
1080
- }
1081
-
1082
- if (infoData)
1083
- {
1084
- var info = new CoordinateInfo();
1085
- info.Value = infoData.Value;
1086
- if (this.ShowText) info.Message[0] = infoData.Text;
1087
- this.Frame.VerticalInfo.push(info);
1088
- textDistance = 0;
1089
- if (i == 0) textDistance = -(this.MinTextDistance / 2);
1090
- }
1091
- }
1092
- }
1093
-
1094
- this.SplitDate = function () //根据日期分割
1095
- {
1096
- this.Frame.VerticalInfo = [];
1097
- var xOffset = this.Frame.Data.DataOffset;
1098
- var xPointCount = this.Frame.XPointCount;
1099
- var lastYear = null, lastMonth = null;
1100
- var monthCount=0;
1101
-
1102
- for (var i = 0, index = xOffset, distance = this.MinDistance; i < xPointCount && index < this.Frame.Data.Data.length; ++i, ++index)
1103
- {
1104
- var year = parseInt(this.Frame.Data.Data[index].Date / 10000);
1105
- var month = parseInt(this.Frame.Data.Data[index].Date / 100) % 100;
1106
- if (lastMonth != month) ++monthCount;
1107
-
1108
- if ((distance < this.MinDistance && lastYear == year) ||
1109
- (lastYear != null && lastYear == year && lastMonth != null && lastMonth == month))
1110
- {
1111
- lastMonth = month;
1112
- ++distance;
1113
- continue;
1114
- }
1115
-
1116
- var info = new CoordinateInfo();
1117
- info.Value = index - xOffset;
1118
- //info.TextColor = "rgb(51,51,51)";
1119
- var text;
1120
- if (lastYear == null || lastYear != year)
1121
- {
1122
- text = year.toString();
1123
- }
1124
- else if (lastMonth == null || lastMonth != month)
1125
- {
1126
- text = month.toString() + "月";
1127
- }
1128
-
1129
- lastYear = year;
1130
- lastMonth = month;
1131
-
1132
- if (this.ShowText) info.Message[0] = text;
1133
- if (info.Value==0) info.LineType=-1; //第1个分割线不画
1134
-
1135
- this.Frame.VerticalInfo.push(info);
1136
- distance = 0;
1137
- }
1138
-
1139
- if (this.Period == 0 && monthCount <= 2)
1140
- this.SplitShortDate();
1141
- }
1142
-
1143
- //分隔在2个月一下的格式
1144
- this.SplitShortDate = function ()
1145
- {
1146
- this.Frame.VerticalInfo = [];
1147
- var xOffset = this.Frame.Data.DataOffset;
1148
- var xPointCount = this.Frame.XPointCount;
1149
- var minDistance = 12;
1150
- var isFirstYear = true;
1151
- for (var i = 0, index = xOffset, distance = minDistance; i < xPointCount && index < this.Frame.Data.Data.length; ++i, ++index)
1152
- {
1153
- var year = parseInt(this.Frame.Data.Data[index].Date / 10000);
1154
- //var month=parseInt(this.Frame.Data.Data[index].Date/100)%100;
1155
- //var day=parseInt(this.Frame.Data.Data[index].Date%100);
1156
-
1157
- if (distance < minDistance)
1158
- {
1159
- ++distance;
1160
- continue;
1161
- }
1162
-
1163
- var info = new CoordinateInfo();
1164
- info.Value = index - xOffset;
1165
- var text;
1166
- if (isFirstYear)
1167
- {
1168
- text = year.toString();
1169
- isFirstYear = false;
1170
- }
1171
- else
1172
- {
1173
- text = IFrameSplitOperator.FormatDateString(this.Frame.Data.Data[index].Date, 'MM-DD');
1174
- }
1175
-
1176
- if (this.ShowText) info.Message[0] = text;
1177
- if (info.Value==0) info.LineType=-1; //第1个分割线不画
1178
-
1179
- this.Frame.VerticalInfo.push(info);
1180
- distance = 0;
1181
- }
1182
-
1183
- if (this.Frame.VerticalInfo.length==1) //只有1个刻度, 就显示年+月
1184
- {
1185
- var item=this.Frame.VerticalInfo[0];
1186
- var index=item.Value+xOffset;
1187
- var kitem=this.Frame.Data.Data[index];
1188
- var text=IFrameSplitOperator.FormatDateString(kitem.Date,'YYYY-MM');
1189
- if (this.ShowText) item.Message[0]=text;
1190
- }
1191
- }
1192
-
1193
- this.Operator = function ()
1194
- {
1195
- if (this.Frame.Data == null) return;
1196
- if (FrameSplitKLineX.SplitCustom) FrameSplitKLineX.SplitCustom(this); //自定义分割
1197
- else if (ChartData.IsMinutePeriod(this.Period, true)) this.SplitDateTime();
1198
- else if (ChartData.IsSecondPeriod(this.Period)) this.SplitSecond();
1199
- else this.SplitDate();
1200
- }
1201
-
1202
- this.CreateCoordinateInfo=function()
1203
- {
1204
- return new CoordinateInfo(); //创建一个节点坐标
1205
- }
1206
- }
1207
-
1208
- //FrameSplitKLineX.SplitCustom=function(split) { }
1209
-
1210
- function FrameSplitMinutePriceY()
1211
- {
1212
- this.newMethod = IFrameSplitOperator; //派生
1213
- this.newMethod();
1214
- delete this.newMethod;
1215
-
1216
- this.High = null; //最高最低价
1217
- this.Low = null;
1218
-
1219
- this.YClose; //昨收
1220
- this.Data; //分钟数据
1221
- this.AverageData; //分钟均线数据
1222
- this.OverlayChartPaint;
1223
- this.SplitCount = 7;
1224
- this.Symbol;
1225
- this.SplitType=0; //0=默认根据最大最小值分割 1=涨跌停分割 2=数据最大最大值分割
1226
- this.DefaultSplitType=0;
1227
- this.LimitPrice; //{Max: Min:} 涨跌停价
1228
- this.Custom;
1229
-
1230
- this.Operator = function ()
1231
- {
1232
- this.Frame.HorizontalInfo = [];
1233
- this.Frame.CustomHorizontalInfo = [];
1234
- if (!this.Data) return;
1235
-
1236
- var range=this.GetMaxMin();
1237
-
1238
- if (this.Symbol && MARKET_SUFFIX_NAME.IsUSA(this.Symbol.toUpperCase()))
1239
- {
1240
- this.USASplit(range);
1241
- }
1242
- else if (this.SplitType==2)
1243
- {
1244
- this.USASplit(range);
1245
- }
1246
- else
1247
- {
1248
- this.DefaultSplit(range);
1249
- }
1250
-
1251
- this.CustomCoordinate();
1252
-
1253
- if (this.GetEventCallback)
1254
- {
1255
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_SPLIT_YCOORDINATE);
1256
- if (event && event.Callback)
1257
- {
1258
- var data={ID:this.Frame.Identify, Frame:this.Frame };
1259
- event.Callback(event,data,this);
1260
- }
1261
- }
1262
- }
1263
-
1264
- this.GetMaxMin = function () //计算图中所有的数据的最大最小值
1265
- {
1266
- var max = this.YClose;
1267
- var min = this.YClose;
1268
-
1269
- for (var i in this.Data.Data)
1270
- {
1271
- if (!this.Data.Data[i]) continue; //价格必须大于0
1272
- if (max < this.Data.Data[i]) max = this.Data.Data[i];
1273
- if (min > this.Data.Data[i]) min = this.Data.Data[i];
1274
- }
1275
-
1276
- if (this.AverageData)
1277
- {
1278
- for (var i in this.AverageData.Data)
1279
- {
1280
- if (!this.AverageData.Data[i]) continue; //价格必须大于0
1281
- if (max < this.AverageData.Data[i]) max = this.AverageData.Data[i];
1282
- if (min > this.AverageData.Data[i]) min = this.AverageData.Data[i];
1283
- }
1284
- }
1285
-
1286
- if (this.OverlayChartPaint && this.OverlayChartPaint.length > 0 && this.OverlayChartPaint[0] && this.OverlayChartPaint[0].Symbol)
1287
- {
1288
- var range = this.OverlayChartPaint[0].GetMaxMin();
1289
- if (range.Max && range.Max > max) max = range.Max;
1290
- if (range.Min && range.Min < min) min = range.Min;
1291
- }
1292
-
1293
- if (this.SplitType==1 && this.LimitPrice)
1294
- {
1295
- if (max<this.LimitPrice.Max) max=this.LimitPrice.Max;
1296
- if (min>this.LimitPrice.Min) min=this.LimitPrice.Min;
1297
- }
1298
-
1299
- if (IFrameSplitOperator.IsNumber(this.High) && IFrameSplitOperator.IsNumber(this.Low))
1300
- {
1301
- if (max < this.High) max = this.High;
1302
- if (min > this.Low) min = this.Low;
1303
- }
1304
-
1305
- //叠加指标
1306
- var overlayRange=this.GetOverlayMaxMin();
1307
- if (overlayRange)
1308
- {
1309
- if (IFrameSplitOperator.IsNumber(overlayRange.Max) && overlayRange.Max>max) max=overlayRange.Max;
1310
- if (IFrameSplitOperator.IsNumber(overlayRange.Min) && overlayRange.Min<min) min=overlayRange.Min;
1311
- }
1312
-
1313
- return { Max: max, Min: min };
1314
- }
1315
-
1316
- //获取共享Y轴叠加指标最大,最小值
1317
- this.GetOverlayMaxMin=function()
1318
- {
1319
- if (!this.HQChart) return null;
1320
- if (!this.HQChart.Frame || !this.HQChart.Frame.SubFrame) return null;
1321
- var subFrame=this.HQChart.Frame.SubFrame[0];
1322
- if (!subFrame) return null;
1323
- if (!IFrameSplitOperator.IsNonEmptyArray(subFrame.OverlayIndex)) return null;
1324
-
1325
- var range={ Max:null, Min:null };
1326
- for(var i=0;i<subFrame.OverlayIndex.length;++i)
1327
- {
1328
- var item=subFrame.OverlayIndex[i];
1329
- if (!item || !item.Frame) continue;
1330
- var overlayFrame=item.Frame;
1331
- if (overlayFrame.IsShareY!=true) continue;
1332
- if (overlayFrame.IsCalculateYMaxMin===false) continue; //叠加坐标Y轴不调整
1333
- for(var j=0;j<item.ChartPaint.length; ++j)
1334
- {
1335
- var paint=item.ChartPaint[j];
1336
- if (paint.IsShow==false) continue;
1337
-
1338
- var value=paint.GetMaxMin();
1339
- if (value==null || value.Max==null || value.Min==null) continue;
1340
-
1341
- if (range.Max==null || range.Max<value.Max) range.Max=value.Max;
1342
- if (range.Min==null || range.Min>value.Min ) range.Min=value.Min;
1343
- }
1344
- }
1345
-
1346
- return range;
1347
- }
1348
-
1349
- this.USASplit=function(range)
1350
- {
1351
- var max=range.Max;
1352
- var min=range.Min;
1353
-
1354
- if (max==min)
1355
- {
1356
- max=max+max*0.1;
1357
- min=min-min*0.1;
1358
- }
1359
- else
1360
- {
1361
- var height=this.Frame.ChartBorder.GetHeight(); //画布的高度
1362
- var spacePrice=5*(max-min)/height;
1363
- max+=spacePrice;
1364
- min-=spacePrice;
1365
- if (min<0) min=range.Min;
1366
- }
1367
-
1368
- var showCount=this.SplitCount;
1369
- var distance=(max-min)/(showCount-1);
1370
- const minDistance=[1, 0.1, 0.01, 0.001, 0.0001];
1371
- var defaultfloatPrecision=JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
1372
- if (distance<minDistance[defaultfloatPrecision])
1373
- {
1374
- distance=minDistance[defaultfloatPrecision];
1375
- max=min+distance*showCount;
1376
- //min=this.YClose-(distance*(showCount-1)/2);
1377
- }
1378
-
1379
- for(var i=0;i<showCount;++i)
1380
- {
1381
- var price=min+(distance*i);
1382
- if (this.YClose && price==this.YClose) continue;
1383
- var coordinate=new CoordinateInfo();
1384
- coordinate.Value=price;
1385
- var strPrice=price.toFixed(defaultfloatPrecision); //价格刻度字符串
1386
- if (this.IsShowLeftText) coordinate.Message[0]=strPrice;
1387
-
1388
- if (this.YClose)
1389
- {
1390
- var per=(price/this.YClose-1)*100;
1391
- if (per>0) coordinate.TextColor=g_JSChartResource.UpTextColor;
1392
- else if (per<0) coordinate.TextColor=g_JSChartResource.DownTextColor;
1393
- if (this.IsShowRightText)
1394
- {
1395
- if (this.RightTextFormat==1) coordinate.Message[1]=strPrice;
1396
- else coordinate.Message[1]=IFrameSplitOperator.FormatValueString(per,2)+'%'; //百分比
1397
- }
1398
- }
1399
-
1400
- this.Frame.HorizontalInfo.push(coordinate);
1401
- }
1402
-
1403
- if (this.YClose>min && this.YClose<max) //前收盘线
1404
- {
1405
- var coordinate=new CoordinateInfo();
1406
- coordinate.Value=this.YClose;
1407
- coordinate.LineType=2;//中间的线画虚线
1408
- if (g_JSChartResource.FrameDotSplitPen) coordinate.LineColor=g_JSChartResource.FrameDotSplitPen;
1409
-
1410
- var strPrice=this.YClose.toFixed(defaultfloatPrecision); //价格刻度字符串
1411
- if (this.IsShowLeftText) coordinate.Message[0]=strPrice;
1412
-
1413
- if (this.IsShowRightText)
1414
- {
1415
- if (this.RightTextFormat==1) coordinate.Message[1]=strPrice;
1416
- else coordinate.Message[1]='0.00%'; //百分比
1417
- }
1418
-
1419
- this.Frame.HorizontalInfo.push(coordinate);
1420
- }
1421
-
1422
- this.Frame.HorizontalInfo.sort(function(a,b) { return a.Value-b.Value; });
1423
-
1424
- this.Frame.HorizontalMax=max;
1425
- this.Frame.HorizontalMin=min;
1426
- }
1427
-
1428
- this.DefaultSplit = function (range)
1429
- {
1430
- var max = range.Max;
1431
- var min = range.Min;
1432
-
1433
- if (this.YClose == max && this.YClose == min)
1434
- {
1435
- max = this.YClose + this.YClose * 0.1;
1436
- min = this.YClose - this.YClose * 0.1;
1437
- }
1438
- else
1439
- {
1440
- var distanceValue = Math.max(Math.abs(this.YClose - max), Math.abs(this.YClose - min));
1441
- max = this.YClose + distanceValue;
1442
- min = this.YClose - distanceValue;
1443
- if (min<0) min=range.Min;
1444
- }
1445
-
1446
- var showCount = this.SplitCount;
1447
- var distance = (max - min) / (showCount - 1);
1448
- const minDistance = [1, 0.1, 0.01, 0.001, 0.0001];
1449
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);; //默认小数位数
1450
- if (JSCommonCoordinateData.MARKET_SUFFIX_NAME.IsSHSZIndex(this.Symbol)) defaultfloatPrecision = 0; //手机端指数不显示小数位数,太长了
1451
-
1452
- if (distance < minDistance[defaultfloatPrecision])
1453
- {
1454
- distance = minDistance[defaultfloatPrecision];
1455
- max = this.YClose + (distance * (showCount - 1) / 2);
1456
- min = this.YClose - (distance * (showCount - 1) / 2);
1457
- }
1458
-
1459
- for (var i = 0; i < showCount; ++i)
1460
- {
1461
- var price = min + (distance * i);
1462
- var coordinate=new CoordinateInfo();
1463
- this.Frame.HorizontalInfo[i] = coordinate;
1464
-
1465
- coordinate.Value = price;
1466
- coordinate.Message[0] = price.toFixed(defaultfloatPrecision);
1467
-
1468
- if (IFrameSplitOperator.IsNumber(this.YClose))
1469
- {
1470
- var per = (price / this.YClose - 1) * 100;
1471
- if (per > 0) coordinate.TextColor = g_JSChartResource.UpTextColor;
1472
- else if (per < 0) coordinate.TextColor = g_JSChartResource.DownTextColor;
1473
- coordinate.Message[1] = IFrameSplitOperator.FormatValueString(per, 2) + '%'; //百分比
1474
-
1475
- if (Math.abs(price-this.YClose) <0.00000000001) //小数有精度问题 使用差值
1476
- {
1477
- coordinate.LineType=2;//中间的线画虚线
1478
- coordinate.TextColor=g_JSChartResource.UnchagneTextColor;
1479
- if (g_JSChartResource.FrameDotSplitPen) coordinate.LineColor=g_JSChartResource.FrameDotSplitPen;
1480
- }
1481
- }
1482
- }
1483
-
1484
- this.Frame.HorizontalMax = max;
1485
- this.Frame.HorizontalMin = min;
1486
- }
1487
-
1488
- this.CustomCoordinate = function () //自定义刻度
1489
- {
1490
- if (!this.Custom) return;
1491
-
1492
- for (var i in this.Custom)
1493
- {
1494
- var item = this.Custom[i];
1495
- if (item.Type == 1)
1496
- this.CustomFixedCoordinate(item);
1497
- else if (item.Type==0)
1498
- {
1499
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
1500
- var latestItem = this.GetLatestPrice(defaultfloatPrecision, item);
1501
- if (latestItem) this.Frame.CustomHorizontalInfo.push(latestItem);
1502
- }
1503
- }
1504
- }
1505
-
1506
- this.GetLatestPrice = function (floatPrecision, option)
1507
- {
1508
- if (!this.Data || !this.Data.Data) return null;
1509
- if (this.Data.Data.length <= 0) return null;
1510
- var price = this.Data.Data[this.Data.Data.length - 1];
1511
- if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(this.YClose)) return null;
1512
-
1513
- var info = new CoordinateInfo();
1514
- info.Type = 0;
1515
- info.Value = price;
1516
- info.TextColor = g_JSChartResource.FrameLatestPrice.TextColor;
1517
- info.LineType = 2; //虚线
1518
- if (option.Position == 'left') info.Message[0] = price.toFixed(floatPrecision);
1519
- else info.Message[1] = price.toFixed(floatPrecision);
1520
- if (price > this.YClose) info.LineColor = g_JSChartResource.FrameLatestPrice.UpBarColor;
1521
- else if (price < this.YClose) info.LineColor = g_JSChartResource.FrameLatestPrice.DownBarColor;
1522
- else info.LineColor = g_JSChartResource.FrameLatestPrice.UnchagneBarColor;
1523
-
1524
- if (IFrameSplitOperator.IsNumber(option.LineType)) info.LineType=option.LineType;
1525
- if (option.IsShowLine == false) info.LineType = -1;
1526
-
1527
- return info;
1528
- }
1529
-
1530
- this.CustomFixedCoordinate = function (option) //固定坐标刻度
1531
- {
1532
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
1533
- for (var i in option.Data)
1534
- {
1535
- var item = option.Data[i];
1536
- var info = new CoordinateInfo();
1537
- info.Type = 1;
1538
- info.TextColor = item.TextColor;
1539
- info.LineColor = item.Color;
1540
- info.LineType = 2; //虚线
1541
- if (IFrameSplitOperator.IsNumber(option.LineType)) info.LineType=option.LineType;
1542
- if (option.IsShowLine == false) info.LineType = -1;
1543
-
1544
- if (IFrameSplitOperator.IsNumber(item.Increase)) //涨幅计算价格
1545
- {
1546
- if (!IFrameSplitOperator.IsNumber(this.YClose)) continue;
1547
- info.Value = this.YClose * (1 + item.Increase);
1548
- }
1549
- else
1550
- {
1551
- info.Value = item.Value;
1552
- }
1553
-
1554
- var text;
1555
- if (item.Text) text = item.Text;
1556
- else text = info.Value.toFixed(defaultfloatPrecision);
1557
- if (option.Position == 'left') info.Message[0] = text;
1558
- else info.Message[1] = text;
1559
-
1560
- this.Frame.CustomHorizontalInfo.push(info);
1561
- }
1562
- }
1563
-
1564
- }
1565
-
1566
- function FrameSplitMinuteX()
1567
- {
1568
- this.newMethod = IFrameSplitOperator; //派生
1569
- this.newMethod();
1570
- delete this.newMethod;
1571
-
1572
- this.ShowText = true; //是否显示坐标信息
1573
- this.Symbol = null; //股票代码 x轴刻度根据股票类型来调整
1574
- this.DayCount = 1;
1575
- this.DayData;
1576
-
1577
- this.Operator = function ()
1578
- {
1579
- this.Frame.VerticalInfo = [];
1580
- var xPointCount = this.Frame.XPointCount;
1581
- var width = this.Frame.ChartBorder.GetWidth();
1582
- var isHScreen = (this.Frame.IsHScreen === true);
1583
- if (isHScreen) width = this.Frame.ChartBorder.GetHeight();
1584
-
1585
- const minuteCoordinate = JSCommonCoordinateData.MinuteCoordinateData;
1586
- var xcoordinateData = minuteCoordinate.GetCoordinateData(this.Symbol, width);
1587
- var minuteCount = xcoordinateData.Count;
1588
- var minuteMiddleCount = xcoordinateData.MiddleCount > 0 ? xcoordinateData.MiddleCount : parseInt(minuteCount / 2);;
1589
-
1590
- var xcoordinate = xcoordinateData.Data;
1591
- this.Frame.XPointCount = 243;
1592
-
1593
- this.Frame.XPointCount = minuteCount * this.DayCount;
1594
- this.Frame.MinuteCount = minuteCount;
1595
- this.Frame.VerticalInfo = [];
1596
-
1597
- if (this.DayCount <= 1)
1598
- {
1599
- for (var i in xcoordinate)
1600
- {
1601
- var info = new CoordinateInfo();
1602
- //info.TextColor = "rgb(51,51,51)";
1603
- info.Value = xcoordinate[i][0];
1604
- if (this.ShowText)
1605
- info.Message[0] = xcoordinate[i][3];
1606
- this.Frame.VerticalInfo[i] = info;
1607
- }
1608
- }
1609
- else
1610
- {
1611
- for (var i = this.DayData.length - 1, j = 0; i >= 0; --i, ++j)
1612
- {
1613
- var info = new CoordinateInfo();
1614
- info.Value = j * minuteCount + minuteMiddleCount;
1615
- info.LineType = -1;
1616
- if (this.ShowText) info.Message[0] = IFrameSplitOperator.FormatDateString(this.DayData[i].Date, 'MM-DD');
1617
- this.Frame.VerticalInfo.push(info);
1618
-
1619
- var info = new CoordinateInfo();
1620
- info.Value = (j + 1) * minuteCount;
1621
- this.Frame.VerticalInfo.push(info);
1622
- }
1623
- }
1624
- }
1625
- }
1626
-
1627
- function FrameSplitXData()
1628
- {
1629
- this.newMethod = IFrameSplitOperator; //派生
1630
- this.newMethod();
1631
- delete this.newMethod;
1632
-
1633
- this.ShowText = true; //是否显示坐标信息
1634
-
1635
- this.Operator = function ()
1636
- {
1637
- if (this.Frame.Data == null || this.Frame.XData == null) return;
1638
- this.Frame.VerticalInfo = [];
1639
- var xOffset = this.Frame.Data.DataOffset;
1640
- var xPointCount = this.Frame.XPointCount;
1641
-
1642
- for (var i = 0, index = xOffset; i < xPointCount && index < this.Frame.Data.Data.length; ++i, ++index)
1643
- {
1644
- var info = new CoordinateInfo();
1645
- info.Value = index - xOffset;
1646
-
1647
- if (this.ShowText)
1648
- info.Message[0] = this.Frame.XData[i];
1649
-
1650
- this.Frame.VerticalInfo.push(info);
1651
- }
1652
- }
1653
- }
1654
-
1655
- //深度图X轴价格信息
1656
- function FrameSplitXDepth()
1657
- {
1658
- this.newMethod=IFrameSplitOperator; //派生
1659
- this.newMethod();
1660
- delete this.newMethod;
1661
-
1662
- this.ShowText=true; //是否显示坐标信息
1663
- this.SplitCount=3;
1664
- this.Symbol;
1665
- this.LineType=3;
1666
-
1667
- this.Operator=function()
1668
- {
1669
- var xRange=this.Frame.VerticalRange;
1670
- if (!xRange) return;
1671
- this.Frame.VerticalInfo=[];
1672
-
1673
- var floatPrecision=2;
1674
- if (this.Symbol) floatPrecision=JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
1675
- var xMax=xRange.Max;
1676
- var xMin=xRange.Min;
1677
- if (xRange.Bid)
1678
- {
1679
- var interval=(xRange.Bid.Max-xMin)/this.SplitCount;
1680
- for(var i=0;i<this.SplitCount;++i)
1681
- {
1682
- var info= new CoordinateInfo();
1683
- info.Value=xMin+(interval*i);
1684
- if (info.Value<=0) continue;
1685
- if (IFrameSplitOperator.IsNumber(this.LineType)) info.LineType=this.LineType;
1686
- if (this.ShowText) info.Message[0]=info.Value.toFixed(floatPrecision);
1687
- this.Frame.VerticalInfo.push(info);
1688
- }
1689
- }
1690
-
1691
- var info=new CoordinateInfo();
1692
- info.Value=xRange.Center;
1693
- this.Frame.VerticalInfo.push(info);
1694
-
1695
- if (xRange.Ask)
1696
- {
1697
- var interval=(xMax-xRange.Ask.Min)/this.SplitCount;
1698
- for(var i=1;i<=this.SplitCount;++i)
1699
- {
1700
- var info= new CoordinateInfo();
1701
- info.Value=xRange.Ask.Min+(interval*i);
1702
- if (IFrameSplitOperator.IsNumber(this.LineType)) info.LineType=this.LineType;
1703
- if (this.ShowText) info.Message[0]=info.Value.toFixed(floatPrecision);
1704
- this.Frame.VerticalInfo.push(info);
1705
- }
1706
- }
1707
-
1708
- if (this.GetEventCallback)
1709
- {
1710
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_SPLIT_XCOORDINATE);
1711
- if (event && event.Callback)
1712
- {
1713
- var data={ID:this.Frame.Identify, Frame:this.Frame };
1714
- event.Callback(event,data,this);
1715
- }
1716
- }
1717
- }
1718
- }
1719
-
1720
- /////////////////////////////////////////////////////////////////////////////////////////////////////////
1721
- // 数据分割
1722
- // [0]=Start起始 [1]=End结束 [2]=FixInterval修正的间隔 [3]=Increase
1723
- //
1724
- function SplitData() {
1725
- this.Data = [
1726
- [0.000001, 0.000002, 0.000001, 0.0000001],
1727
- [0.000002, 0.000004, 0.000002, 0.0000002],
1728
- [0.000004, 0.000005, 0.000004, 0.0000001],
1729
- [0.000005, 0.00001, 0.000005, 0.0000005],
1730
-
1731
- [0.00001, 0.00002, 0.00001, 0.000001],
1732
- [0.00002, 0.00004, 0.00002, 0.000002],
1733
- [0.00004, 0.00005, 0.00004, 0.000001],
1734
- [0.00005, 0.0001, 0.00005, 0.000005],
1735
-
1736
- [0.0001, 0.0002, 0.0001, 0.00001],
1737
- [0.0002, 0.0004, 0.0002, 0.00002],
1738
- [0.0004, 0.0005, 0.0004, 0.00001],
1739
- [0.0005, 0.001, 0.0005, 0.00005],
1740
-
1741
- [0.001, 0.002, 0.001, 0.0001],
1742
- [0.002, 0.004, 0.002, 0.0002],
1743
- [0.004, 0.005, 0.004, 0.0001],
1744
- [0.005, 0.01, 0.005, 0.0005],
1745
-
1746
- [0.01, 0.02, 0.01, 0.001],
1747
- [0.02, 0.04, 0.02, 0.002],
1748
- [0.04, 0.05, 0.04, 0.001],
1749
- [0.05, 0.1, 0.05, 0.005],
1750
-
1751
- [0.1, 0.2, 0.1, 0.01],
1752
- [0.2, 0.4, 0.2, 0.02],
1753
- [0.4, 0.5, 0.4, 0.01],
1754
- [0.5, 1, 0.5, 0.05],
1755
-
1756
- [1, 2, 1, 0.05],
1757
- [2, 4, 2, 0.05],
1758
- [4, 5, 4, 0.05],
1759
- [5, 10, 5, 0.05],
1760
-
1761
- [10, 20, 10, 2],
1762
- [20, 40, 20, 5],
1763
- [40, 50, 40, 2],
1764
- [50, 100, 50, 10],
1765
-
1766
- [100, 200, 100, 10],
1767
- [200, 400, 200, 20],
1768
- [400, 500, 400, 10],
1769
- [500, 1000, 500, 50],
1770
-
1771
- [1000, 2000, 1000, 50],
1772
- [2000, 4000, 2000, 50],
1773
- [4000, 5000, 4000, 50],
1774
- [5000, 10000, 5000, 100],
1775
-
1776
- [10000, 20000, 10000, 1000],
1777
- [20000, 40000, 20000, 2000],
1778
- [40000, 50000, 40000, 1000],
1779
- [50000, 100000, 50000, 5000],
1780
-
1781
- [100000, 200000, 100000, 10000],
1782
- [200000, 400000, 200000, 20000],
1783
- [400000, 500000, 400000, 10000],
1784
- [500000, 1000000, 500000, 50000],
1785
-
1786
- [1000000, 2000000, 1000000, 100000],
1787
- [2000000, 4000000, 2000000, 200000],
1788
- [4000000, 5000000, 4000000, 100000],
1789
- [5000000, 10000000, 5000000, 500000],
1790
-
1791
- [10000000, 20000000, 10000000, 1000000],
1792
- [20000000, 40000000, 20000000, 2000000],
1793
- [40000000, 50000000, 40000000, 1000000],
1794
- [50000000, 100000000, 50000000, 5000000],
1795
-
1796
- [100000000, 200000000, 100000000, 10000000],
1797
- [200000000, 400000000, 100000000, 10000000],
1798
- [400000000, 500000000, 100000000, 10000000],
1799
- [500000000, 1000000000, 100000000, 10000000],
1800
-
1801
- [1000000000, 2000000000, 1000000000, 100000000],
1802
- [2000000000, 4000000000, 2000000000, 200000000],
1803
- [4000000000, 5000000000, 4000000000, 100000000],
1804
- [5000000000, 10000000000, 5000000000, 500000000],
1805
- ];
1806
-
1807
- this.Find = function (interval) {
1808
- for (var i in this.Data) {
1809
- var item = this.Data[i];
1810
- if (interval > item[0] && interval <= item[1]) {
1811
- var result = {};
1812
- result.FixInterval = item[2];
1813
- result.Increase = item[3];
1814
- return result;
1815
- }
1816
- }
1817
-
1818
- return null;
1819
- }
1820
- }
1821
-
1822
- function PriceSplitData() {
1823
- this.newMethod = SplitData; //派生
1824
- this.newMethod();
1825
- delete this.newMethod;
1826
-
1827
- this.Data = [
1828
- [0.000001, 0.000002, 0.000001, 0.0000001],
1829
- [0.000002, 0.000004, 0.000002, 0.0000002],
1830
- [0.000004, 0.000005, 0.000004, 0.0000001],
1831
- [0.000005, 0.00001, 0.000005, 0.0000005],
1832
-
1833
- [0.00001, 0.00002, 0.00001, 0.000001],
1834
- [0.00002, 0.00004, 0.00002, 0.000002],
1835
- [0.00004, 0.00005, 0.00004, 0.000001],
1836
- [0.00005, 0.0001, 0.00005, 0.000005],
1837
-
1838
- [0.0001, 0.0002, 0.0001, 0.00001],
1839
- [0.0002, 0.0004, 0.0002, 0.00002],
1840
- [0.0004, 0.0005, 0.0004, 0.00001],
1841
- [0.0005, 0.001, 0.0005, 0.00005],
1842
-
1843
- [0.001, 0.002, 0.001, 0.0001],
1844
- [0.002, 0.004, 0.002, 0.0002],
1845
- [0.004, 0.005, 0.004, 0.0001],
1846
- [0.005, 0.01, 0.005, 0.0005],
1847
-
1848
- [0.01, 0.02, 0.01, 0.001],
1849
- [0.02, 0.04, 0.02, 0.002],
1850
- [0.04, 0.05, 0.04, 0.001],
1851
- [0.05, 0.1, 0.05, 0.005],
1852
-
1853
- [0.1, 0.2, 0.1, 0.01],
1854
- [0.2, 0.4, 0.2, 0.02],
1855
- [0.4, 0.5, 0.2, 0.01],
1856
- [0.5, 0.8, 0.2, 0.05],
1857
- [0.8, 1, 0.5, 0.05],
1858
-
1859
- [1, 2, 0.5, 0.05],
1860
- [2, 4, 0.5, 0.05],
1861
- [4, 5, 0.5, 0.05],
1862
- [5, 10, 0.5, 0.05],
1863
-
1864
- [10, 12, 10, 2],
1865
- [20, 40, 20, 5],
1866
- [40, 50, 40, 2],
1867
- [50, 100, 50, 10],
1868
-
1869
- [100, 200, 100, 10],
1870
- [200, 400, 200, 20],
1871
- [400, 500, 400, 10],
1872
- [500, 1000, 500, 50],
1873
-
1874
- [1000, 2000, 1000, 50],
1875
- [2000, 4000, 2000, 50],
1876
- [4000, 5000, 4000, 50],
1877
- [5000, 10000, 5000, 100],
1878
-
1879
- [10000, 20000, 10000, 1000],
1880
- [20000, 40000, 20000, 2000],
1881
- [40000, 50000, 40000, 1000],
1882
- [50000, 100000, 50000, 5000],
1883
-
1884
- [100000, 200000, 100000, 10000],
1885
- [200000, 400000, 200000, 20000],
1886
- [400000, 500000, 400000, 10000],
1887
- [500000, 1000000, 500000, 50000],
1888
-
1889
- [1000000, 2000000, 1000000, 100000],
1890
- [2000000, 4000000, 2000000, 200000],
1891
- [4000000, 5000000, 4000000, 100000],
1892
- [5000000, 10000000, 5000000, 500000],
1893
-
1894
- [10000000, 20000000, 10000000, 1000000],
1895
- [20000000, 40000000, 20000000, 2000000],
1896
- [40000000, 50000000, 40000000, 1000000],
1897
- [50000000, 100000000, 50000000, 5000000],
1898
-
1899
- [100000000, 200000000, 100000000, 10000000],
1900
- [200000000, 400000000, 200000000, 20000000],
1901
- [400000000, 500000000, 400000000, 10000000],
1902
- [500000000, 1000000000, 500000000, 50000000],
1903
-
1904
- [1000000000, 2000000000, 1000000000, 100000000],
1905
- [2000000000, 4000000000, 2000000000, 200000000],
1906
- [4000000000, 5000000000, 4000000000, 100000000],
1907
- [5000000000, 10000000000, 5000000000, 500000000],
1908
- ];
1909
- }
1910
-
1911
- //整数分割
1912
- function IntegerSplitData() {
1913
- this.newMethod = SplitData; //派生
1914
- this.newMethod();
1915
- delete this.newMethod;
1916
-
1917
- this.Data =
1918
- [
1919
- [0.000001, 0.000002, 0.000001, 0.0000001],
1920
- [0.000002, 0.000004, 0.000002, 0.0000002],
1921
- [0.000004, 0.000005, 0.000004, 0.0000001],
1922
- [0.000005, 0.00001, 0.000005, 0.0000005],
1923
-
1924
- [0.00001, 0.00002, 0.00001, 0.000001],
1925
- [0.00002, 0.00004, 0.00002, 0.000002],
1926
- [0.00004, 0.00005, 0.00004, 0.000001],
1927
- [0.00005, 0.0001, 0.00005, 0.000005],
1928
-
1929
- [0.0001, 0.0002, 0.0001, 0.00001],
1930
- [0.0002, 0.0004, 0.0002, 0.00002],
1931
- [0.0004, 0.0005, 0.0004, 0.00001],
1932
- [0.0005, 0.001, 0.0005, 0.00005],
1933
-
1934
- [0.001, 0.002, 0.001, 0.0001],
1935
- [0.002, 0.004, 0.002, 0.0002],
1936
- [0.004, 0.005, 0.004, 0.0001],
1937
- [0.005, 0.01, 0.005, 0.0005],
1938
-
1939
- [0.01, 0.02, 0.01, 0.001],
1940
- [0.02, 0.04, 0.02, 0.002],
1941
- [0.04, 0.05, 0.04, 0.001],
1942
- [0.05, 0.1, 0.05, 0.005],
1943
-
1944
- [0.1, 0.2, 1, 1],
1945
- [0.2, 0.4, 1, 1],
1946
- [0.4, 0.5, 1, 1],
1947
- [0.5, 0.8, 1, 1],
1948
- [0.8, 1, 1, 1],
1949
-
1950
- [1, 2, 1, 1],
1951
- [2, 4, 2, 1],
1952
- [4, 5, 4, 1],
1953
- [5, 10, 5, 1],
1954
-
1955
- [10, 12, 10, 2],
1956
- [20, 40, 20, 5],
1957
- [40, 50, 40, 2],
1958
- [50, 100, 50, 10],
1959
-
1960
- [100, 200, 100, 10],
1961
- [200, 400, 200, 20],
1962
- [400, 500, 400, 10],
1963
- [500, 1000, 500, 50],
1964
-
1965
- [1000, 2000, 1000, 50],
1966
- [2000, 4000, 2000, 50],
1967
- [4000, 5000, 4000, 50],
1968
- [5000, 10000, 5000, 100],
1969
-
1970
- [10000, 20000, 10000, 1000],
1971
- [20000, 40000, 20000, 2000],
1972
- [40000, 50000, 40000, 1000],
1973
- [50000, 100000, 50000, 5000],
1974
-
1975
- [100000, 200000, 100000, 10000],
1976
- [200000, 400000, 200000, 20000],
1977
- [400000, 500000, 400000, 10000],
1978
- [500000, 1000000, 500000, 50000],
1979
-
1980
- [1000000, 2000000, 1000000, 100000],
1981
- [2000000, 4000000, 2000000, 200000],
1982
- [4000000, 5000000, 4000000, 100000],
1983
- [5000000, 10000000, 5000000, 500000],
1984
-
1985
- [10000000, 20000000, 10000000, 1000000],
1986
- [20000000, 40000000, 20000000, 2000000],
1987
- [40000000, 50000000, 40000000, 1000000],
1988
- [50000000, 100000000, 50000000, 5000000],
1989
-
1990
- [100000000, 200000000, 100000000, 10000000],
1991
- [200000000, 400000000, 200000000, 20000000],
1992
- [400000000, 500000000, 400000000, 10000000],
1993
- [500000000, 1000000000, 500000000, 50000000],
1994
-
1995
- [1000000000, 2000000000, 1000000000, 100000000],
1996
- [2000000000, 4000000000, 2000000000, 200000000],
1997
- [4000000000, 5000000000, 4000000000, 100000000],
1998
- [5000000000, 10000000000, 5000000000, 500000000],
1999
- ];
2000
- }
2001
-
2002
-
2003
- /////////////////////////////////////////////////////////////////////////////////
2004
- //
2005
- function IChangeStringFormat() {
2006
- this.Data;
2007
- this.Value; //数据
2008
- this.Text; //输出字符串
2009
-
2010
- this.Operator = function () {
2011
- return false;
2012
- }
2013
- }
2014
-
2015
-
2016
- function HQPriceStringFormat()
2017
- {
2018
- this.newMethod = IChangeStringFormat; //派生
2019
- this.newMethod();
2020
- delete this.newMethod;
2021
-
2022
- this.Symbol;
2023
- this.FrameID;
2024
- this.LanguageID = JSCHART_LANGUAGE_ID.LANGUAGE_CHINESE_ID;
2025
- this.PercentageText; //百分比
2026
- this.RValue; //右边值
2027
- this.RText;
2028
- this.RComplexText; //{ Space:2 间距, Text:[ {Color:, Text: }] } 支持单行多颜色
2029
-
2030
- this.PriceFormatType=0; //主窗口格式 0=默认 1=科学计数
2031
- this.DataFormatType=0; //副图指标格式 0=默认 1=科学计数
2032
-
2033
- this.Operator = function ()
2034
- {
2035
- this.RText = null;
2036
- this.RComplexText=null;
2037
- if (IFrameSplitOperator.IsString(this.RValue)) this.RText = this.RValue;
2038
- if (!this.Value) return false;
2039
-
2040
- var defaultfloatPrecision = 2; //价格小数位数
2041
- if (this.FrameID == 0) //第1个窗口显示原始价格
2042
- {
2043
- var defaultfloatPrecision = JSCommonCoordinateData.GetfloatPrecision(this.Symbol);
2044
-
2045
- if (this.PriceFormatType==1)
2046
- this.Text=IFrameSplitOperator.FormatValueThousandsString(this.Value,defaultfloatPrecision);
2047
- else
2048
- this.Text = this.Value.toFixed(defaultfloatPrecision);
2049
-
2050
- if (this.YClose>0) this.PercentageText=((this.Value-this.YClose)*100/this.YClose).toFixed(2); //走势图右边坐标显示百分比
2051
- }
2052
- else
2053
- {
2054
- if (this.DataFormatType==1)
2055
- this.Text=IFrameSplitOperator.FormatValueThousandsString(this.Value,defaultfloatPrecision);
2056
- else
2057
- this.Text = IFrameSplitOperator.FormatValueString(this.Value, defaultfloatPrecision, this.LanguageID);
2058
- }
2059
-
2060
- if (this.GetEventCallback)
2061
- {
2062
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_FORMAT_CORSSCURSOR_Y_TEXT);
2063
- if (event)
2064
- {
2065
- var data={ Value:this.Value, FrameID:this.FrameID };
2066
- event.Callback(event,data,this);
2067
- }
2068
- }
2069
-
2070
- return true;
2071
- }
2072
- }
2073
-
2074
- function HQDateStringFormat()
2075
- {
2076
- this.newMethod = IChangeStringFormat; //派生
2077
- this.newMethod();
2078
- delete this.newMethod;
2079
-
2080
- this.DateFormatType=0; //0=YYYY-MM-DD 1=YYYY/MM/DD 2=YYYY/MM/DD/W 3=DD/MM/YYYY
2081
- this.LanguageID=0;
2082
-
2083
- this.Operator = function ()
2084
- {
2085
- if (!IFrameSplitOperator.IsNumber(this.Value) || this.Value<0) return false;
2086
- if (!this.Data) return false;
2087
-
2088
- var index = this.Value;
2089
- index = parseInt(index.toFixed(0));
2090
- if (this.Data.DataOffset + index >= this.Data.Data.length) return false;
2091
-
2092
- var currentData = this.Data.Data[this.Data.DataOffset + index];
2093
- var date = currentData.Date;
2094
- var dateFormatString="YYYY-MM-DD";
2095
- if (this.DateFormatType==1) dateFormatString="YYYY/MM/DD";
2096
- else if (this.DateFormatType==2) dateFormatString="YYYY/MM/DD/W";
2097
- else if (this.DateFormatType==3) dateFormatString="DD/MM/YYYY";
2098
- this.Text = IFrameSplitOperator.FormatDateString(date,dateFormatString,this.LanguageID);
2099
- if (ChartData.IsMinutePeriod(this.Data.Period, true)) // 分钟周期
2100
- {
2101
- var time = IFrameSplitOperator.FormatTimeString(currentData.Time);
2102
- this.Text = this.Text + " " + time;
2103
- }
2104
- else if (ChartData.IsSecondPeriod(this.Data.Period))
2105
- {
2106
- var time = IFrameSplitOperator.FormatTimeString(currentData.Time,"HH:MM:SS");
2107
- this.Text = this.Text + " " + time;
2108
- }
2109
-
2110
- if (this.GetEventCallback)
2111
- {
2112
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_FORMAT_CORSSCURSOR_X_TEXT);
2113
- if (event)
2114
- {
2115
- var data={ Item:currentData, Period:this.Data.Period, Date:currentData.Date, Time:currentData.Time,Index:this.Data.DataOffset+index };
2116
- event.Callback(event,data,this);
2117
- }
2118
- }
2119
- return true;
2120
- }
2121
- }
2122
-
2123
- function HQMinuteTimeStringFormat()
2124
- {
2125
- this.newMethod = IChangeStringFormat; //派生
2126
- this.newMethod();
2127
- delete this.newMethod;
2128
-
2129
- this.Frame;
2130
- this.Symbol;
2131
-
2132
- this.Operator = function ()
2133
- {
2134
- if (this.Value == null || isNaN(this.Value)) return false;
2135
-
2136
- var index = Math.abs(this.Value);
2137
- index = parseInt(index.toFixed(0));
2138
- var showIndex = index;
2139
- if (this.Frame && this.Frame.MinuteCount) showIndex = index % this.Frame.MinuteCount;
2140
-
2141
- var timeStringData = JSCommonCoordinateData.MinuteTimeStringData;
2142
- var timeData = timeStringData.GetTimeData(this.Symbol);
2143
- if (!timeData) return false;
2144
-
2145
- if (showIndex < 0) showIndex = 0;
2146
- else if (showIndex > timeData.length) showIndex = timeData.length - 1;
2147
- if (this.Frame && index >= this.Frame.XPointCount)
2148
- showIndex = timeData.length - 1;
2149
-
2150
- var time = timeData[showIndex];
2151
- this.Text = IFrameSplitOperator.FormatTimeString(time);
2152
-
2153
- if (this.GetEventCallback)
2154
- {
2155
- var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_FORMAT_CORSSCURSOR_X_TEXT);
2156
- if (event)
2157
- {
2158
- var data={ Time:time, Index:showIndex };
2159
- event.Callback(event,data,this);
2160
- }
2161
- }
2162
- return true;
2163
- }
2164
- }
2165
-
2166
- function DivTooltipDataForamt()
2167
- {
2168
- this.DataMap=new Map(
2169
- [
2170
- ["CorssCursor_XStringFormat", { Create:function() { return new HQDateStringFormat(); } }],
2171
- ["CorssCursor_YStringFormat", { Create:function() { return new HQPriceStringFormat(); } }]
2172
- ]
2173
- );
2174
-
2175
- this.Create=function(name)
2176
- {
2177
- if (!this.DataMap.has(name)) return null;
2178
- var item=this.DataMap.get(name);
2179
- return item.Create();
2180
- }
2181
- }
2182
-
2183
- var g_DivTooltipDataForamt=new DivTooltipDataForamt();
2184
-
2185
-
2186
- //导出统一使用JSCommon命名空间名
2187
- export
2188
- {
2189
- CoordinateInfo,
2190
- IFrameSplitOperator,
2191
- FrameSplitKLinePriceY,
2192
- FrameSplitY,
2193
- FrameSplitKLineX,
2194
- FrameSplitMinutePriceY,
2195
- FrameSplitMinuteX,
2196
- FrameSplitXData,
2197
- SplitData,
2198
- PriceSplitData,
2199
- FrameSplitXDepth,
2200
-
2201
- IChangeStringFormat,
2202
- HQPriceStringFormat,
2203
- HQDateStringFormat,
2204
- HQMinuteTimeStringFormat,
2205
- g_DivTooltipDataForamt,
2206
- }
2207
- /*
2208
- module.exports =
2209
- {
2210
- JSCommonSplit:
2211
- {
2212
- CoordinateInfo: CoordinateInfo,
2213
- IFrameSplitOperator: IFrameSplitOperator,
2214
- FrameSplitKLinePriceY: FrameSplitKLinePriceY,
2215
- FrameSplitY: FrameSplitY,
2216
- FrameSplitKLineX: FrameSplitKLineX,
2217
- FrameSplitMinutePriceY: FrameSplitMinutePriceY,
2218
- FrameSplitMinuteX: FrameSplitMinuteX,
2219
- FrameSplitXData: FrameSplitXData,
2220
- SplitData: SplitData,
2221
- PriceSplitData: PriceSplitData,
2222
- FrameSplitXDepth:FrameSplitXDepth,
2223
- IChangeStringFormat:IChangeStringFormat,
2224
- HQPriceStringFormat:HQPriceStringFormat,
2225
- HQDateStringFormat:HQDateStringFormat,
2226
- HQMinuteTimeStringFormat:HQMinuteTimeStringFormat,
2227
- },
2228
-
2229
- JSCommonSplit_CoordinateInfo: CoordinateInfo,
2230
- JSCommonSplit_IFrameSplitOperator: IFrameSplitOperator,
2231
- JSCommonSplit_FrameSplitKLinePriceY: FrameSplitKLinePriceY,
2232
- JSCommonSplit_FrameSplitY: FrameSplitY,
2233
- JSCommonSplit_FrameSplitKLineX: FrameSplitKLineX,
2234
- JSCommonSplit_FrameSplitMinutePriceY: FrameSplitMinutePriceY,
2235
- JSCommonSplit_FrameSplitMinuteX: FrameSplitMinuteX,
2236
- JSCommonSplit_FrameSplitXData: FrameSplitXData,
2237
- JSCommonSplit_SplitData: SplitData,
2238
- JSCommonSplit_PriceSplitData: PriceSplitData,
2239
- JSCommonSplit_FrameSplitXDepth:FrameSplitXDepth,
2240
-
2241
- JSCommonFormat_IChangeStringFormat:IChangeStringFormat,
2242
- JSCommonFormat_HQPriceStringFormat:HQPriceStringFormat,
2243
- JSCommonFormat_HQDateStringFormat:HQDateStringFormat,
2244
- JSCommonFormat_HQMinuteTimeStringFormat:HQMinuteTimeStringFormat,
2245
- JSCommonFormat_Global_DataFormat :g_DivTooltipDataForamt,
2246
- };
2247
- */