hqchart 1.1.13743 → 1.1.13754

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.
@@ -30665,6 +30665,7 @@ function ChartLine()
30665
30665
  this.LineWidth; //线段宽度
30666
30666
  this.DrawType=0; //画图方式 0=无效数平滑 1=无效数不画断开
30667
30667
  this.IsDotLine=false; //虚线
30668
+ this.LineDash=g_JSChartResource.DOTLINE.LineDash;
30668
30669
  this.BreakPoint; //断开的点索引 Set();
30669
30670
 
30670
30671
 
@@ -30710,7 +30711,7 @@ function ChartLine()
30710
30711
 
30711
30712
  this.Canvas.save();
30712
30713
  if (this.LineWidth>0) this.Canvas.lineWidth=this.LineWidth * GetDevicePixelRatio();
30713
- if (this.IsDotLine) this.Canvas.setLineDash(g_JSChartResource.DOTLINE.LineDash); //画虚线
30714
+ if (this.IsDotLine) this.Canvas.setLineDash(this.LineDash); //画虚线
30714
30715
  var bFirstPoint=true;
30715
30716
  var drawCount=0;
30716
30717
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
@@ -30777,7 +30778,7 @@ function ChartLine()
30777
30778
  this.ClipClient(bHScreen);
30778
30779
  if (this.LineWidth>0) this.Canvas.lineWidth=this.LineWidth * GetDevicePixelRatio();
30779
30780
  this.Canvas.strokeStyle=this.Color;
30780
- if (this.IsDotLine) this.Canvas.setLineDash(g_JSChartResource.DOTLINE.LineDash); //画虚线
30781
+ if (this.IsDotLine) this.Canvas.setLineDash(this.LineDash); //画虚线
30781
30782
 
30782
30783
  var bFirstPoint=true;
30783
30784
  var ptFirst=null;; //第1个点
@@ -30874,7 +30875,7 @@ function ChartLine()
30874
30875
  this.ClipClient(bHScreen);
30875
30876
  if (this.LineWidth>0) this.Canvas.lineWidth=this.LineWidth * GetDevicePixelRatio();
30876
30877
  this.Canvas.strokeStyle=this.Color;
30877
- if (this.IsDotLine) this.Canvas.setLineDash(g_JSChartResource.DOTLINE.LineDash); //画虚线
30878
+ if (this.IsDotLine) this.Canvas.setLineDash(this.LineDash); //画虚线
30878
30879
 
30879
30880
  var bFirstPoint=true;
30880
30881
  var ptFirst=null;; //第1个点
@@ -36046,16 +36047,38 @@ function ChartClipColorStick()
36046
36047
  this.UpColor=g_JSChartResource.UpBarColor;
36047
36048
  this.DownColor=g_JSChartResource.DownBarColor;
36048
36049
  this.LineWidth=1;
36050
+ this.Style=0; //1=同方向 0=上下两个方向
36051
+
36049
36052
  //差值线
36050
36053
  this.DownDiffColor=g_JSChartResource.DownBarColor;
36051
36054
  this.UpDiffColor=g_JSChartResource.UpBarColor;
36052
36055
 
36056
+ //文字
36057
+ this.TextLabelConfig=
36058
+ {
36059
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
36060
+ TextMargin:{ Left:2, Right:2, Bottom:2, Top:2 },
36061
+ TextColor:"rgb(230,230,230)",
36062
+ UpColor:"rgb(137,16,19)",
36063
+ DownColor:"rgb(44,104,57)",
36064
+ UnchangeColor:"rgb(111,112,115)",
36065
+ BorderColor:"rgb(0,0,0)",
36066
+
36067
+ //缓存
36068
+ LabelWidth:0,
36069
+ TextHeight:0,
36070
+ MaxTextWidth:0,
36071
+ }
36072
+
36053
36073
  this.BaseLineColor; //基准线
36054
36074
 
36055
36075
  this.BaseValue=0;
36056
36076
  this.Super_GetMaxMin=this.GetMaxMin; //父类的方法
36057
36077
  this.ValueRange; //{ Max:, Min: } //固定最大最小值
36058
36078
 
36079
+ this.IsShowText=false;
36080
+
36081
+
36059
36082
  this.SetOption=function(option)
