hqchart 1.1.15160 → 1.1.15170

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.15160",
3
+ "version": "1.1.15170",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -666,7 +666,7 @@ function JSDialogTooltip()
666
666
  if (titleChart.ClassName!="DynamicChartTitlePainting") continue;
667
667
  if (!IFrameSplitOperator.IsNonEmptyArray(titleChart.Data)) continue;
668
668
 
669
- var indexName=titleChart.Title;
669
+ var indexName=titleChart.Title || "--";
670
670
  //if (titleChart.ArgumentsText) indexName+=titleChart.ArgumentsText;
671
671
  aryText.push({ Title:indexName, IsMergeCell:true, TitleClassName:this.TitleAlign.Center });
672
672
  for(j=0;j<titleChart.Data.length;++j)
@@ -333,12 +333,23 @@ var Character =
333
333
  return (cp >= 0x30 && cp <= 0x39) || (cp >= 0x41 && cp <= 0x46) || (cp >= 0x61 && cp <= 0x66); // a..f
334
334
  },
335
335
 
336
- isOctalDigit: function (cp)
336
+ IsOctalDigit: function (cp)
337
337
  {
338
338
  return (cp >= 0x30 && cp <= 0x37); // 0..7
339
339
  }
340
340
  }
341
341
 
342
+
343
+ function HexValue(ch)
344
+ {
345
+ return '0123456789abcdef'.indexOf(ch.toLowerCase());
346
+ }
347
+
348
+ function OctalValue(ch)
349
+ {
350
+ return '01234567'.indexOf(ch);
351
+ }
352
+
342
353
  var TOKEN_NAME={};
343
354
  TOKEN_NAME[1 /* BooleanLiteral */] = 'Boolean';
344
355
  TOKEN_NAME[2 /* EOF */] = '<end>';
@@ -437,6 +448,7 @@ JSComplierHelper.GetConvertValueName=function(funcName)
437
448
  function ErrorHandler()
