umychart.resource.wechat.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. copyright (c) 2018 jones
  3. http://www.apache.org/licenses/LICENSE-2.0
  4. 开源项目 https://github.com/jones2000/HQChart
  5. jones_2000@163.com
  6. 全局配置颜色
  7. */
  8. function JSChartResource()
  9. {
  10. this.TooltipBGColor = "rgb(255, 255, 255)"; //背景色
  11. this.TooltipAlpha = 0.92; //透明度
  12. this.SelectRectBGColor = "rgba(1,130,212,0.06)"; //背景色
  13. // this.SelectRectAlpha=0.06; //透明度
  14. this.BGColor = 'rgb(255,255,255)'; //背景色
  15. this.UpBarColor = "rgb(238,21,21)";
  16. this.DownBarColor = "rgb(25,158,0)";
  17. this.UnchagneBarColor = "rgb(0,0,0)";
  18. this.MinKLineBarWidth=4; //最小的柱子宽度 比这个还小就画直线
  19. this.Minute = {};
  20. this.Minute.VolBarColor = null;
  21. this.Minute.PriceColor = "rgb(50,171,205)";
  22. this.Minute.AreaPriceColor = 'rgba(50,171,205,0.1)';
  23. this.Minute.AvPriceColor = "rgb(238,127,9)";
  24. this.DefaultTextColor = "rgb(43,54,69)";
  25. this.DefaultTextFont = '12px 微软雅黑';
  26. this.IndexTitleBGColor='rgb(217,219,220)'; //指标名字背景色
  27. this.DynamicTitleFont = '12px 微软雅黑'; //指标动态标题字体
  28. this.UpTextColor = "rgb(238,21,21)";
  29. this.DownTextColor = "rgb(25,158,0)";
  30. this.UnchagneTextColor = "rgb(0,0,0)";
  31. this.CloseLineColor = 'rgb(0,191,255)';
  32. this.CloseLineAreaColor = ['rgba(0,191,255,0.8)', 'rgba(0,191,255,0.2)'];
  33. this.Title = {
  34. TradeIndexColor:'rgb(105,105,105)', //交易指标颜色
  35. ColorIndexColor:'rgb(112,128,144)', //五彩K线颜色
  36. VolColor:"rgb(43,54,69)", //标题成交量
  37. AmountColor:"rgb(43,54,69)", //成交金额
  38. DateTimeColor:"rgb(43,54,69)", //时间,日期
  39. SettingColor:"rgb(43,54,69)", //周期,复权
  40. NameColor:"rgb(43,54,69)" , //股票名称
  41. TurnoverRateColor:'rgb(43,54,69)', //换手率
  42. PositionColor:"rgb(43,54,69)" //持仓
  43. };
  44. this.FrameBorderPen = "rgb(225,236,242)";
  45. this.FrameSplitPen = "rgb(225,236,242)"; //分割线
  46. this.FrameSplitTextColor = "rgb(51,51,51)"; //刻度文字颜色
  47. this.FrameSplitTextFont = "12px 微软雅黑"; //坐标刻度文字字体
  48. this.FrameYLineDash=[2, 2]; //Y轴线段虚线点间距,填null 就是实线
  49. this.FrameXLineDash=null; //X轴线段虚线点间距,填null 就是实线
  50. //this.FrameSplitTextFont = "14px PingFang-SC-Bold";//坐标刻度文字字体
  51. this.FrameTitleBGColor = "rgb(246,251,253)"; //标题栏背景色
  52. this.Frame = {
  53. XBottomOffset: 0 , //X轴文字向下偏移
  54. YTopOffset:2 //Y轴顶部文字向下偏移
  55. };
  56. this.FrameLatestPrice =
  57. {
  58. TextColor: 'rgb(255,255,255)', //最新价格文字颜色
  59. UpBarColor: "rgb(238,21,21)", //上涨
  60. DownBarColor: "rgb(25,158,0)", //下跌
  61. UnchagneBarColor: "rgb(0,0,0)", //平盘
  62. BGAlpha: 0.6
  63. };
  64. this.FrameMargin = 4; //左右一共的边距
  65. this.FrameLeftMargin = 2;
  66. this.FrameRightMargin=2;
  67. this.CorssCursorBGColor = "rgb(43,54,69)"; //十字光标背景
  68. this.CorssCursorTextColor = "rgb(255,255,255)";
  69. this.CorssCursorTextFont = "12px 微软雅黑";
  70. this.CorssCursorHPenColor = "rgb(130,130,130)"; //十字光标线段颜色(水平)
  71. this.CorssCursorVPenColor = "rgb(130,130,130)"; //十字光标线段颜色(垂直)
  72. this.Domain = "https://opensource.zealink.com"; //API域名
  73. this.CacheDomain = "https://opensourcecache.zealink.com"; //缓存域名
  74. this.KLine =
  75. {
  76. MaxMin: { Font: '12px 微软雅黑', Color: 'rgb(111,111,111)', RightArrow:"→", LeftArrow:"←", HighYOffset:0, LowYOffset:0 }, //K线最大最小值显示
  77. Info: //信息地雷
  78. {
  79. Color: 'rgb(205,149,12)',
  80. Color2: 'rgb(255,133,3)', //三角图形颜色
  81. TextColor: '#197de9',
  82. TextBGColor: 'rgba(220,220,220,0.5)',
  83. Investor:
  84. {
  85. ApiUrl: '/API/NewsInteract', //互动易
  86. },
  87. Announcement: //公告
  88. {
  89. ApiUrl: '/API/ReportList',
  90. },
  91. Pforecast: //业绩预告
  92. {
  93. ApiUrl: '/API/StockHistoryDay',
  94. },
  95. Research: //调研
  96. {
  97. ApiUrl: '/API/InvestorRelationsList',
  98. },
  99. BlockTrading: //大宗交易
  100. {
  101. ApiUrl: '/API/StockHistoryDay',
  102. },
  103. TradeDetail: //龙虎榜
  104. {
  105. ApiUrl: '/API/StockHistoryDay',
  106. },
  107. Policy: //策略
  108. {
  109. ApiUrl: '/API/StockHistoryDay',
  110. }
  111. }
  112. };
  113. this.Index = {};
  114. //指标线段颜色
  115. this.Index.LineColor =
  116. [
  117. "rgb(255,189,09)",
  118. "rgb(22,198,255)",
  119. "rgb(174,35,161)",
  120. "rgb(236,105,65)",
  121. "rgb(68,114,196)",
  122. "rgb(229,0,79)",
  123. "rgb(0,128,255)",
  124. "rgb(252,96,154)",
  125. "rgb(42,230,215)",
  126. "rgb(24,71,178)",
  127. ];
  128. this.ColorArray = //自定义指标默认颜色
  129. [
  130. "rgb(255,174,0)",
  131. "rgb(25,199,255)",
  132. "rgb(175,95,162)",
  133. "rgb(236,105,65)",
  134. "rgb(68,114,196)",
  135. "rgb(229,0,79)",
  136. "rgb(0,128,255)",
  137. "rgb(252,96,154)",
  138. "rgb(42,230,215)",
  139. "rgb(24,71,178)",
  140. ];
  141. //历史数据api
  142. this.Index.StockHistoryDayApiUrl = "https://opensource.zealink.com/API/StockHistoryDay";
  143. //市场多空
  144. this.Index.MarketLongShortApiUrl = "https://opensource.zealink.com/API/FactorTiming";
  145. //市场关注度
  146. this.Index.MarketAttentionApiUrl = "https://opensource.zealink.com/API/MarketAttention";
  147. //行业,指数热度
  148. this.Index.MarketHeatApiUrl = "https://opensource.zealink.com/API/MarketHeat"
  149. //自定义指数热度
  150. this.Index.CustomIndexHeatApiUrl = "https://opensource.zealink.com/API/QuadrantCalculate";
  151. //指标不支持信息
  152. this.Index.NotSupport = { Font: "12px 微软雅黑", TextColor: "rgb(52,52,52)" };
  153. //画图工具
  154. this.DrawPicture = {};
  155. this.DrawPicture.LineColor =
  156. [
  157. "rgb(30,144,255)",
  158. ];
  159. this.DrawPicture.PointColor =
  160. [
  161. "rgb(105,105,105)",
  162. ];
  163. this.KLineTrain =
  164. {
  165. Font: 'bold 12px 宋体',
  166. LastDataIcon: { Color: 'rgb(0,0,205)', Text: '⬇' },
  167. BuyIcon: { Color: 'rgb(255,185, 15)', Text: '买' },
  168. SellIcon: { Color: 'rgb(70,130,180)', Text: '卖' }
  169. };
  170. //K线tooltip
  171. this.TooltipPaint =
  172. {
  173. BGColor: 'rgba(250,250,250,0.8)', //背景色
  174. BorderColor: 'rgb(120,120,120)', //边框颜色
  175. TitleColor: 'rgb(120,120,120)', //标题颜色
  176. TitleFont: '12px 微软雅黑' //字体
  177. },
  178. //弹幕
  179. this.Barrage =
  180. {
  181. Font: '16px 微软雅黑', //字体
  182. Height: 20,
  183. Color: 'RGB(109,109,109)'
  184. }
  185. //走势图 信息地雷
  186. this.MinuteInfo = {
  187. TextColor: 'rgb(84,143,255)',
  188. Font: '12px 微软雅黑',
  189. PointColor: 'rgb(38,113,254)',
  190. LineColor: 'rgb(120,167,255)',
  191. TextBGColor: 'rgba(255,255,255,0.8)'
  192. };
  193. //单图标指标ChartSingleText -> DRAWICON
  194. this.DRAWICON=
  195. {
  196. Text:
  197. {
  198. MaxSize:50, //字体最大
  199. MinSize:20, //字体最小
  200. Zoom:
  201. {
  202. Type:2, //0=放大(K线宽度*Value) 1=放大(K线+间距)*Value 2=(K线+间距)+2*Value;
  203. Value:1
  204. },
  205. FontName:'Arial' //字体
  206. }
  207. }
  208. this.DRAWTEXT=
  209. {
  210. MaxSize:18, //字体最大
  211. MinSize:18, //字体最小
  212. Zoom:
  213. {
  214. Type:1, //0=放大(K线宽度*Value) 1=放大(K线+间距)*Value 2=(K线+间距)+2*Value;
  215. Value:1
  216. },
  217. FontName:'微软雅黑' //字体
  218. }
  219. this.DRAWNUMBER=
  220. {
  221. MaxSize:18, //字体最大
  222. MinSize:18, //字体最小
  223. Zoom:
  224. {
  225. Type:1, //0=放大(K线宽度*Value) 1=放大(K线+间距)*Value 2=(K线+间距)+2*Value;
  226. Value:1
  227. },
  228. FontName:'微软雅黑' //字体
  229. }
  230. this.DRAWABOVE=
  231. {
  232. YOffset:0 //y坐标向上偏移
  233. }
  234. this.CIRCLEDOT=
  235. {
  236. Radius:1.3
  237. }
  238. this.POINTDOT=
  239. {
  240. Radius:2
  241. }
  242. //深度图
  243. this.DepthChart=
  244. {
  245. BidColor: { Line:"rgb(82,176,123)", Area:"rgba(82,176,123,0.8)"}, //卖
  246. AskColor: { Line:"rgb(207,76,89)", Area:"rgba(207,76,89, 0.8)"}, //买
  247. LineWidth:4
  248. }
  249. this.DepthCorss=
  250. {
  251. BidColor: { Line:"rgb(82,176,123)" }, //卖
  252. AskColor: { Line:"rgb(207,76,89)" }, //买
  253. LineWidth:2, //线段宽度
  254. LineDash:[3,3],
  255. Tooltip:
  256. {
  257. BGColor:'rgba(236,240,245, 0.8)', TextColor:"rgb(130,140,151)",
  258. Border:{ Top:5, Left:20, Bottom:5, Center: 5},
  259. Font:"12px 微软雅黑",
  260. LineHeight:16 //单行高度
  261. }
  262. }
  263. // //自定义风格
  264. this.SetStyle = function (style)
  265. {
  266. if (style.TooltipBGColor) this.TooltipBGColor = style.TooltipBGColor;
  267. if (style.TooltipAlpha) this.TooltipAlpha = style.TooltipAlpha;
  268. if (style.BGColor) this.BGColor = style.BGColor;
  269. if (style.SelectRectBGColor) this.SelectRectBGColor = style.SelectRectBGColor;
  270. if (style.UpBarColor) this.UpBarColor = style.UpBarColor;
  271. if (style.DownBarColor) this.DownBarColor = style.DownBarColor;
  272. if (style.UnchagneBarColor) this.UnchagneBarColor = style.UnchagneBarColor;
  273. if (style.Minute)
  274. {
  275. if (style.Minute.VolBarColor) this.Minute.VolBarColor = style.Minute.VolBarColor;
  276. if (style.Minute.PriceColor) this.Minute.PriceColor = style.Minute.PriceColor;
  277. if (style.Minute.AvPriceColor) this.Minute.AvPriceColor = style.Minute.AvPriceColor;
  278. if (style.Minute.AreaPriceColor) this.Minute.AreaPriceColor = style.Minute.AreaPriceColor;
  279. }
  280. if (style.DefaultTextColor) this.DefaultTextColor = style.DefaultTextColor;
  281. if (style.DefaultTextFont) this.DefaultTextFont = style.DefaultTextFont;
  282. if (style.DynamicTitleFont) this.DynamicTitleFont = style.DynamicTitleFont;
  283. if (style.IndexTitleBGColor) this.IndexTitleBGColor=style.IndexTitleBGColor;
  284. if (style.UpTextColor) this.UpTextColor = style.UpTextColor;
  285. if (style.DownTextColor) this.DownTextColor = style.DownTextColor;
  286. if (style.UnchagneTextColor) this.UnchagneTextColor = style.UnchagneTextColor;
  287. if (style.CloseLineColor) this.CloseLineColor = style.CloseLineColor;
  288. if (style.CloseLineAreaColor) this.CloseLineAreaColor = style.CloseLineAreaColor;
  289. if (style.FrameBorderPen) this.FrameBorderPen = style.FrameBorderPen;
  290. if (style.FrameSplitPen) this.FrameSplitPen = style.FrameSplitPen;
  291. if (style.FrameSplitTextColor) this.FrameSplitTextColor = style.FrameSplitTextColor;
  292. if (style.FrameSplitTextFont) this.FrameSplitTextFont = style.FrameSplitTextFont;
  293. if (style.FrameTitleBGColor) this.FrameTitleBGColor = style.FrameTitleBGColor;
  294. if (style.Frame)
  295. {
  296. if (style.Frame.XBottomOffset) this.Frame.XBottomOffset = style.Frame.XBottomOffset;
  297. if (style.Frame.YTopOffset) this.Frame.YTopOffset = style.Frame.YTopOffset;
  298. }
  299. if (style.FrameLatestPrice)
  300. {
  301. if (style.FrameLatestPrice.TextColor) this.FrameLatestPrice.TextColor = style.FrameLatestPrice.TextColor;
  302. if (style.FrameLatestPrice.UpBarColor) this.FrameLatestPrice.UpBarColor = style.FrameLatestPrice.UpBarColor;
  303. if (style.FrameLatestPrice.DownBarColor) this.FrameLatestPrice.DownBarColor = style.FrameLatestPrice.DownBarColor;
  304. if (style.FrameLatestPrice.UnchagneBarColor) this.FrameLatestPrice.UnchagneBarColor = style.FrameLatestPrice.UnchagneBarColor;
  305. if (style.FrameLatestPrice.BGAlpha) this.FrameLatestPrice.BGAlpha = style.FrameLatestPrice.BGAlpha;
  306. }
  307. if (style.CorssCursorBGColor) this.CorssCursorBGColor = style.CorssCursorBGColor;
  308. if (style.CorssCursorTextColor) this.CorssCursorTextColor = style.CorssCursorTextColor;
  309. if (style.CorssCursorTextFont) this.CorssCursorTextFont = style.CorssCursorTextFont;
  310. if (style.CorssCursorHPenColor) this.CorssCursorHPenColor = style.CorssCursorHPenColor;
  311. if (style.CorssCursorVPenColor) this.CorssCursorVPenColor = style.CorssCursorVPenColor;
  312. if (style.KLine) this.KLine = style.KLine;
  313. if (style.Index)
  314. {
  315. if (style.Index.LineColor) this.Index.LineColor = style.Index.LineColor;
  316. if (style.Index.NotSupport) this.Index.NotSupport = style.Index.NotSupport;
  317. }
  318. if (style.ColorArray) this.ColorArray = style.ColorArray;
  319. if (style.DrawPicture)
  320. {
  321. this.DrawPicture.LineColor = style.DrawPicture.LineColor;
  322. this.DrawPicture.PointColor = style.DrawPicture.PointColor;
  323. }
  324. if (style.TooltipPaint)
  325. {
  326. if (style.TooltipPaint.BGColor) this.TooltipPaint.BGColor = style.TooltipPaint.BGColor;
  327. if (style.TooltipPaint.BorderColor) this.TooltipPaint.BorderColor = style.TooltipPaint.BorderColor;
  328. if (style.TooltipPaint.TitleColor) this.TooltipPaint.TitleColor = style.TooltipPaint.TitleColor;
  329. if (style.TooltipPaint.TitleFont) this.TooltipPaint.TitleFont = style.TooltipPaint.TitleFont;
  330. }
  331. if (style.Title)
  332. {
  333. if (style.Title.TradeIndexColor) this.Title.TradeIndexColor=style.Title.TradeIndexColor;
  334. if (style.Title.ColorIndexColor) this.Title.ColorIndexColor=style.Title.ColorIndexColor;
  335. if (style.Title.VolColor) this.Title.VolColor=style.Title.VolColor;
  336. if (style.Title.AmountColor) this.Title.AmountColor=style.Title.AmountColor;
  337. if (style.Title.DateTimeColor) this.Title.DateTimeColor=style.Title.DateTimeColor;
  338. if (style.Title.NameColor) this.Title.NameColor=style.Title.NameColor;
  339. if (style.Title.SettingColor) this.Title.SettingColor=style.Title.SettingColor;
  340. if (style.Title.TurnoverRateColor) this.Title.TurnoverRateColor=style.Title.TurnoverRateColor;
  341. if (style.Title.PositionColor) this.Title.PositionColor=style.Title.PositionColor;
  342. }
  343. if (style.DRAWICON)
  344. {
  345. if (style.DRAWICON.Text)
  346. {
  347. var item=style.DRAWICON.Text;
  348. if (IFrameSplitOperator.IsPlusNumber(item.MaxSize)) this.DRAWICON.Text.MaxSize=item.MaxSize;
  349. if (IFrameSplitOperator.IsPlusNumber(item.MinSize)) this.DRAWICON.Text.MinSize=item.MinSize;
  350. if (item.Zoom) this.DRAWICON.Text.Zoom=item.Zoom;
  351. if (item.FontName) this.DRAWICON.Text.FontName=item.FontName;
  352. }
  353. }
  354. if (style.DRAWTEXT)
  355. {
  356. var item=style.DRAWTEXT;
  357. if (IFrameSplitOperator.IsPlusNumber(item.MaxSize)) this.DRAWICON.MaxSize=item.MaxSize;
  358. if (IFrameSplitOperator.IsPlusNumber(item.MinSize)) this.DRAWICON.MinSize=item.MinSize;
  359. if (item.Zoom) this.DRAWICON.Zoom=item.Zoom;
  360. if (item.FontName) this.DRAWICON.FontName=item.FontName;
  361. }
  362. if (style.DRAWNUMBER)
  363. {
  364. var item=style.DRAWNUMBER;
  365. if (this.IsPlusNumber(item.MaxSize)) this.DRAWNUMBER.Text.MaxSize=item.MaxSize;
  366. if (this.IsPlusNumber(item.MinSize)) this.DRAWNUMBER.Text.MinSize=item.MinSize;
  367. if (item.Zoom) this.DRAWNUMBER.Text.Zoom=item.Zoom;
  368. if (item.FontName) this.DRAWNUMBER.Text.FontName=item.FontName;
  369. }
  370. if (style.DRAWABOVE)
  371. {
  372. var item=style.DRAWABOVE;
  373. if (this.IsNumber(item.YOffset)) this.DRAWABOVE.YOffset=item.YOffset;
  374. }
  375. if (style.DepthChart)
  376. {
  377. var item=style.DepthChart;
  378. if (item.BidColor)
  379. {
  380. if (item.BidColor.Line) this.DepthChart.BidColor.Line=item.BidColor.Line;
  381. if (item.BidColor.Area) this.DepthChart.BidColor.Area=item.BidColor.Area;
  382. }
  383. if (item.AskColor)
  384. {
  385. if (item.AskColor.Line) this.DepthChart.AskColor.Line=item.AskColor.Line;
  386. if (item.AskColor.Area) this.DepthChart.AskColor.Area=item.AskColor.Area;
  387. }
  388. if (item.LineWidth) this.DepthChart.LineWidth=item.LineWidth;
  389. }
  390. if (style.DepthCorss)
  391. {
  392. var item=style.DepthCorss;
  393. if (item.BidColor)
  394. {
  395. if (item.BidColor.Line) this.DepthCorss.BidColor.Line=item.BidColor.Line;
  396. }
  397. if (item.AskColor)
  398. {
  399. if (item.AskColor.Line) this.DepthCorss.AskColor.Line=item.AskColor.Line;
  400. }
  401. if (item.LineWidth) this.DepthCorss.LineWidth=item.LineWidth;
  402. if (item.LineDash) this.DepthCorss.LineDash=item.LineDash;
  403. if (item.Tooltip)
  404. {
  405. var tooltip=item.Tooltip;
  406. if (tooltip.BGColor) this.DepthCorss.Tooltip.BGColor=tooltip.BGColor;
  407. if (tooltip.TextColor) this.DepthCorss.Tooltip.TextColor=tooltip.TextColor;
  408. if (tooltip.Font) this.DepthCorss.Tooltip.Font=tooltip.Font;
  409. if (tooltip.LineHeight) this.DepthCorss.Tooltip.LineHeight=tooltip.LineHeight;
  410. var border=tooltip.Border;
  411. if (this.IsNumber(border.Top)) this.DepthCorss.Tooltip.Border.Top=border.Top;
  412. if (this.IsNumber(border.Left)) this.DepthCorss.Tooltip.Border.Left=border.Left;
  413. if (this.IsNumber(border.Bottom)) this.DepthCorss.Tooltip.Border.Bottom=border.Bottom;
  414. if (this.IsNumber(border.Center)) this.DepthCorss.Tooltip.Border.Center=border.Center;
  415. }
  416. }
  417. if (style.CIRCLEDOT)
  418. {
  419. var item=style.CIRCLEDOT;
  420. if (this.IsNumber(item.Radius)) this.CIRCLEDOT.Radius=item.Radius;
  421. }
  422. if (style.POINTDOT)
  423. {
  424. var item=style.POINTDOT;
  425. if (this.IsNumber(item.Radius)) this.POINTDOT.Radius=item.Radius;
  426. }
  427. }
  428. this.IsNumber=function(value)
  429. {
  430. if (value==null) return false;
  431. if (isNaN(value)) return false;
  432. return true;
  433. }
  434. //判断是否是正数
  435. this.IsPlusNumber=function(value)
  436. {
  437. if (value==null) return false;
  438. if (isNaN(value)) return false;
  439. return value>0;
  440. }
  441. }
  442. var g_JSChartResource = new JSChartResource();
  443. var JSCHART_LANGUAGE_ID =
  444. {
  445. LANGUAGE_CHINESE_ID: 0,
  446. LANGUAGE_ENGLISH_ID: 1
  447. };
  448. function JSChartLocalization()
  449. {
  450. this.TextResource = new Map([
  451. //内部tooltip
  452. ['Tooltip-Open', { CN: '开:', EN: 'O:' }],
  453. ['Tooltip-High', { CN: '高:', EN: 'H:' }],
  454. ['Tooltip-Low', { CN: '低:', EN: 'L:' }],
  455. ['Tooltip-Close', { CN: '收:', EN: 'C:' }],
  456. ['Tooltip-Increase', { CN: '幅:', EN: 'I:' }],
  457. ['Tooltip-Vol', { CN: '量:', EN: 'V:' }],
  458. ['Tooltip-Amount', { CN: '额:', EN: 'A:' }],
  459. ['Tooltip-AvPrice', { CN: '均:', EN: 'AP:' }],
  460. ['Tooltip-Price', { CN: '价:', EN: 'P:' }],
  461. ['Tooltip-Exchange', { CN: '换:', EN: 'E:' }],
  462. ['Tooltip-Position', { CN: '持:', EN: 'P:' }],
  463. //K线动态标题
  464. ['KTitle-Open', { CN: '开:', EN: 'O:' }],
  465. ['KTitle-High', { CN: '高:', EN: 'H:' }],
  466. ['KTitle-Low', { CN: '低:', EN: 'L:' }],
  467. ['KTitle-Close', { CN: '收:', EN: 'C:' }],
  468. ['KTitle-Increase', { CN: '幅:', EN: 'I:' }],
  469. ['KTitle-Vol', { CN: '量:', EN: 'V:' }],
  470. ['KTitle-Amount', { CN: '额:', EN: 'A:' }],
  471. ['KTitle-Exchange', { CN: '换:', EN: 'E:' }],
  472. ['KTitle-Position', { CN: '持:', EN: 'P:' }],
  473. //走势图动态标题
  474. ['MTitle-Close', { CN: '价:', EN: 'C:' }],
  475. ['MTitle-AvPrice', { CN: '均:', EN: 'AC:' }],
  476. ['MTitle-Increase', { CN: '幅:', EN: 'I:' }],
  477. ['MTitle-Vol', { CN: '量:', EN: 'V:' }],
  478. ['MTitle-Amount', { CN: '额:', EN: 'A:' }],
  479. ['MTitle-Position', { CN: '持:', EN: 'P:' }],
  480. //周期
  481. ['日线', { CN: '日线', EN: '1D' }],
  482. ['周线', { CN: '周线', EN: '1W' }],
  483. ['双周', { CN: '双周', EN: "2W" }],
  484. ['月线', { CN: '月线', EN: '1M' }],
  485. ['年线', { CN: '年线', EN: '1Y' }],
  486. ['1分', { CN: '1分', EN: '1Min' }],
  487. ['5分', { CN: '5分', EN: '5Min' }],
  488. ['15分', { CN: '15分', EN: '15Min' }],
  489. ['30分', { CN: '30分', EN: '30Min' }],
  490. ['60分', { CN: '60分', EN: '60Min' }],
  491. ['季线', { CN: '季线', EN: '1Q' }],
  492. ['分笔', { CN: '分笔', EN: 'Tick' }],
  493. ['2小时', { CN: '2小时', EN: '2H' }],
  494. ['4小时', { CN: '4小时', EN: '4H' }],
  495. //复权
  496. ['不复权', { CN: '不复权', EN: 'No Right' }],
  497. ['前复权', { CN: '前复权', EN: 'Pro Right' }],
  498. ['后复权', { CN: '后复权', EN: 'Post Right' }],
  499. //week
  500. ['日', { CN: '日', EN: 'Sun.' }],
  501. ['一', { CN: '一', EN: 'Mon.' }],
  502. ['二', { CN: '二', EN: 'Tues.' }],
  503. ['三', { CN: '三', EN: 'Wed.' }],
  504. ['四', { CN: '四', EN: 'Thur.' }],
  505. ['五', { CN: '五', EN: 'Fri.' }],
  506. ['六', { CN: '六', EN: 'Sat.' }],
  507. ['1月', { CN: '1月', EN: 'Jan' }],
  508. ['2月', { CN: '2月', EN: 'Feb' }],
  509. ['3月', { CN: '3月', EN: 'Mar' }],
  510. ['4月', { CN: '4月', EN: 'Apr' }],
  511. ['5月', { CN: '5月', EN: 'May' }],
  512. ['6月', { CN: '6月', EN: 'Jun' }],
  513. ['7月', { CN: '7月', EN: 'Jul' }],
  514. ['8月', { CN: '8月', EN: 'Aug' }],
  515. ['9月', { CN: '9月', EN: 'Sept' }],
  516. ['10月', { CN: '10月', EN: 'Oct' }],
  517. ['11月', { CN: '11月', EN: 'Nov' }],
  518. ['12月', { CN: '12月', EN: 'Dec' }],
  519. ['自定义分钟', { CN: '分', EN: 'Min' }],
  520. ['自定义日线', { CN: '日', EN: 'D' }],
  521. ['自定义秒', { CN: '秒', EN: 'S' }]
  522. ]);
  523. this.GetText = function (key, language)
  524. {
  525. var item = this.TextResource.get(key);
  526. if (!item) return '';
  527. switch (language)
  528. {
  529. case JSCHART_LANGUAGE_ID.LANGUAGE_CHINESE_ID:
  530. return item.CN;
  531. case JSCHART_LANGUAGE_ID.LANGUAGE_ENGLISH_ID:
  532. return item.EN;
  533. default:
  534. return item.CN;
  535. }
  536. }
  537. this.SetTextResource = function (key, value)
  538. {
  539. this.TextResource.set(key, value)
  540. }
  541. };
  542. var g_JSChartLocalization = new JSChartLocalization();
  543. //导出统一使用JSCommon命名空间名
  544. module.exports =
  545. {
  546. JSCommonResource:
  547. {
  548. JSChartResource: JSChartResource,
  549. Global_JSChartResource: g_JSChartResource,
  550. Global_JSChartLocalization: g_JSChartLocalization,
  551. JSCHART_LANGUAGE_ID: JSCHART_LANGUAGE_ID,
  552. },
  553. //单个类导出
  554. JSCommonResource_JSChartResource: JSChartResource,
  555. JSCommonResource_Global_JSChartResource: g_JSChartResource,
  556. JSCommonResource_Global_JSChartLocalization: g_JSChartLocalization,
  557. JSCommonResource_JSCHART_LANGUAGE_ID: JSCHART_LANGUAGE_ID
  558. };