36060
36083
  {
36061
36084
  if (!option) return;
@@ -36066,11 +36089,18 @@ function ChartClipColorStick()
36066
36089
  if (option.UpDiffColor) this.UpDiffColor=option.UpDiffColor;
36067
36090
  if (option.BaseLineColor) this.BaseLineColor=option.BaseLineColor;
36068
36091
  if (IFrameSplitOperator.IsNumber(option.BaseValue)) this.BaseValue=option.BaseValue;
36092
+ if (IFrameSplitOperator.IsNumber(option.Style)) this.Style=option.Style;
36069
36093
  if (option.ValueRange) this.ValueRange=option.ValueRange;
36094
+
36070
36095
  }
36071
36096
 
36072
36097
  this.Draw=function()
36073
36098
  {
36099
+ this.IsShowText=false;
36100
+ this.TextLabelConfig.LabelWidth=0;
36101
+ this.TextLabelConfig.TextHeight=0;
36102
+ this.TextLabelConfig.MaxTextWidth=0;
36103
+
36074
36104
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
36075
36105
  if (this.IsShowIndexTitleOnly()) return;
36076
36106
  if (this.IsHideScriptIndex()) return;
@@ -36081,23 +36111,44 @@ function ChartClipColorStick()
36081
36111
  return;
36082
36112
  }
36083
36113
 
36084
- this.Canvas.save();
36085
36114
  var dataWidth=this.ChartFrame.DataWidth;
36115
+ var distanceWidth=this.ChartFrame.DistanceWidth;
36116
+ var xPointCount=this.ChartFrame.XPointCount;
36117
+ var bHScreen=this.ChartFrame.IsHScreen===true;
36118
+
36086
36119
  var lineWidth=this.LineWidth*GetDevicePixelRatio();
36087
36120
  if (this.LineWidth==50) lineWidth=dataWidth;
36088
36121
  else if (lineWidth>dataWidth) lineWidth=dataWidth;
36089
-
36122
+
36123
+ if (!bHScreen)
36124
+ {
36125
+ var itemWidth=dataWidth+distanceWidth;
36126
+ var bMinute=this.IsMinuteFrame();
36127
+ if (bMinute)
36128
+ {
36129
+ var border=this.ChartBorder.GetBorder();
36130
+ itemWidth=(border.Right-border.Left)/(xPointCount-1);
36131
+ }
36132
+
36133
+ this.Canvas.font=this.TextLabelConfig.Font;
36134
+ this.TextLabelConfig.MaxTextWidth=this.Canvas.measureText("-888").width;
36135
+ this.TextLabelConfig.LabelWidth=this.TextLabelConfig.MaxTextWidth+this.TextLabelConfig.TextMargin.Left+this.TextLabelConfig.TextMargin.Right;
36136
+ this.IsShowText=itemWidth>this.TextLabelConfig.LabelWidth;
36137
+ this.TextLabelConfig.TextHeight=this.Canvas.measureText("擎").width;
36138
+ }
36139
+
36140
+ this.Canvas.save();
36090
36141
  if (IFrameSplitOperator.IsNumber(this.BaseValue) && this.BaseValue!=0)
36091
36142
  {
36092
36143
  this.DrawBaseLine();
36093
36144
 
36094
- if (this.BaseValue>0) this.DrawBars(lineWidth, true);
36095
- else this.DrawBars(lineWidth, false);
36145
+ if (this.BaseValue>0) this.DrawBars(lineWidth, true, true);
36146
+ else this.DrawBars(lineWidth, false, true);
36096
36147
  }
36097
36148
  else
36098
36149
  {
36099
36150
  //上下分开画
36100
- this.DrawBars(lineWidth, true);
36151
+ this.DrawBars(lineWidth, true, true);
36101
36152
  this.DrawBars(lineWidth, false);
36102
36153
  }
36103
36154
 
@@ -36105,15 +36156,15 @@ function ChartClipColorStick()
36105
36156
  this.Canvas.restore();
36106
36157
  }
36107
36158
 