438
449
  {
439
450
  this.Error=[];
451
+ this.IsTolerant=false;
440
452
 
441
453
  this.RecordError=function(error)
442
454
  {
@@ -463,7 +475,7 @@ function ErrorHandler()
463
475
  return error;
464
476
  }
465
477
 
466
- this.CreateError=function(index, line, col, description, word)
478
+ this.CreateError=function(index, line, col, description, word=null)
467
479
  {
468
480
  let msg='Line ' + line + ': ' + description;
469
481
  let error=this.ConstructError(msg,col);
@@ -480,6 +492,13 @@ function ErrorHandler()
480
492
  throw error;
481
493
  }
482
494
 
495
+ this.TolerateError=function(index, line, col, description)
496
+ {
497
+ const error = this.CreateError(index, line, col, description);
498
+ if (this.IsTolerant) this.RecordError(error);
499
+ else throw error;
500
+ }
501
+
483
502
  //重新下载数据
484
503
  this.ThrowDownloadJob=function(index, line, col, description,job)
485
504
  {
@@ -517,12 +536,22 @@ function Scanner(code, ErrorHandler)
517
536
  return this.Index>=this.Length;
518
537
  }
519
538
 
539
+ this.ThrowUnexpectedToken=function(message=Messages.UnexpectedTokenIllegal)
540
+ {
541
+ return this.ErrorHandler.ThrowError(this.Index, this.LineNumber, this.Index - this.LineStart + 1, message);
542
+ }
543
+
544
+ this.TolerateUnexpectedToken=function(message = Messages.UnexpectedTokenIllegal)
545
+ {
546
+ this.ErrorHandler.TolerateError(this.Index, this.LineNumber, this.Index - this.LineStart + 1, message);
547
+ }
548
+
520
549
  this.IsKeyword=function(id)
521
550
  {
522
551
  return false;
523
552
  }
524
553
 
525
- this.CodePointAt = function (i)
554
+ this.CodePointAt=function (i)
526
555
  {
527
556
  let cp = this.Source.charCodeAt(i);
528
557
  if (cp >= 0xD800 && cp <= 0xDBFF)
@@ -536,6 +565,27 @@ function Scanner(code, ErrorHandler)
536
565
  return cp;
537
566
  }
538
567
 
568
+ //8进制->10进制
569
+ this.OctalToDecimal=function(ch)
570
+ {
571
+ // \0 is not octal escape sequence
572
+ let octal = (ch !== '0');
573
+ let code = OctalValue(ch);
574
+
575
+ if (!this.IsEOF() && Character.IsOctalDigit(this.Source.charCodeAt(this.Index)))
576
+ {
577
+ octal = true;
578
+ code = code * 8 + OctalValue(this.Source[this.Index++]);
579
+
580
+ // 3 digits are only allowed when string starts
581
+ // with 0, 1, 2, 3
582
+ if ('0123'.indexOf(ch) >= 0 && !this.IsEOF() && Character.IsOctalDigit(this.Source.charCodeAt(this.Index)))
583
+ code = code * 8 + OctalValue(this.Source[this.Index++]);
584
+ }
585
+
586
+ return { Code: code, Octal: octal };
587
+ }
588
+
539
589
  this.Lex=function()
540
590
  {
541
591
  if (this.IsEOF()) return { Type:2/*EOF*/, Value:'', LineNumber:this.LineNumber, LineStart:this.LineStart, Start:this.Index, End:this.Index };
@@ -622,6 +672,123 @@ function Scanner(code, ErrorHandler)
622
672
  return this.Source.slice(start,this.Index);
623
673
  }
624
674
 
675
+ this.GetComplexIdentifier=function()
676
+ {
677
+ let cp = this.CodePointAt(this.Index);
678
+ let id = Character.FromCodePoint(cp);
679
+ this.Index += id.length;
680
+
681
+ // '\u' (U+005C, U+0075) denotes an escaped character.
682
+ let ch;
683
+ if (cp === 0x5C)
684
+ {
685
+ if (this.Source.charCodeAt(this.Index) !== 0x75)
686
+ this.ThrowUnexpectedToken();
687
+
688
+ ++this.Index;
689
+ if (this.Source[this.Index] === '{')
690
+ {
691
+ ++this.Index;
692
+ ch = this.ScanUnicodeCodePointEscape();
693
+ }
694
+ else
695
+ {
696
+ ch = this.ScanHexEscape('u');
697
+ if (ch === null || ch === '\\' || !Character.IsIdentifierStart(ch.charCodeAt(0)))
698
+ this.ThrowUnexpectedToken();
699
+ }
700
+ id = ch;
701
+ }
702
+
703
+ while (!this.IsEOF())
704
+ {
705
+ cp = this.CodePointAt(this.Index);
706
+ if (!Character.IsIdentifierPart(cp))
707
+ break;
708
+
709
+ ch = Character.FromCodePoint(cp);
710
+ id += ch;
711
+ this.Index += ch.length;
712
+
713
+ // '\u' (U+005C, U+0075) denotes an escaped character.
714
+ if (cp === 0x5C)
715
+ {
716
+ id = id.substring(0, id.length - 1);
717
+ if (this.Source.charCodeAt(this.Index) !== 0x75)
718
+ this.ThrowUnexpectedToken();
719
+
720
+ ++this.Index;
721
+ if (this.Source[this.Index] === '{')
722
+ {
723
+ ++this.Index;
724
+ ch = this.ScanUnicodeCodePointEscape();
725
+ }
726
+ else
727
+ {
728
+ ch = this.ScanHexEscape('u');
729
+ if (ch === null || ch === '\\' || !Character.IsIdentifierPart(ch.charCodeAt(0)))
730
+ this.ThrowUnexpectedToken();
731
+ }
732
+ id += ch;
733
+ }
734
+ }
735
+
736
+ return id;
737
+ }
738
+
739
+ this.ScanUnicodeCodePointEscape=function()
740
+ {
741
+ const result = this.TryToScanUnicodeCodePointEscape();
742
+ if (result === null)
743
+ return this.ThrowUnexpectedToken();
744
+
745
+ return result;
746
+ }
747
+
748
+ this.TryToScanUnicodeCodePointEscape=function()
749
+ {
750
+ let ch = this.Source[this.Index];
751
+ let code = 0;
752
+
753
+ // At least, one hex digit is required.
754
+ if (ch === '}')
755
+ return null;
756
+
757
+ while (!this.IsEOF())
758
+ {
759
+ ch = this.Source[this.Index++];
760
+ if (!Character.IsHexDigit(ch.charCodeAt(0)))
761
+ break;
762
+
763
+ code = code * 16 + HexValue(ch);
764
+ }
765
+
766
+ if (code > 0x10FFFF || ch !== '}')
767
+ return null;
768
+
769
+ return Character.FromCodePoint(code);
770
+ }
771
+
772
+ this.ScanHexEscape=function(prefix)
773
+ {
774
+ const len = (prefix === 'u') ? 4 : 2;
775
+ let code = 0;
776
+
777
+ for (let i = 0; i < len; ++i)
778
+ {
779
+ if (!this.IsEOF() && Character.IsHexDigit(this.Source.charCodeAt(this.Index)))
780
+ {
781
+ code = code * 16 + HexValue(this.source[this.Index++]);
782
+ }
783
+ else
784
+ {
785
+ return null;
786
+ }
787
+ }
788
+
789
+ return String.fromCharCode(code);
790
+ }
791
+
625
792
  //操作符 https://tc39.github.io/ecma262/#sec-punctuators
626
793
  this.ScanPunctuator=function()
627
794
  {
@@ -693,7 +860,72 @@ function Scanner(code, ErrorHandler)
693
860
  }
694
861
  else if (ch=='\\') //字符串转义
695
862
  {
696
- throw "not complete";
863
+ ch = this.Source[this.Index++];
864
+ if (!ch || !Character.IsLineTerminator(ch.charCodeAt(0)))
865
+ {
866
+ switch (ch)
867
+ {
868
+ case 'u':
869
+ if (this.Source[this.Index] === '{')
870
+ {
871
+ ++this.Index;
872
+ str += this.ScanUnicodeCodePointEscape();
873
+ }
874
+ else
875
+ {
876
+ const unescapedChar = this.ScanHexEscape(ch);
877
+ if (unescapedChar === null)
878
+ this.ThrowUnexpectedToken();
879
+
880
+ str += unescapedChar;
881
+ }
882
+ break;
883
+ case 'x': //十六进制 它的转义规则:\x<hex>,\x后跟上2位十六进制数
884
+ const unescaped = this.ScanHexEscape(ch);
885
+ if (unescaped === null)
886
+ this.ThrowUnexpectedToken(Messages.InvalidHexEscapeSequence);
887
+
888
+ str += unescaped;
889
+ break;
890
+ case 'n': //换行符
891
+ str += '\n';
892
+ break;
893
+ case 'r': //回车键
894
+ str += '\r';
895
+ break;
896
+ case 't': //制表符
897
+ str += '\t';
898
+ break;
899
+ case 'b': //后退键
900
+ str += '\b';
901
+ break;
902
+ case 'f': //换页符
903
+ str += '\f';
904
+ break;
905
+ case 'v': //垂直制表符
906
+ str += '\x0B';
907
+ break;
908
+ case '8':
909
+ case '9':
910
+ str += ch;
911
+ this.TolerateUnexpectedToken();
912
+ break;
913
+ default:
914
+ if (ch && Character.IsOctalDigit(ch.charCodeAt(0))) //反斜杠后面跟3位八进制数,就代表一个转义字符
915
+ {
916
+ const octToDec = this.OctalToDecimal(ch);
917
+
918
+ octal = octToDec.Octal || octal;
919
+ str += String.fromCharCode(octToDec.Code);
920
+ }
921
+ else
922
+ {
923
+ str += ch;
924
+ }
925
+ break;
926
+ }
927
+ }
928
+
697
929
  }
698
930
  else if (Character.IsLineTerminator(ch.charCodeAt(0)))
699
931
  {
@@ -8503,7 +8503,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
8503
8503
  pt.X=this.Frame.GetXFromIndex(this.CursorIndex); //X轴动态变的
8504
8504
  if (this.ChartCorssCursor)
8505
8505
  {
8506
- if (this.ChartCorssCursor.Status==1)
8506
+ if ((this.ChartCorssCursor.Status&JSCHART_CORSSCURSOR_STATUS_ID.LINE_ID)>0)
8507
8507
  {
8508
8508
 
8509
8509
  }
@@ -10128,6 +10128,60 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10128
10128
  return true;
10129
10129
  }
10130
10130
 
10131
+ /*
10132
+ //对比画图
10133
+ this.CompareChartDrawPicture=function(aryData)
10134
+ {
10135
+ var mapData=new Map();
10136
+ if (IFrameSplitOperator.IsNonEmptyArray(aryData))
10137
+ {
10138
+ for(var i=0;i<aryData.length;++i)
10139
+ {
10140
+ var item=aryData[i];
10141
+ if (!item.Guid) continue;
10142
+ mapData.set(item.Guid, item);
10143
+ }
10144
+ }
10145
+
10146
+ var mapChart=new Map();
10147
+ if (IFrameSplitOperator.IsNonEmptyArray(this.ChartDrawPicture))
10148
+ {
10149
+ for(var i=0;i<this.ChartDrawPicture.length;++i)
10150
+ {
10151
+ var item=this.ChartDrawPicture[i];
10152
+ mapChart.set(item.Guid, item);
10153
+ }
10154
+ }
10155
+
10156
+ var aryDelete=[], aryEqual=[], aryNew=[];
10157
+
10158
+ for(var mapItem of mapData)
10159
+ {
10160
+ var item=mapItem[1];
10161
+ if (mapChart.has(item.Guid)) //存在的
10162
+ {
10163
+ var chart=mapChart.get(item.Guid);
10164
+ aryEqual.push({ Chart:chart, Data:item });
10165
+ }
10166
+ else
10167
+ {
10168
+ aryNew.push({ Data:item }); //新建
10169
+ }
10170
+ }
10171
+
10172
+ for(var mapItem of mapChart)
10173
+ {
10174
+ var item=mapItem[1];
10175
+ if (!mapData.has(item.Guid))
10176
+ {
10177
+ aryDelete.push({ Chart:item }); //删除的
10178
+ }
10179
+ }
10180
+
10181
+ return { AryDelete:aryDelete, AryNew:aryNew, AryEqual:aryEqual };
10182
+ }
10183
+ */
10184
+
10131
10185
  //清空所有的画线工具 option={ Draw:false/true }
10132
10186
  this.ClearChartDrawPicture=function(drawPicture, option)
10133
10187
  {
@@ -15764,7 +15818,8 @@ function AverageWidthFrame()
15764
15818
  this.Canvas.fillRect(rectLeft,bgTop,itemText.Width,textHeight);
15765
15819
  }
15766
15820
 
15767
- this.Canvas.fillStyle = item.TextColor;
15821
+ if (itemText.TextColor) this.Canvas.fillStyle=itemText.TextColor;
15822
+ else this.Canvas.fillStyle = item.TextColor;
15768
15823
  this.Canvas.fillText(itemText.Text, textLeft - 1*pixelTatio, yText);
15769
15824
  }
15770
15825
 
@@ -15778,7 +15833,8 @@ function AverageWidthFrame()
15778
15833
  }
