hqchart 1.1.13660 → 1.1.13672

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.13660",
3
+ "version": "1.1.13672",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -49546,3 +49546,24 @@ HQData.Report_RequestStockSortData=function(data, callback)
49546
49546
  }
49547
49547
 
49548
49548
 
49549
+
49550
+ HQData.Keyboard_RequestSymbolList=function(data, callback)
49551
+ {
49552
+ //加载数据
49553
+ var recv={ symbollist:SYMBOL_LIST };
49554
+ var arySymbol=[];
49555
+ for(var i=0;i<recv.symbollist.length;++i)
49556
+ {
49557
+ var item=recv.symbollist[i];
49558
+ var shortSymbol=item[0];
49559
+ shortSymbol=shortSymbol.replace(".sh", "");
49560
+ shortSymbol=shortSymbol.replace(".sz", "");
49561
+ var symbolItem={ Symbol:item[0], Name:item[1], ShortSymbol:shortSymbol, Spell:item[3], Type:item[2] };
49562
+ if (i%5==0) symbolItem.Color="rgb(255,0,0)";
49563
+ arySymbol.push(symbolItem);
49564
+ }
49565
+
49566
+ callback(arySymbol);
49567
+ }
49568
+
49569
+
@@ -0,0 +1,268 @@
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
+ function JSPopKeyboard()
14
+ {
15
+ this.DivDialog=null;
16
+ this.DragTitle=null;
17
+ this.InputDOM=null;
18
+ this.Title="HQChart 键盘精灵"
19
+ this.ID=Guid();
20
+
21
+ this.Keyboard=
22
+ {
23
+ Option:JSPopKeyboard.GetOption(),
24
+ JSChart:null,
25
+ }
26
+
27
+ this.Inital=function()
28
+ {
29
+ window.addEventListener('mousedown', (e)=>{ this.OnWindowMouseDown(e)});
30
+ }
31
+
32
+ this.OnWindowMouseDown=function(e)
33
+ {
34
+ if (!this.DivDialog) return;
35
+
36
+ console.log("[JSPopKeyboard::OnWindowMouseDown] e=", e);
37
+
38
+ if (!this.DivDialog.contains(e.target))
39
+ {
40
+ this.Hide();
41
+ }
42
+ }
43
+
44
+ this.Create=function()
45
+ {
46
+ var divDom=document.createElement('div');
47
+ divDom.className='jchart_pop_keyboard_dailog';
48
+ divDom.id=this.ID;
49
+
50
+ var divTitle=document.createElement("div");
51
+ divTitle.className='jschart_keyboard_Title_Div';
52
+ divTitle.innerText=this.Title;
53
+ divTitle.onmousedown=(e)=>{ this.OnMouseDownTitle(e); }
54
+ divDom.appendChild(divTitle);
55
+
56
+ var divInput=document.createElement("div");
57
+ divInput.className='jschart_keyboard_Input_Div';
58
+ divDom.appendChild(divInput);
59
+
60
+ var input=document.createElement("input");
61
+ input.className="jschart_keyboard_input";
62
+ input.addEventListener("keydown", (event)=>{ this.OnKeydown(event); });
63
+ input.addEventListener("keyup", (event)=>{ this.OnKeyup(event); });
64
+
65
+ divInput.appendChild(input);
66
+
67
+ var divChart=document.createElement("div");
68
+ divChart.className="jschart_keyboard_Chart_Div";
69
+ divDom.appendChild(divChart);
70
+
71
+ this.DivDialog=divDom;
72
+ this.InputDOM=input;
73
+
74
+ var chart=JSKeyboardChart.Init(divChart);
75
+ this.Keyboard.JSChart=chart;
76
+
77
+ this.Keyboard.Option.OnCreatedCallback=(chart)=>{ this.OnCreateHQChart(chart); }
78
+ chart.SetOption(this.Keyboard.Option); //设置K线配置
79
+
80
+ chart.AddEventCallback(
81
+ {
82
+ event:JSCHART_EVENT_ID.ON_KEYBOARD_MOUSEUP,
83
+ callback:(event, data, chart)=>{ this.OnChartMouseUp(event, data, chart);}
84
+ }
85
+ )
86
+
87
+ document.body.appendChild(divDom);
88
+ }
89
+
90
+ this.OnCreateHQChart=function(chart)
91
+ {
92
+
93
+ }
94
+
95
+ this.OnKeydown=function(event)
96
+ {
97
+ var aryKey=new Set([
98
+ 40,
99
+ 38,
100
+ 13,
101
+ 33,
102
+ 34
103
+ ]);
104
+
105
+ if (aryKey.has(event.keyCode))
106
+ {
107
+ this.Keyboard.JSChart.OnKeyDown(event);
108
+ }
109
+
110
+ if (event.keyCode==27)
111
+ {
112
+ this.Hide();
113
+ }
114
+ }
115
+
116
+ this.OnKeyup=function(event)
117
+ {
118
+ var code=event.keyCode;
119
+ if ((code>=48 && code<=57) || (code>=65 && code<=90) || (code>=97 && code<=122) || code==8)
120
+ {
121
+ var strText=this.InputDOM.value;
122
+ strText=strText.toUpperCase();
123
+ if (strText.length==0)
124
+ {
125
+ this.Hide();
126
+ }
127
+ else
128
+ {
129
+ this.Keyboard.JSChart.Search(strText);
130
+ }
131
+ }
132
+ }
133
+
134
+
135
+ this.OnMouseDownTitle=function(e)
136
+ {
137
+ if (!this.DivDialog) return;
138
+
139
+ var dragData={ X:e.clientX, Y:e.clientY };
140
+ dragData.YOffset=e.clientX - this.DivDialog.offsetLeft;
141
+ dragData.XOffset=e.clientY - this.DivDialog.offsetTop;
142
+ this.DragTitle=dragData;
143
+
144
+ document.onmousemove=(e)=>{ this.DocOnMouseMoveTitle(e); }
145
+ document.onmouseup=(e)=>{ this.DocOnMouseUpTitle(e); }
146
+ }
147
+
148
+ this.DocOnMouseMoveTitle=function(e)
149
+ {
150
+ if (!this.DragTitle) return;
151
+
152
+ var left = e.clientX - this.DragTitle.YOffset;
153
+ var top = e.clientY - this.DragTitle.XOffset;
154
+
155
+ var right=left+this.DivDialog.offsetWidth;
156
+ var bottom=top+ this.DivDialog.offsetHeight;
157
+
158
+ if ((right+5)>=window.innerWidth) left=window.innerWidth-this.DivDialog.offsetWidth-5;
159
+ if ((bottom+5)>=window.innerHeight) top=window.innerHeight-this.DivDialog.offsetHeight-5;
160
+
161
+ this.DivDialog.style.left = left + 'px';
162
+ this.DivDialog.style.top = top + 'px';
163
+
164
+ if(e.preventDefault) e.preventDefault();
165
+ }
166
+
167
+ this.DocOnMouseUpTitle=function(e)
168
+ {
169
+ this.DragTitle=null;
170
+ this.onmousemove = null;
171
+ this.onmouseup = null;
172
+ }
173
+
174
+ this.SetSymbolData=function(data)
175
+ {
176
+ if (!this.Keyboard.JSChart) return false;
177
+ this.Keyboard.JSChart.SetSymbolData(data);
178
+ }
179
+
180
+ this.Show=function()
181
+ {
182
+ if (!this.DivDialog) return;
183
+
184
+ //显示在右下方
185
+ var height=this.DivDialog.offsetHeight;
186
+ var width=this.DivDialog.offsetWidth;
187
+ var xRight=window.innerWidth-5;
188
+ var ybottom=window.innerHeight-5;
189
+ var x=xRight-width;
190
+ var y=ybottom-height;
191
+
192
+ this.DivDialog.style.visibility='visible';
193
+ this.DivDialog.style.top = y + "px";
194
+ this.DivDialog.style.left = x + "px";
195
+ }
196
+
197
+ this.Hide=function()
198
+ {
199
+ if (!this.DivDialog) return;
200
+
201
+ this.DivDialog.style.visibility='hidden';
202
+ this.InputDOM.value="";
203
+ this.Keyboard.JSChart.ClearSearch();
204
+ }
205
+
206
+ this.IsShow=function()
207
+ {
208
+ if (!this.DivDialog) return false;
209
+ return this.DivDialog.style.visibility==='visible';
210
+ }
211
+
212
+ this.OnGlobalKeydown=function(event)
213
+ {
214
+ if (!this.DivDialog) return;
215
+
216
+ var code=event.keyCode;
217
+ if (!this.IsShow() && (code>=48 && code<=57) || (code>=65 && code<=90) || (code>=97 && code<=122))
218
+ {
219
+ this.Show();
220
+ this.InputDOM.focus();
221
+ }
222
+ else if (code==27 && this.IsShow())
223
+ {
224
+ this.Hide();
225
+ }
226
+ }
227
+
228
+ this.OnGlobalMouseDown=function(event)
229
+ {
230
+ if (!this.DivDialog) return;
231
+
232
+ if (this.DivDialog.style.display=='none') return;
233
+
234
+ if (!this.DivDialog.contains(event.target))
235
+ {
236
+ this.Hide();
237
+ }
238
+ }
239
+
240
+ this.OnChartMouseUp=function(event, data, chart)
241
+ {
242
+ this.InputDOM.focus();
243
+ }
244
+ }
245
+
246
+ JSPopKeyboard.GetOption=function()
247
+ {
248
+ var option=
249
+ {
250
+ Type:'键盘精灵', //创建图形类型
251
+
252
+ Border: //边框
253
+ {
254
+ Left:1, //左边间距
255
+ Right:1, //右边间距
256
+ Bottom:1, //底部间距
257
+ Top:1 //顶部间距
258
+ },
259
+
260
+ BorderLine:0,
261
+ EnableResize:true
262
+ };
263
+
264
+ return option;
265
+ }
266
+
267
+
268
+
@@ -41634,9 +41634,17 @@ function MinuteTooltipPaint()
41634
41634
  if (IFrameSplitOperator.IsNumber(close) && IFrameSplitOperator.IsNumber(this.YClose))