36108
- this.DrawBars=function(lineWidth, bUpBar)
36159
+ this.DrawBars=function(lineWidth, bUpBar, bDrawLabel)
36109
36160
  {
36110
36161
  var isMinute=this.IsMinuteFrame();
36111
36162
  var dataWidth=this.ChartFrame.DataWidth;
36112
36163
  var distanceWidth=this.ChartFrame.DistanceWidth;
36113
36164
  var xPointCount=this.ChartFrame.XPointCount;
36114
- var isHSCreen=this.ChartFrame.IsHScreen===true;
36165
+ var bHScreen=this.ChartFrame.IsHScreen===true;
36115
36166
 
36116
- if (isHSCreen)
36167
+ if (bHScreen)
36117
36168
  {
36118
36169
  var border=this.ChartBorder.GetHScreenBorder();
36119
36170
  var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
@@ -36132,19 +36183,14 @@ function ChartClipColorStick()
36132
36183
  }
36133
36184
 
36134
36185
  var yBottom=this.ChartFrame.GetYFromData(this.BaseValue);
36135
- var aryBar=[], aryDiffBar=[];
36136
- for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
36186
+ var aryBar=[], aryDiffBar=[], aryText=[];
36187
+ var preValue=null;
36188
+ var start=this.Data.DataOffset;
36189
+ if (start-1>0) preValue=this.Data.Data[start-1]; //上一个数值
36190
+ for(var i=start,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
36137
36191
  {
36138
36192
  var value=this.Data.Data[i];
36139
36193
  if (value==null) continue;
36140
- if (bUpBar)
36141
- {
36142
- if (value<0) continue;
36143
- }
36144
- else
36145
- {
36146
- if (value>=0) continue;
36147
- }
36148
36194
 
36149
36195
  if (isMinute)
36150
36196
  {
@@ -36160,6 +36206,21 @@ function ChartClipColorStick()
36160
36206
 
36161
36207
  if (x>chartright) break;
36162
36208
 
36209
+ var textItem={ X:x, Value:value };
36210
+ if (IFrameSplitOperator.IsNumber(preValue)) textItem.DiffValue=value-preValue;
36211
+ aryText.push(textItem);
36212
+
36213
+ preValue=value;
36214
+
36215
+ if (bUpBar)
36216
+ {
36217
+ if (value<0) continue;
36218
+ }
36219
+ else
36220
+ {
36221
+ if (value>=0) continue;
36222
+ }
36223
+
36163
36224
  var bDiffBar=false;
36164
36225
  var diffValue=null;
36165
36226
  if (this.BaseValue>0)
@@ -36167,7 +36228,10 @@ function ChartClipColorStick()
36167
36228
  if (value<this.BaseValue)
36168
36229
  {
36169
36230
  bDiffBar=true;
36170
- diffValue=this.BaseValue-(this.BaseValue-value);
36231
+ if (this.Style==1)
36232
+ diffValue=this.BaseValue+(this.BaseValue-value);
36233
+ else
36234
+ diffValue=this.BaseValue-(this.BaseValue-value);
36171
36235
  }
36172
36236
  }
36173
36237
  else if (this.BaseValue<0)
@@ -36175,19 +36239,22 @@ function ChartClipColorStick()
36175
36239
  if (value>this.BaseValue)
36176
36240
  {
36177
36241
  bDiffBar=true;
36178
- diffValue=this.BaseValue+(value-this.BaseValue)
36242
+ if (this.Style==1)
36243
+ diffValue=this.BaseValue-(value-this.BaseValue);
36244
+ else
36245
+ diffValue=this.BaseValue+(value-this.BaseValue)
36179
36246
  }
36180
36247
  }
36181
36248
 
36182
36249
  if (!bDiffBar)
36183
36250
  {
36184
36251
  var y=this.ChartFrame.GetYFromData(value);
36185
- aryBar.push({X:x, Y:y});
36252
+ aryBar.push({X:x, Y:y });
36186
36253
  }
36187
36254
  else
36188
36255
  {
36189
36256
  var y=this.ChartFrame.GetYFromData(diffValue);
36190
- aryDiffBar.push({X:x, Y:y});
36257
+ aryDiffBar.push({X:x, Y:y });
36191
36258
  }
36192
36259
  }
36193
36260
 
@@ -36196,6 +36263,7 @@ function ChartClipColorStick()
36196
36263
  else this.Canvas.strokeStyle=this.DownColor;
36197
36264
 
36198
36265
  this.DrawStick(aryBar,lineWidth,yBottom);
36266
+
36199
36267
 
36200
36268
  if (this.BaseValue>0)
36201
36269
  {
@@ -36208,13 +36276,14 @@ function ChartClipColorStick()
36208
36276
  this.DrawStick(aryDiffBar,lineWidth,yBottom);
36209
36277
  }
36210
36278
 
36279
+ if (this.IsShowText && bDrawLabel) this.DrawStickText(aryText);
36211
36280
  }