15779
15834
  }
15780
15835
  }
15781
- else if (item.Message[1]) //右
15836
+
15837
+ if (item.Message[1]) // 右
15782
15838
  {
15783
15839
  if (borderRight<10 || position==1)
15784
15840
  {
@@ -62604,6 +62660,7 @@ function DynamicChartTitlePainting()
62604
62660
  if (option)
62605
62661
  {
62606
62662
  if (option.DynamicTitle===true) this.DynamicTitle={ OutName:null, OutValue:null }; //主图胴动态标题
62663
+ if (option.ArgumentsText===true) this.ArgumentsText=null;
62607
62664
  }
62608
62665
  }
62609
62666
 
@@ -84552,7 +84609,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
84552
84609
 
84553
84610
  this.RecvRealtimeData=function(data)
84554
84611
  {
84555
- if (this.IsOnTouch==true) return; //正在操作手势不更新数据
84612
+ if (this.IsOnTouch==true) return; //正在操作手势不更新数据
84556
84613
  if (this.IsPauseUpdateByKeyboard()) return; //正在操作键盘不更新数据
84557
84614
 
84558
84615
  if (data.Ver==3.0)
@@ -85636,7 +85693,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85636
85693
  //清空东条标题
85637
85694
  var titleIndex=windowIndex+1;
85638
85695
  var chartTitle=this.TitlePaint[titleIndex];
85639
- if (chartTitle) chartTitle.Clear({ DynamicTitle:true });
85696
+ if (chartTitle) chartTitle.Clear({ DynamicTitle:true , ArgumentsText:true});
85640
85697
  }
85641
85698
 
85642
85699
  //显示隐藏主图K线