evui 3.3.12 → 3.3.13

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.
@@ -311,13 +311,6 @@ const modules = {
311
311
  value,
312
312
  name,
313
313
  });
314
- } else if (this.options.type === 'heatMap') {
315
- formattedTxt = opt.formatter({
316
- x: this.options.horizontal ? hitItem.y : hitItem.x,
317
- y: this.options.horizontal ? hitItem.x : hitItem.y,
318
- name,
319
- value,
320
- });
321
314
  } else {
322
315
  formattedTxt = opt.formatter({
323
316
  x: this.options.horizontal ? value : hitItem.x,
@@ -363,12 +356,13 @@ const modules = {
363
356
  const boxPadding = { t: 8, b: 8, r: 20, l: 16 };
364
357
  const isHorizontal = this.options.horizontal;
365
358
  const opt = this.options.tooltip;
359
+ let xValue = '';
360
+ let yValue = '';
366
361
 
367
362
  // draw tooltip Title(axis label) and add style class for wrap line about too much long label.
368
- if (this.axesX.length && this.axesY.length) {
369
- this.tooltipHeaderDOM.textContent = this.options.horizontal
370
- ? `${this.axesY[hitAxis.y].getLabelFormat(hitItem.y)} / ${this.axesX[hitAxis.x].getLabelFormat(hitItem.x)}`
371
- : `${this.axesX[hitAxis.x].getLabelFormat(hitItem.x)} / ${this.axesY[hitAxis.y].getLabelFormat(hitItem.y)}`;
363
+ if (this.axesX.length) {
364
+ xValue = this.axesX[hitAxis.x].getLabelFormat(hitItem.x);
365
+ this.tooltipHeaderDOM.textContent = xValue;
372
366
  }
373
367
 
374
368
  if (opt.textOverflow) {
@@ -402,13 +396,35 @@ const modules = {
402
396
  ctx.fillStyle = hitColor;
403
397
  }
404
398
 
405
- // 1. Draw series color
399
+ // 1. Draw value color
406
400
  ctx.fillRect(itemX - 4, itemY - 12, 12, 12);
407
401
  ctx.fillStyle = opt.fontColor;
408
402
 
409
- // 2. Draw series name
403
+ // 2. Draw value y names
410
404
  ctx.textBaseline = 'Bottom';
411
- ctx.fillText(itemValue, itemX + COLOR_MARGIN, itemY);
405
+ if (this.axesY.length) {
406
+ yValue = this.axesY[hitAxis.y].getLabelFormat(hitItem.y);
407
+ ctx.fillText(yValue, itemX + COLOR_MARGIN, itemY);
408
+ }
409
+
410
+ // 3. Draw value
411
+ let formattedTxt;
412
+ if (opt.formatter) {
413
+ formattedTxt = opt.formatter({
414
+ x: xValue,
415
+ y: yValue,
416
+ value: itemValue,
417
+ });
418
+ }
419
+
420
+ if ((!opt.formatter || typeof formattedTxt !== 'string') && itemValue !== 'error') {
421
+ formattedTxt = numberWithComma(itemValue);
422
+ } else {
423
+ formattedTxt = itemValue;
424
+ }
425
+
426
+ ctx.textAlign = 'right';
427
+ ctx.fillText(formattedTxt, this.tooltipDOM.offsetWidth - boxPadding.r, itemY);
412
428
  ctx.closePath();
413
429
 
414
430
  this.setTooltipDOMStyle(opt);
@@ -7,6 +7,7 @@ class StepScale extends Scale {
7
7
  constructor(type, opt, ctx, labels, options) {
8
8
  super(type, opt, ctx, options);
9
9
  this.labels = labels;
10
+ this.rangeMode = opt.rangeMode;
10
11
  }
11
12
 
12
13
  /**
@@ -138,7 +139,8 @@ class StepScale extends Scale {
138
139
 
139
140
  if (this.type === 'x') {
140
141
  labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
141
- ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
142
+ const xPoint = this.rangeMode ? labelCenter : labelCenter + (labelGap / 2);
143
+ ctx.fillText(labelText, xPoint, labelPoint);
142
144
 
143
145
  if (!isBlurredLabel
144
146
  && this.options?.selectItem?.showLabelTip
@@ -168,7 +170,8 @@ class StepScale extends Scale {
168
170
  }
169
171
  } else {
170
172
  labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
171
- ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
173
+ const yPoint = this.rangeMode ? labelCenter : labelCenter + (labelGap / 2);
174
+ ctx.fillText(labelText, labelPoint, yPoint);
172
175
 
173
176
  if (index > 0 && this.showGrid) {
174
177
  ctx.moveTo(offsetPoint, linePosition);
@@ -178,6 +181,30 @@ class StepScale extends Scale {
178
181
  ctx.stroke();
179
182
  });
180
183
 
184
+ if (this.rangeMode) {
185
+ let labelLastText = +labels[labels.length - 1] + (+labels[1] - +labels[0]);
186
+ if (isNaN(labelLastText)) {
187
+ labelLastText = 'Max';
188
+ }
189
+ labelCenter = Math.round(startPoint + (labelGap * labels.length));
190
+ linePosition = labelCenter + aliasPixel;
191
+
192
+ if (this.type === 'x') {
193
+ ctx.fillText(labelLastText, labelCenter, labelPoint);
194
+ if (this.showGrid) {
195
+ ctx.moveTo(linePosition, offsetPoint);
196
+ ctx.lineTo(linePosition, offsetCounterPoint);
197
+ }
198
+ } else {
199
+ ctx.fillText(labelLastText, labelPoint, labelCenter);
200
+ if (this.showGrid) {
201
+ ctx.moveTo(offsetPoint, linePosition);
202
+ ctx.lineTo(offsetCounterPoint, linePosition);
203
+ }
204
+ }
205
+ ctx.stroke();
206
+ }
207
+
181
208
  ctx.closePath();
182
209
  }
183
210
 
@@ -164,7 +164,7 @@ class TimeCategoryScale extends Scale {
164
164
  }
165
165
 
166
166
  const graphGap = (endPoint - startPoint) / (labels.length || 1);
167
- if (this.categoryMode) {
167
+ if (this.categoryMode && !this.rangeMode) {
168
168
  startPoint += Math.ceil(graphGap / 2) - 2;
169
169
  }
170
170
 
@@ -176,6 +176,7 @@ class TimeCategoryScale extends Scale {
176
176
  ctx.strokeStyle = this.gridLineColor;
177
177
 
178
178
  let labelText;
179
+ let labelPoint;
179
180
  for (let ix = 0; ix < oriSteps; ix += count) {
180
181
  ticks[ix] = axisMin + (ix * stepValue);
181
182
 
@@ -198,8 +199,6 @@ class TimeCategoryScale extends Scale {
198
199
 
199
200
  ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
200
201
 
201
- let labelPoint;
202
-
203
202
  if (this.type === 'x') {
204
203
  labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
205
204
  ctx.fillText(labelText, labelCenter, labelPoint);
@@ -243,6 +242,31 @@ class TimeCategoryScale extends Scale {
243
242
  ctx.stroke();
244
243
  }
245
244
 
245
+ if (this.categoryMode && this.rangeMode && (count * steps) === oriSteps) {
246
+ const diffTime = dayjs(labels[1]).diff(dayjs(labels[0]));
247
+ const labelLastText = this.getLabelFormat(
248
+ dayjs(labels[labels.length - 1] + diffTime),
249
+ );
250
+
251
+ labelCenter = Math.round(startPoint + (graphGap * labels.length));
252
+ linePosition = labelCenter + aliasPixel;
253
+
254
+ if (this.type === 'x') {
255
+ ctx.fillText(labelLastText, labelCenter, labelPoint);
256
+ if (this.showGrid) {
257
+ ctx.moveTo(linePosition, offsetPoint);
258
+ ctx.lineTo(linePosition, offsetCounterPoint);
259
+ }
260
+ } else {
261
+ ctx.fillText(labelLastText, labelPoint, labelCenter);
262
+ if (this.showGrid) {
263
+ ctx.moveTo(offsetPoint, linePosition);
264
+ ctx.lineTo(offsetCounterPoint, linePosition);
265
+ }
266
+ }
267
+ ctx.stroke();
268
+ }
269
+
246
270
  ctx.closePath();
247
271
  }
248
272
  }
@@ -100,6 +100,17 @@ const DEFAULT_OPTIONS = {
100
100
  fillColor: '#38ACEC',
101
101
  opacity: 0.65,
102
102
  },
103
+ heatMapColor: {
104
+ min: '#FFFFFF',
105
+ max: '#0052FF',
106
+ categoryCnt: 5,
107
+ stroke: {
108
+ show: false,
109
+ color: '#FFFFFF',
110
+ lineWidth: 1,
111
+ },
112
+ error: '#FF0000',
113
+ },
103
114
  };
104
115
 
105
116
  const DEFAULT_DATA = {
@@ -605,8 +605,13 @@ export default {
605
605
  );
606
606
  watch(
607
607
  () => props.checked,
608
- (checkedList) => {
609
- checkInfo.checkedRows = checkedList;
608
+ (value) => {
609
+ checkInfo.checkedRows = value;
610
+ },
611
+ );
612
+ watch(
613
+ () => checkInfo.checkedRows,
614
+ (value) => {
610
615
  checkInfo.isHeaderChecked = false;
611
616
  let store = stores.store;
612
617
  if (pageInfo.isClientPaging) {
@@ -614,20 +619,27 @@ export default {
614
619
  }
615
620
  if (store.length) {
616
621
  store.forEach((row) => {
617
- row[ROW_CHECK_INDEX] = checkedList.includes(row[ROW_DATA_INDEX]);
622
+ row[ROW_CHECK_INDEX] = value.includes(row[ROW_DATA_INDEX]);
618
623
  });
619
- checkInfo.isHeaderChecked = checkedList.length === store.length;
624
+ checkInfo.isHeaderChecked = value.length === store.length;
620
625
  }
621
626
  updateVScroll();
622
627
  },
623
628
  );
624
629
  watch(
625
630
  () => props.selected,
626
- (selectedList) => {
631
+ (value) => {
632
+ if (selectInfo.useSelect) {
633
+ selectInfo.selectedRow = value;
634
+ }
635
+ },
636
+ );
637
+ watch(
638
+ () => selectInfo.selectedRow,
639
+ (value) => {
627
640
  if (selectInfo.useSelect) {
628
- selectInfo.selectedRow = selectedList;
629
641
  stores.store.forEach((row) => {
630
- row[ROW_SELECT_INDEX] = selectInfo.selectedRow.includes(row[ROW_DATA_INDEX]);
642
+ row[ROW_SELECT_INDEX] = value.includes(row[ROW_DATA_INDEX]);
631
643
  });
632
644
  updateVScroll();
633
645
  }
@@ -457,16 +457,21 @@ export default {
457
457
 
458
458
  watch(
459
459
  () => props.checked,
460
- (checkedList) => {
460
+ (value) => {
461
+ checkInfo.checkedRows = value;
462
+ },
463
+ );
464
+ watch(
465
+ () => checkInfo.checkedRows,
466
+ (value) => {
467
+ checkInfo.isHeaderChecked = false;
461
468
  let store = stores.store;
462
469
  if (pageInfo.isClientPaging) {
463
470
  store = getPagingData();
464
471
  }
465
- checkInfo.checkedRows = checkedList;
466
- checkInfo.isHeaderChecked = false;
467
472
  if (store.length) {
468
473
  store.forEach((row) => {
469
- row.checked = !!checkedList.find(c => c.index === row.index);
474
+ row.checked = !!value.find(checkedRow => checkedRow.index === row.index);
470
475
  });
471
476
  checkHeader(store);
472
477
  }
@@ -475,12 +480,21 @@ export default {
475
480
  );
476
481
  watch(
477
482
  () => props.selected,
478
- (selectedList) => {
479
- selectInfo.selectedRow = selectedList;
480
- stores.store.forEach((row) => {
481
- row.selected = !!selectInfo.selectedRow.find(s => s.index === row.index);
482
- });
483
- updateVScroll();
483
+ (value) => {
484
+ if (selectInfo.useSelect) {
485
+ selectInfo.selectedRow = value;
486
+ }
487
+ },
488
+ );
489
+ watch(
490
+ () => selectInfo.selectedRow,
491
+ (value) => {
492
+ if (selectInfo.useSelect) {
493
+ stores.store.forEach((row) => {
494
+ row.selected = !!value.find(selectedRow => selectedRow.index === row.index);
495
+ });
496
+ updateVScroll();
497
+ }
484
498
  }, { deep: true },
485
499
  );
486
500
  watch(