36212
36281
 
36213
36282
  this.DrawStick=function(aryData, lineWidth, yBottom)
36214
36283
  {
36215
36284
  if (!IFrameSplitOperator.IsNonEmptyArray(aryData)) return;
36216
36285
 
36217
- var isHSCreen=this.ChartFrame.IsHScreen===true;
36286
+ var bHScreen=this.ChartFrame.IsHScreen===true;
36218
36287
  var drawCount=0;
36219
36288
  this.Canvas.beginPath();
36220
36289
  for(var i=0; i<aryData.length; ++i)
@@ -36223,7 +36292,7 @@ function ChartClipColorStick()
36223
36292
  var y=item.Y;
36224
36293
  var xFix=ToFixedPoint2(lineWidth, item.X); //毛边修正
36225
36294
 
36226
- if (isHSCreen)
36295
+ if (bHScreen)
36227
36296
  {
36228
36297
  this.Canvas.moveTo(yBottom,ToFixedPoint(x));
36229
36298
  this.Canvas.lineTo(y,ToFixedPoint(x));
@@ -36245,14 +36314,14 @@ function ChartClipColorStick()
36245
36314
  if (!IFrameSplitOperator.IsNumber(this.BaseValue) || this.BaseValue==0) return;
36246
36315
  if (!this.BaseLineColor) return;
36247
36316
 
36248
- var isHSCreen=this.ChartFrame.IsHScreen===true;
36317
+ var bHScreen=this.ChartFrame.IsHScreen===true;
36249
36318
  var border=this.ChartFrame.GetBorder();
36250
36319
  var y=this.ChartFrame.GetYFromData(this.BaseValue);
36251
36320
 
36252
36321
  this.Canvas.strokeStyle=this.BaseLineColor;
36253
36322
  this.Canvas.lineWidth=1*GetDevicePixelRatio();
36254
36323
 
36255
- if (isHSCreen)
36324
+ if (bHScreen)
36256
36325
  {
36257
36326
 
36258
36327
  }
@@ -36266,6 +36335,107 @@ function ChartClipColorStick()
36266
36335
  }
36267
36336
  }
36268
36337
 