41635
41635
  {
41636
41636
  title=g_JSChartLocalization.GetText('Tooltip-Increase',this.LanguageID);
41637
- var value=(close-this.YClose)/this.YClose*100;
41638
- color = this.TitlePaint.GetColor(value, 0);
41639
- text = value.toFixed(2)+'%';
41637
+ if (this.YClose===0)
41638
+ {
41639
+ text = '--.--';
41640
+ color = this.TitleColor;
41641
+ }
41642
+ else
41643
+ {
41644
+ var value=(close-this.YClose)/this.YClose*100;
41645
+ color = this.TitlePaint.GetColor(value, 0);
41646
+ text = value.toFixed(2)+'%';
41647
+ }
41640
41648
  aryText.push({Title:title, TitleColor:this.TitleColor, Text:text, Color:color });
41641
41649
  }
41642
41650
 
@@ -42058,7 +42066,7 @@ function MinuteLeftTooltipPaint()
42058
42066
  this.ForamtIncrease=function(price, TitleID)
42059
42067
  {
42060
42068
  if (!IFrameSplitOperator.IsNumber(price) || price==0) return null;
42061
-
42069
+
42062
42070
  var value=(price-this.YClose)/this.YClose*100;
42063
42071
  var titleItem=
42064
42072
  {
@@ -42068,6 +42076,13 @@ function MinuteLeftTooltipPaint()
42068
42076
  TextColor:this.GetColor(value, 0)
42069
42077
  };
42070
42078
 
42079
+ if (this.YClose===0)
42080
+ {
42081
+ titleItem.Text="--.--";
42082
+ titleItem.TextColor=this.TitleColor
42083
+ }
42084
+
42085
+
42071
42086
  return titleItem;
42072
42087
  }
