@operato/scene-scichart 7.2.2 → 7.2.3

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.
@@ -25,6 +25,7 @@ import {
25
25
  ZoomPanModifier,
26
26
  ZoomExtentsModifier,
27
27
  RolloverModifier,
28
+ NumericLabelProvider,
28
29
  SmartDateLabelProvider,
29
30
  EllipsePointMarker,
30
31
  SquarePointMarker,
@@ -78,6 +79,16 @@ function convertColor(color: string | string[] | undefined, defaultColor?: strin
78
79
  return tinyColor.toHex8String() || defaultColor
79
80
  }
80
81
 
82
+ export function calculatePrecision(format: string | number = '') {
83
+ const formatString = format.toString()
84
+
85
+ if (formatString.indexOf('.') !== -1) {
86
+ return formatString.split('.')[1].length
87
+ }
88
+
89
+ return 0
90
+ }
91
+
81
92
  function createPointMarker(wasmContext: any, dataset: any, color: string = DEFAULT_COLOR) {
82
93
  const { pointStyle, pointRadius = POINT_MARKER_SIZE } = dataset || {}
83
94
 
@@ -115,6 +126,7 @@ function createAxis(
115
126
  fontColor: string,
116
127
  fontFamily?: string,
117
128
  fontSize?: number,
129
+ precision?: number,
118
130
  options?: any
119
131
  ) {
120
132
  const { axisTitle, ticks } = axis
@@ -126,7 +138,8 @@ function createAxis(
126
138
  stepSize,
127
139
  beginAtZero,
128
140
  color = fontColor,
129
- textStrokeColor = fontColor
141
+ textStrokeColor = fontColor,
142
+ display
130
143
  } = ticks || {}
131
144
 
132
145
  const axisOptions = {
@@ -149,21 +162,32 @@ function createAxis(
149
162
  ...options
150
163
  }
151
164
 
152
- const labelProvider = new SmartDateLabelProvider({
153
- labelFormat: ENumericFormat.Date_HHMMSS,
154
- showWiderDateOnFirstLabel: true,
155
- showYearOnWiderDate: true,
156
- dateOffset: getLocalTimeOffset()
157
- })
165
+ const labelProvider = isXAxis
166
+ ? new SmartDateLabelProvider({
167
+ showWiderDateOnFirstLabel: true,
168
+ showYearOnWiderDate: false,
169
+ dateOffset: getLocalTimeOffset()
170
+ })
171
+ : new NumericLabelProvider()
158
172
 
159
- labelProvider.cursorNumericFormat = ENumericFormat.Date_DDMMHHMM
173
+ if (isXAxis) {
174
+ labelProvider.cursorNumericFormat = ENumericFormat.Date_HHMMSS
175
+ } else {
176
+ labelProvider.numericFormat = ENumericFormat.Decimal
177
+ labelProvider.precision = precision || calculatePrecision(stepSize || 0.1)
178
+ labelProvider.cursorNumericFormat = ENumericFormat.NoFormat
179
+ }
160
180
 
161
181
  return isXAxis
162
182
  ? new DateTimeNumericAxis(wasmContext, {
163
183
  ...axisOptions,
164
184
  labelProvider
165
185
  })
166
- : new NumericAxis(wasmContext, { ...axisOptions, id: index !== 0 ? `yAxis${index}` : undefined })
186
+ : new NumericAxis(wasmContext, {
187
+ ...axisOptions,
188
+ id: index !== 0 ? `yAxis${index}` : undefined,
189
+ labelProvider
190
+ })
167
191
  }
168
192
 
169
193
  function createSeries(
@@ -235,7 +259,7 @@ export async function buildSciChart(
235
259
  config: OperatoChart.ChartConfig | undefined | null,
236
260
  container: any,
237
261
  { fontSize = 14, fontFamily = 'Roboto', fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string },
238
- grouped?: string
262
+ { grouped, precision }: { grouped?: string; precision?: number }
239
263
  ): Promise<{ chart: any; dataSeries: any[] } | undefined> {
240
264
  if (!config) return
241
265
 
@@ -281,7 +305,7 @@ export async function buildSciChart(
281
305
 
282
306
  // Y 축 설정
283
307
  ;(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
284
- const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize)
308
+ const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize, precision)
285
309
  sciChartSurface.yAxes.add(yAxis)
286
310
  })
287
311
 
@@ -295,7 +319,7 @@ export async function buildSciChart(
295
319
  if (tooltip) {
296
320
  const rolloverModifier = new RolloverModifier({
297
321
  showTooltip: true,
298
- showAxisLabel: true,
322
+ showAxisLabel: true /* 한글의 크기를 잘 계산하지 못하므로 false */,
299
323
  modifierGroup: grouped
300
324
  })
301
325
 
@@ -478,7 +502,7 @@ export async function buildSciChartOverview(
478
502
 
479
503
  // Y 축 설정
480
504
  ;(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
481
- const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize, {
505
+ const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize, undefined, {
482
506
  drawLabels: false,
483
507
  drawMajorTicks: false,
484
508
  drawMinorTicks: false,