36338
+ this.DrawStickText=function(aryData)
36339
+ {
36340
+ var config=this.TextLabelConfig;
36341
+ this.Canvas.font=config.Font;
36342
+ var border=this.ChartBorder.GetBorder();
36343
+ var itemHeight=config.TextHeight*2+config.TextMargin.Bottom+config.TextMargin.Top;
36344
+ for(var i=0; i<aryData.length; ++i)
36345
+ {
36346
+ var item=aryData[i];
36347
+ var value=item.Value;
36348
+ var xCenter=item.X;
36349
+ var xLeft=xCenter-config.LabelWidth/2;
36350
+
36351
+ var rtDraw={ Left:xLeft, Width:config.LabelWidth, Top:border.BottomEx+1, Height:itemHeight };
36352
+ rtDraw.Right=rtDraw.Left+rtDraw.Width;
36353
+ rtDraw.Bottom=rtDraw.Top+rtDraw.Height;
36354
+ if (IFrameSplitOperator.IsNumber(value))
36355
+ {
36356
+ var bgColor=config.UnchangeColor;
36357
+ if (value>0) bgColor=config.UpColor;
36358
+ else if (value<0) bgColor=config.DownColor;
36359
+ this.DrawTextLabel(value, bgColor, config.BorderColor, config.TextColor, rtDraw, config.TextHeight, config.MaxTextWidth, config.TextMargin);
36360
+ }
36361
+
36362
+ var value=item.DiffValue;
36363
+ var rtDraw={ Left:xLeft, Width:config.LabelWidth, Bottom:border.TopEx-1, Height:itemHeight };
36364
+ rtDraw.Right=rtDraw.Left+rtDraw.Width;
36365
+ rtDraw.Top=rtDraw.Bottom-rtDraw.Height;
36366
+ if (IFrameSplitOperator.IsNumber(value))
36367
+ {
36368
+ var bgColor=config.UnchangeColor;
36369
+ if (value>0) bgColor=config.UpColor;
36370
+ else if (value<0) bgColor=config.DownColor;
36371
+ this.DrawTextLabel(value, bgColor, config.BorderColor, config.TextColor, rtDraw, config.TextHeight, config.MaxTextWidth, config.TextMargin);
36372
+ }
36373
+ }
36374
+ }
36375
+
36376
+ //数值标签
36377
+ this.DrawTextLabel=function(value, clrGB, clrBorder, clrText, rtDraw, textHeight, textWidth, textMargin)
36378
+ {
36379
+ if (clrGB)
36380
+ {
36381
+ this.Canvas.fillStyle=clrGB;
36382
+ this.Canvas.fillRect(rtDraw.Left ,rtDraw.Top, (rtDraw.Width), (rtDraw.Height));
36383
+ }
36384
+
36385
+ if (clrBorder)
36386
+ {
36387
+ this.Canvas.lineWidth=2;
36388
+ this.Canvas.strokeStyle=clrBorder;
36389
+ this.Canvas.strokeRect(rtDraw.Left, rtDraw.Top, rtDraw.Width, rtDraw.Height);
36390
+ }
36391
+ else
36392
+ {
36393
+ this.Canvas.lineWidth=1;
36394
+ this.Canvas.strokeStyle="rgb(0,0,0)";
36395
+ this.Canvas.strokeRect(rtDraw.Left, rtDraw.Top, rtDraw.Width, rtDraw.Height);
36396
+ }
36397
+
36398
+ var aryText=[null, null]; //大于3位数的 2行输出
36399
+ var sign=""; //负数
36400
+ if (value<0)
36401
+ {
36402
+ value=Math.abs(value);
36403
+ sign='-';
36404
+ }
36405
+
36406
+ if (value>999)
36407
+ {
36408
+ var thousand=parseInt(value/1000);
36409
+ var hundred=parseInt(value%1000);
36410
+
36411
+ aryText[0]=`${sign}${thousand}`;
36412
+ aryText[1]=`${hundred}`;
36413
+ if (hundred<10) aryText[1]=`00${hundred}`;
36414
+ else if (hundred<100) aryText[1]=`0${hundred}`;
36415
+ }
36416
+ else
36417
+ {
36418
+ aryText[1]=`${sign}${value.toFixed(0)}`;
36419
+ }
36420
+
36421
+ this.Canvas.textAlign="right";
36422
+ this.Canvas.textBaseline="top";
36423
+ var xRight=rtDraw.Right-(rtDraw.Right-rtDraw.Left-textWidth)/2;
36424
+
36425
+ this.Canvas.fillStyle=clrText;
36426
+ var yText=textMargin.Top+rtDraw.Top;
36427
+ for(var i=0;i<aryText.length;++i)
36428
+ {
36429
+ var text=aryText[i];
36430
+ if (text)
36431
+ {
36432
+ this.Canvas.fillText(text,xRight,yText);
36433
+ }
36434
+
36435
+ yText+=textHeight;
36436
+ }
36437
+ }
36438
+
36269
36439
  this.GetMaxMin=function()
36270
36440
  {
36271
36441
  if (!IFrameSplitOperator.IsNumber(this.BaseValue) || this.BaseValue==0)
@@ -36328,13 +36498,36 @@ function ChartClipColorStick()
36328
36498
 
36329
36499
  if (this.BaseValue>0)
36330
36500
  {
36331
- if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Min))
36332
- range.Min-=maxDiffValue;
36501
+ if (this.Style==1)
36502
+ {
36503
+ if (IFrameSplitOperator.IsNumber(maxDiffValue))
36504
+ {
36505
+ var value=this.BaseValue+maxDiffValue;
36506
+ if (IFrameSplitOperator.IsNumber(range.Max) || range.Max<value) range.Max=value;
36507
+ }
36508
+ }
36509
+ else
36510
+ {
36511
+ if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Min))
36512
+ range.Min-=maxDiffValue;
36513
+ }
36514
+
36333
36515
  }
36334
36516
  else
36335
36517
  {
36336
- if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Max))
36337
- range.Max+=maxDiffValue;
36518
+ if (this.Style==1)
36519
+ {
36520
+ if (IFrameSplitOperator.IsNumber(maxDiffValue))
36521
+ {
36522
+ var value=this.BaseValue-maxDiffValue;
36523
+ if (IFrameSplitOperator.IsNumber(range.Min) || range.Min>value) range.Min=value;
36524
+ }
36525
+ }
36526
+ else
36527
+ {
36528
+ if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Max))
36529
+ range.Max+=maxDiffValue;
36530
+ }
36338
36531
  }
36339
36532
 
36340
36533
  return range;