42073
42088
 
@@ -48784,7 +48799,7 @@ function FrameSplitMinutePriceY()
48784
48799
  var strPrice=price.toFixed(defaultfloatPrecision); //价格刻度字符串
48785
48800
  if (this.IsShowLeftText) coordinate.Message[0]=strPrice;
48786
48801
 
48787
- if (this.YClose)
48802
+ if (this.YClose && this.YClose!=0)
48788
48803
  {
48789
48804
  var per=(price/this.YClose-1)*100;
48790
48805
  if (per>0) coordinate.TextColor=g_JSChartResource.UpTextColor;
@@ -48868,7 +48883,7 @@ function FrameSplitMinutePriceY()
48868
48883
  var strPrice=price.toFixed(defaultfloatPrecision); //价格刻度字符串
48869
48884
  if (this.IsShowLeftText) coordinate.Message[0]=strPrice
48870
48885
 
48871
- if (IFrameSplitOperator.IsNumber(this.YClose))
48886
+ if (IFrameSplitOperator.IsNumber(this.YClose) && this.YClose!=0)
48872
48887
  {
48873
48888
  var per=(price/this.YClose-1)*100;
48874
48889
  if (per>0) coordinate.TextColor=g_JSChartResource.UpTextColor;
@@ -16,6 +16,7 @@ function JSKeyboardChart(divElement)
16
16
  {
17
17
  this.DivElement=divElement;
18
18
  this.JSChartContainer; //表格控件
19
+ this.ResizeListener; //大小变动监听
19
20
 
20
21
  //h5 canvas
21
22
  this.CanvasElement=document.createElement("canvas");
@@ -33,9 +34,18 @@ function JSKeyboardChart(divElement)
33
34
  this.OnSize=function()
34
35
  {
35
36
  //画布大小通过div获取
36
- var height=parseInt(this.DivElement.style.height.replace("px",""));
37
+ var height=this.DivElement.offsetHeight;
38
+ var width=this.DivElement.offsetWidth;
39
+ if (this.DivElement.style.height && this.DivElement.style.width)
40
+ {
41
+ if (this.DivElement.style.height.includes("px"))
42
+ height=parseInt(this.DivElement.style.height.replace("px",""));
43
+ if (this.DivElement.style.width.includes("px"))
44
+ width=parseInt(this.DivElement.style.width.replace("px",""));
45
+ }
46
+
37
47
  this.CanvasElement.height=height;
38
- this.CanvasElement.width=parseInt(this.DivElement.style.width.replace("px",""));
48
+ this.CanvasElement.width=width;
39
49
  this.CanvasElement.style.width=this.CanvasElement.width+'px';
40
50
  this.CanvasElement.style.height=this.CanvasElement.height+'px';
41
51
 
@@ -62,6 +72,18 @@ function JSKeyboardChart(divElement)
62
72
  this.JSChartContainer=chart;
63
73
  this.DivElement.JSChart=this; //div中保存一份
64
74
 
75
+ //注册事件
76
+ if (option.EventCallback)
77
+ {
78
+ for(var i=0;i<option.EventCallback.length;++i)
79
+ {
80
+ var item=option.EventCallback[i];
81
+ chart.AddEventCallback(item);
82
+ }
83
+ }
84
+
85
+ if (option.EnableResize==true) this.CreateResizeListener();
86
+
65
87
  chart.Draw();
66
88
  }
67
89
 
@@ -106,6 +128,18 @@ function JSKeyboardChart(divElement)
106
128
  chart.Frame.ChartBorder.Bottom*=pixelTatio;
107
129
  }
108
130
 
131
+ this.CreateResizeListener=function()
132
+ {
133
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
134
+ this.ResizeListener.observe(this.DivElement);
135
+ }
136
+
137
+ this.OnDivResize=function(entries)
138
+ {
139
+ JSConsole.Chart.Log("[JSKeyboardChart::OnDivResize] entries=", entries);
140
+ this.OnSize();
141
+ }
142
+
109
143
  /////////////////////////////////////////////////////////////////////////////
110
144
  //对外接口
111
145
  this.SetColumn=function(aryColumn, option)
@@ -15,6 +15,7 @@ function JSReportChart(divElement)
15
15
  {
16
16
  this.DivElement=divElement;
17
17
  this.JSChartContainer; //表格控件
18
+ this.ResizeListener; //大小变动监听
18
19
 
19
20
  //h5 canvas
20
21
  this.CanvasElement=document.createElement("canvas");
@@ -141,6 +142,16 @@ function JSReportChart(divElement)
141
142
  this.JSChartContainer=chart;
142
143
  this.DivElement.JSChart=this; //div中保存一份
143
144
 
145
+ //注册事件
146
+ if (option.EventCallback)
147
+ {
148
+ for(var i=0;i<option.EventCallback.length;++i)
149
+ {
150
+ var item=option.EventCallback[i];
151
+ chart.AddEventCallback(item);
152
+ }
153
+ }
154
+
144
155
  if (option.EnableResize==true) this.CreateResizeListener();
145
156
 
146
157
  if (option.EnablePopMenuV2===true) chart.InitalPopMenu();
@@ -1504,7 +1504,7 @@ input[type="color"] {
1504
1504
  position: absolute;
1505
1505
  height: 500px;
1506
1506
  width: 600px;
1507
- z-index: 999;
1507
+ z-index: 809;
1508
1508
  visibility:'hidden';
1509
1509
  background-color: rgba(255,255,255,0.95);
1510
1510
  border: solid 1px rgba(200, 210, 219, 0.92);
@@ -1538,6 +1538,65 @@ input[type="color"] {
1538
1538
 
1539
1539
 
1540
1540
 
1541
+ /*
1542
+ Copyright (c) 2018 jones
1543
+
1544
+ http://www.apache.org/licenses/LICENSE-2.0
1545
+
1546
+ 开源项目 https://github.com/jones2000/HQChart
1547
+
1548
+ jones_2000@163.com
1549
+
1550
+ 内置键盘精灵对话框
1551
+ */
1552
+
1553
+ .jchart_pop_keyboard_dailog
1554
+ {
1555
+ position: absolute;
1556
+ width: 230px;
1557
+ height:380px;
1558
+ left: 1px;
1559
+ top: 1px;
1560
+ z-index: 999;
1561
+ visibility:hidden;
1562
+ background-color: rgba(255,255,255,0.95);
1563
+ border: solid 1px rgb(0, 0, 0);
1564
+ display: flex;
1565
+ flex-flow: column;
1566
+ }
1567
+
1568
+ .jschart_keyboard_Title_Div
1569
+ {
1570
+ padding-left: 2px;
1571
+ height:20px;
1572
+ border-bottom: 1px solid;
1573
+ border-color: rgb(204,204,204);
1574
+ display: flex;
1575
+ cursor: default;
1576
+ user-select: none;
1577
+ background-color:rgb(222,222,222)
1578
+ }
1579
+
1580
+ .jschart_keyboard_Input_Div
1581
+ {
1582
+ display: flex;
1583
+ height:25px;
1584
+
1585
+ }
1586
+
1587
+ .jschart_keyboard_input
1588
+ {
1589
+ width:100%;
1590
+ margin:2px;
1591
+ }
1592
+
1593
+ .jschart_keyboard_Chart_Div
1594
+ {
1595
+ flex: 1
1596
+ }
1597
+
1598
+
1599
+
1541
1600
 
1542
1601
 
1543
1602