evui 3.4.3 → 3.4.6

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": "evui",
3
- "version": "3.4.3",
3
+ "version": "3.4.6",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -379,12 +379,12 @@ class EvChart {
379
379
  return axes.map((axis) => {
380
380
  switch (axis.type) {
381
381
  case 'linear':
382
- return new LinearScale(dir, axis, ctx, options);
382
+ return new LinearScale(dir, axis, ctx, labels, options);
383
383
  case 'time':
384
384
  if (axis.categoryMode) {
385
385
  return new TimeCategoryScale(dir, axis, ctx, labels, options);
386
386
  }
387
- return new TimeScale(dir, axis, ctx, options);
387
+ return new TimeScale(dir, axis, ctx, labels, options);
388
388
  case 'log':
389
389
  return new LogarithmicScale(dir, axis, ctx);
390
390
  case 'step':
@@ -10,7 +10,7 @@ import {
10
10
  import Util from '../helpers/helpers.util';
11
11
 
12
12
  class Scale {
13
- constructor(type, axisOpt, ctx, options) {
13
+ constructor(type, axisOpt, ctx, labels, options) {
14
14
  const merged = defaultsDeep({}, axisOpt, AXIS_OPTION);
15
15
  Object.keys(merged).forEach((key) => {
16
16
  this[key] = merged[key];
@@ -19,6 +19,7 @@ class Scale {
19
19
  this.type = type;
20
20
  this.ctx = ctx;
21
21
  this.units = AXIS_UNITS[this.type];
22
+ this.labels = labels;
22
23
  this.options = options;
23
24
 
24
25
  if (!this.position) {
@@ -275,10 +276,22 @@ class Scale {
275
276
  }
276
277
 
277
278
  if (this.labelStyle?.show) {
278
- const labelGap = (endPoint - startPoint) / steps;
279
+ const distance = endPoint - startPoint;
280
+ const labelGap = distance / steps;
279
281
  const ticks = [];
282
+ const size = stepInfo.interval;
280
283
  let labelCenter = null;
281
284
  let linePosition = null;
285
+ let offsetStartPoint = startPoint;
286
+ let axisMinForLabel = axisMin;
287
+
288
+ if (this.type === 'x' && options?.axesX[0].flow && this.labels.length !== steps + 1) {
289
+ const axisMinByMinutes = Math.floor(axisMin / size) * size;
290
+ if (axisMinByMinutes !== +axisMin) {
291
+ axisMinForLabel = axisMinByMinutes + size;
292
+ offsetStartPoint += (distance / (axisMax - axisMin)) * (axisMinForLabel - axisMin);
293
+ }
294
+ }
282
295
 
283
296
  ctx.strokeStyle = this.gridLineColor;
284
297
  ctx.lineWidth = 1;
@@ -286,82 +299,85 @@ class Scale {
286
299
 
287
300
  let labelText;
288
301
  for (let ix = 0; ix <= steps; ix++) {
289
- ctx.beginPath();
290
- ticks[ix] = axisMin + (ix * stepValue);
302
+ labelCenter = Math.round(offsetStartPoint + (labelGap * ix));
291
303
 
292
- labelCenter = Math.round(startPoint + (labelGap * ix));
293
- linePosition = labelCenter + aliasPixel;
294
- labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
304
+ if (labelCenter <= endPoint || this.type !== 'x' || !options?.axesX[0].flow || this.labels.length === steps + 1) {
305
+ ctx.beginPath();
306
+ ticks[ix] = axisMinForLabel + (ix * stepValue);
295
307
 
296
- const isBlurredLabel = this.options?.selectLabel?.use
297
- && this.options?.selectLabel?.useLabelOpacity
298
- && (this.options.horizontal === (this.type === 'y'))
299
- && selectLabelInfo?.dataIndex?.length
300
- && !selectLabelInfo?.label
301
- .map(t => this.getLabelFormat(Math.min(axisMax, t))).includes(labelText);
308
+ linePosition = labelCenter + aliasPixel;
309
+ labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
302
310
 
303
- const labelColor = this.labelStyle.color;
304
- let defaultOpacity = 1;
311
+ const isBlurredLabel = this.options?.selectLabel?.use
312
+ && this.options?.selectLabel?.useLabelOpacity
313
+ && (this.options.horizontal === (this.type === 'y'))
314
+ && selectLabelInfo?.dataIndex?.length
315
+ && !selectLabelInfo?.label
316
+ .map(t => this.getLabelFormat(Math.min(axisMax, t))).includes(labelText);
305
317
 
306
- if (Util.getColorStringType(labelColor) === 'RGBA') {
307
- defaultOpacity = Util.getOpacity(labelColor);
308
- }
318
+ const labelColor = this.labelStyle.color;
319
+ let defaultOpacity = 1;
309
320
 
310
- ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
321
+ if (Util.getColorStringType(labelColor) === 'RGBA') {
322
+ defaultOpacity = Util.getOpacity(labelColor);
323
+ }
311
324
 
312
- let labelPoint;
325
+ ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
313
326
 
314
- if (this.type === 'x') {
315
- labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
316
- if (options?.brush?.showLabel || !options?.brush) {
317
- ctx.fillText(labelText, labelCenter, labelPoint);
318
- }
327
+ let labelPoint;
319
328
 
320
- if (!isBlurredLabel
321
- && options?.selectItem?.showLabelTip
322
- && hitInfo?.label
323
- && !this.options?.horizontal) {
324
- const selectedLabel = this.getLabelFormat(
325
- Math.min(axisMax, hitInfo.label + (0 * stepValue)),
326
- );
327
- if (selectedLabel === labelText) {
328
- const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
329
- Util.showLabelTip({
330
- ctx: this.ctx,
331
- width: Math.round(ctx.measureText(selectedLabel).width) + 10,
332
- height,
333
- x: labelCenter,
334
- y: labelPoint + (height - 2),
335
- borderRadius: 2,
336
- arrowSize: 3,
337
- text: labelText,
338
- backgroundColor: options?.selectItem?.labelTipStyle?.backgroundColor,
339
- textColor: options?.selectItem?.labelTipStyle?.textColor,
340
- });
329
+ if (this.type === 'x') {
330
+ labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
331
+ if (options?.brush?.showLabel || !options?.brush) {
332
+ ctx.fillText(labelText, labelCenter, labelPoint);
341
333
  }
342
- }
343
- if (ix !== 0 && this.showGrid) {
344
- ctx.moveTo(linePosition, offsetPoint);
345
- ctx.lineTo(linePosition, offsetCounterPoint);
346
- }
347
- } else {
348
- labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
349
- if (options?.brush?.showLabel || !options?.brush) {
350
- ctx.fillText(labelText, labelPoint, labelCenter);
351
- }
352
334
 
353
- if (ix === steps) {
354
- linePosition -= 1;
355
- }
335
+ if (!isBlurredLabel
336
+ && options?.selectItem?.showLabelTip
337
+ && hitInfo?.label
338
+ && !this.options?.horizontal) {
339
+ const selectedLabel = this.getLabelFormat(
340
+ Math.min(axisMax, hitInfo.label + (0 * stepValue)),
341
+ );
342
+ if (selectedLabel === labelText) {
343
+ const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
344
+ Util.showLabelTip({
345
+ ctx: this.ctx,
346
+ width: Math.round(ctx.measureText(selectedLabel).width) + 10,
347
+ height,
348
+ x: labelCenter,
349
+ y: labelPoint + (height - 2),
350
+ borderRadius: 2,
351
+ arrowSize: 3,
352
+ text: labelText,
353
+ backgroundColor: options?.selectItem?.labelTipStyle?.backgroundColor,
354
+ textColor: options?.selectItem?.labelTipStyle?.textColor,
355
+ });
356
+ }
357
+ }
358
+ if ((ix !== 0 || options?.axesX[0].flow) && this.showGrid) {
359
+ ctx.moveTo(linePosition, offsetPoint);
360
+ ctx.lineTo(linePosition, offsetCounterPoint);
361
+ }
362
+ } else {
363
+ labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
364
+ if (options?.brush?.showLabel || !options?.brush) {
365
+ ctx.fillText(labelText, labelPoint, labelCenter);
366
+ }
356
367
 
357
- if (ix !== 0 && this.showGrid) {
358
- ctx.moveTo(offsetPoint, linePosition);
359
- ctx.lineTo(offsetCounterPoint, linePosition);
368
+ if (ix === steps) {
369
+ linePosition -= 1;
370
+ }
371
+
372
+ if (ix !== 0 && this.showGrid) {
373
+ ctx.moveTo(offsetPoint, linePosition);
374
+ ctx.lineTo(offsetCounterPoint, linePosition);
375
+ }
360
376
  }
361
- }
362
377
 
363
- ctx.stroke();
364
- ctx.closePath();
378
+ ctx.stroke();
379
+ ctx.closePath();
380
+ }
365
381
  }
366
382
  }
367
383
 
@@ -5,11 +5,6 @@ import Util from '../helpers/helpers.util';
5
5
  import { truthyNumber } from '../../../common/utils';
6
6
 
7
7
  class StepScale extends Scale {
8
- constructor(type, axisOpt, ctx, labels, options) {
9
- super(type, axisOpt, ctx, options);
10
- this.labels = labels;
11
- }
12
-
13
8
  /**
14
9
  * Calculate min/max value, label and size information for step scale
15
10
  * @param {object} minMax min/max information (unused on step scale)
@@ -4,12 +4,6 @@ import Scale from './scale';
4
4
  import Util from '../helpers/helpers.util';
5
5
 
6
6
  class TimeCategoryScale extends Scale {
7
- constructor(type, axisOpt, ctx, labels, options) {
8
- super(type, axisOpt, ctx);
9
- this.labels = labels;
10
- this.options = options;
11
- }
12
-
13
7
  /**
14
8
  * Transforming label by designated format
15
9
  * @param {number} value label value
@@ -16,7 +16,10 @@
16
16
  :readonly="readonly"
17
17
  @change="changeMv"
18
18
  />
19
- <span class="ev-checkbox-label" :title="label">
19
+ <span
20
+ ref="checkboxLabel"
21
+ class="ev-checkbox-label"
22
+ >
20
23
  <template v-if="$slots.default">
21
24
  <slot />
22
25
  </template>
@@ -28,7 +31,7 @@
28
31
  </template>
29
32
 
30
33
  <script>
31
- import { ref, computed, watch, nextTick, inject } from 'vue';
34
+ import { ref, computed, watch, nextTick, inject, onMounted } from 'vue';
32
35
 
33
36
  export default {
34
37
  name: 'EvCheckbox',
@@ -41,6 +44,10 @@ export default {
41
44
  type: [String, Number, Boolean, Symbol],
42
45
  default: null,
43
46
  },
47
+ tooltipTitle: {
48
+ type: String,
49
+ default: '',
50
+ },
44
51
  disabled: {
45
52
  type: Boolean,
46
53
  default: false,
@@ -60,6 +67,20 @@ export default {
60
67
  change: null,
61
68
  },
62
69
  setup(props, { emit }) {
70
+ /**
71
+ * checkbox label Ref
72
+ */
73
+ const checkboxLabel = ref();
74
+
75
+ /**
76
+ * checkbox label의 title(마우스 호버 시 보이는 내용)사용 되는
77
+ * tooltipTitle props의 값이 있을 시 태그에 title 속성 추가
78
+ */
79
+ onMounted(() => {
80
+ if (checkboxLabel.value && props.tooltipTitle) {
81
+ checkboxLabel.value.title = props.tooltipTitle;
82
+ }
83
+ });
63
84
  /**
64
85
  * checkbox Ref
65
86
  */
@@ -121,6 +142,7 @@ export default {
121
142
 
122
143
  return {
123
144
  mv,
145
+ checkboxLabel,
124
146
  checkbox,
125
147
  checked,
126
148
  changeMv,
@@ -35,6 +35,9 @@ export const usePosition = () => {
35
35
  top: null,
36
36
  left: null,
37
37
  right: null,
38
+ pageY: null,
39
+ pageX: null,
40
+ clientX: null,
38
41
  });
39
42
 
40
43
  /**
@@ -52,6 +55,9 @@ export const usePosition = () => {
52
55
  const docHeight = document.documentElement.clientHeight;
53
56
  const docWidth = document.documentElement.clientWidth;
54
57
  const RIGHT_BUFFER_PX = 20;
58
+ menuStyle.pageX = e.pageX;
59
+ menuStyle.pageY = e.pageY;
60
+ menuStyle.clientX = e.clientX;
55
61
  if (docHeight < e.clientY + menuListHeight) {
56
62
  // dropTop
57
63
  menuStyle.top = `${e.pageY - menuListHeight}px`;