stz-chart-maker 1.7.0 → 2.0.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +80 -4
  2. package/dist/index.js +2672 -2615
  3. package/package.json +3 -2
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { ChartTypeRegistry, ChartType, ChartDataset, GridLineOptions, FontSpec, Tick, PluginOptionsByType, ChartOptions, Chart, ChartEvent, ActiveElement, LegendOptions, Plugin as Plugin$1, TooltipItem } from 'chart.js';
1
+ import { ChartTypeRegistry, ChartType, ChartDataset, GridLineOptions, FontSpec, Tick, PluginOptionsByType, Chart, ChartOptions, ChartEvent, ActiveElement, LegendOptions, Plugin as Plugin$1, TooltipItem } from 'chart.js';
2
2
  import { TreemapControllerDatasetOptions } from 'chartjs-chart-treemap';
3
3
  import { ZoomPluginOptions } from 'chartjs-plugin-zoom/types/options';
4
- import { DeepPartial as DeepPartial$1 } from 'chart.js/dist/types/utils';
5
4
 
6
5
  /**
7
6
  * ═════════════════════════════════════════════════════════════
@@ -190,7 +189,7 @@ interface CommonAxes {
190
189
  weight: number;
191
190
  }
192
191
  interface CommonCartesianAxes extends Omit<CommonAxes, 'ticks'>, Partial<CommonCartesian> {
193
- type: 'category' | 'linear' | 'logarithmic' | 'time' | 'timeseries';
192
+ type: 'category' | 'linear' | 'logarithmic' | 'time' | 'timeseries' | 'realtime';
194
193
  ticks?: CommonCartesianTicks;
195
194
  }
196
195
  type DeepPartialCartesianAxes = DeepPartial<CommonCartesianAxes>;
@@ -233,7 +232,7 @@ interface CustomZoomType<TType extends ChartType = ChartType> extends PluginOpti
233
232
  pan?: PanOptions;
234
233
  zoomLimits?: ZoomLimits;
235
234
  }
236
- type DeepPartialZoomType = DeepPartial$1<CustomZoomType>;
235
+ type DeepPartialZoomType = DeepPartial<CustomZoomType>;
237
236
 
238
237
  interface DataLabelsContext {
239
238
  chart: any;
@@ -258,6 +257,54 @@ interface DataLabels {
258
257
  }
259
258
  type PartialDataLabels = Partial<DataLabels>;
260
259
 
260
+ /**
261
+ * `chartjs-plugin-streaming`의 옵션을 정의합니다.
262
+ * `addStreaming` 메서드에 이 타입의 객체를 전달하여 스트리밍 동작을 설정합니다.
263
+ * @see https://github.com/nagix/chartjs-plugin-streaming
264
+ */
265
+ interface StreamingOptions {
266
+ /**
267
+ * 차트에 데이터가 표시되는 시간 (밀리초 단위).
268
+ */
269
+ duration?: number;
270
+ /**
271
+ * 차트가 업데이트되는 간격 (밀리초 단위).
272
+ */
273
+ refresh?: number;
274
+ /**
275
+ * 데이터 추가 시 발생하는 지연 시간 (밀리초 단위).
276
+ */
277
+ delay?: number;
278
+ /**
279
+ * 애니메이션 프레임당 업데이트 여부.
280
+ */
281
+ frame?: boolean;
282
+ /**
283
+ * 차트 업데이트를 일시 중지할지 여부.
284
+ */
285
+ pause?: boolean;
286
+ /**
287
+ * 데이터가 차트에 머무는 시간 (Time to Live). `duration`과 유사합니다.
288
+ */
289
+ ttl?: number;
290
+ /**
291
+ * 차트가 새로고침될 때 호출되는 콜백 함수.
292
+ * 이 함수 안에서 데이터 소스(WebSocket, API 등)로부터 받은 데이터를
293
+ * 차트의 데이터셋에 추가해야 합니다.
294
+ *
295
+ * @example
296
+ * onRefresh: (chart) => {
297
+ * chart.data.datasets.forEach(dataset => {
298
+ * dataset.data.push({
299
+ * x: Date.now(),
300
+ * y: Math.random()
301
+ * });
302
+ * });
303
+ * }
304
+ */
305
+ onRefresh?: (chart: Chart) => void;
306
+ }
307
+
261
308
  /**
262
309
  * ═════════════════════════════════════════════════════════════
263
310
  * 📄 FILE : options.ts
@@ -329,6 +376,7 @@ type HtmlLegendOptions = {
329
376
  type CustomOptionPlugins<TType extends ChartType = ChartType> = DeepPartial<PluginOptionsByType<TType>> & {
330
377
  zoom?: DeepPartialZoomType;
331
378
  datalabels?: PartialDataLabels;
379
+ streaming?: StreamingOptions;
332
380
  settingsIcon?: {
333
381
  iconSize?: Record<'w' | 'h', number>;
334
382
  img?: string;
@@ -744,6 +792,34 @@ declare abstract class ChartWrapper<TType extends ChartType, TOptions extends Cu
744
792
  * @beta
745
793
  */
746
794
  setChartData(uid: string, newDataset: CustomChartDatasets<TType>): void;
795
+ /**
796
+ * @description 실시간 스트리밍 옵션을 설정합니다.
797
+ * 이 메서드를 사용하기 전에, 사용자는 'chartjs-plugin-streaming'을 설치하고 Chart.js에 직접 등록해야 합니다.
798
+ * @param {StreamingOptions} streamingOptions - `chartjs-plugin-streaming` 플러그인에 전달할 옵션 객체.
799
+ * @returns {this}
800
+ * @since 1.8.0
801
+ * @category plugin
802
+ * @example
803
+ * // 1. 사용자 측에서 웹소켓 등 데이터 소스 설정
804
+ * const myWebSocket = new WebSocket('wss://my-data-source');
805
+ *
806
+ * // 2. ChartWrapper에 스트리밍 옵션 적용
807
+ * chart.addStreaming({
808
+ * duration: 20000, // 20초 분량의 데이터를 차트에 표시
809
+ * refresh: 1000, // 1초마다 차트 업데이트
810
+ * onRefresh: (chart) => {
811
+ * // 3. 데이터 소스로부터 받은 데이터를 차트에 추가
812
+ * myWebSocket.onmessage = (event) => {
813
+ * const data = JSON.parse(event.data);
814
+ * chart.data.datasets[0].data.push({
815
+ * x: data.timestamp,
816
+ * y: data.value
817
+ * });
818
+ * };
819
+ * }
820
+ * });
821
+ */
822
+ addStreaming(streamingOptions: StreamingOptions): this;
747
823
  }
748
824
 
749
825
  interface AxisColors {