stz-chart-maker 1.0.16 → 1.0.17

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 +118 -20
  2. package/dist/index.js +1480 -1429
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChartType, PluginOptionsByType, ChartOptions, GridLineOptions, FontSpec, Tick, Chart, ChartDataset, ChartTypeRegistry, Plugin as Plugin$1, TooltipItem } from 'chart.js';
1
+ import { ChartType, PluginOptionsByType, ChartOptions, GridLineOptions, FontSpec, Tick, Chart, ChartEvent, ActiveElement, ChartDataset, Plugin as Plugin$1, TooltipItem, ChartTypeRegistry } from 'chart.js';
2
2
  import { ZoomPluginOptions } from 'chartjs-plugin-zoom/types/options';
3
3
  import { DeepPartial as DeepPartial$1 } from 'chart.js/dist/types/utils';
4
4
 
@@ -210,6 +210,12 @@ type CustomChartOptions<TType extends ChartType = ChartType> = Override<ChartOpt
210
210
  right?: number;
211
211
  };
212
212
  };
213
+ onResize?: (this: Chart<TType>, chart: Chart<TType>, size: {
214
+ width: number;
215
+ height: number;
216
+ }) => void;
217
+ onClick?: (this: Chart<TType>, event: ChartEvent, elements: ActiveElement[]) => void;
218
+ onHover?: (this: Chart<TType>, event: ChartEvent, elements: ActiveElement[]) => void;
213
219
  }> & {
214
220
  _mounted?: (chart: Chart<TType>) => void;
215
221
  _chartId?: string;
@@ -350,9 +356,11 @@ declare abstract class ChartWrapper<TType extends ChartType> implements ChartBui
350
356
  static registry: Map<string, Constructor<any, any>>;
351
357
  constructor(type: TType, labels: (string | number)[], datasets: ChartDataset<TType, (number | null)[]>[], options: CustomChartOptions<TType>, plugins?: any | undefined);
352
358
  static create<TType extends ChartType>(type: TType, labels: (string | number)[], datasets: ChartDataset<TType, (number | null)[]>[], options?: CustomChartOptions<TType>, plugins?: any): TType extends CartesianChartType ? CartesianChartBuilder<TType> : ChartBuilder<TType>;
359
+ static register<TType extends ChartType, TInstance>(type: TType, wrapperClass: Constructor<TType, TInstance>): void;
360
+ static has(type: ChartType): boolean;
353
361
  protected abstract normalize(): void;
354
362
  protected abstract configAop(config: any): any;
355
- static register<TType extends ChartType, TInstance>(type: TType, wrapperClass: Constructor<TType, TInstance>): void;
363
+ abstract build(id?: string): ChartConfig;
356
364
  /**
357
365
  * 플러그인을 추가합니다.
358
366
  * @param plugin
@@ -377,7 +385,19 @@ declare abstract class ChartWrapper<TType extends ChartType> implements ChartBui
377
385
  * @param pluginId
378
386
  */
379
387
  hasPlugin(pluginId: string): boolean;
380
- abstract build(id?: string): ChartConfig;
388
+ /**
389
+ *
390
+ * @param callback
391
+ * @description 차트 리사이즈 이벤트 콜백 함수를 설정합니다.
392
+ * @Since 1.0.0
393
+ * @category options
394
+ * @beta (기능 개발 중)
395
+ *
396
+ */
397
+ onResize(callback: (chart: Chart<TType>, size: {
398
+ width: number;
399
+ height: number;
400
+ }) => void): this;
381
401
  }
382
402
 
383
403
  interface AxisColors {
@@ -459,6 +479,15 @@ declare abstract class CartesianChartWrapper<TType extends CartesianChartType> e
459
479
  protected isBar(): boolean;
460
480
  protected normalize(): void;
461
481
  protected configAop(config: any): any;
482
+ /**
483
+ * 차트 설정 객체를 생성합니다.
484
+ * @param id
485
+ * @returns {ChartConfig}
486
+ * @Description 차트 설정 객체를 생성합니다. 이 메소드는 차트의 구성 요소를 종합하여 Chart.js에서 사용할 수 있는 형식으로 반환합니다.
487
+ * @Since 1.0.0
488
+ * @category Chart
489
+ *
490
+ */
462
491
  build(id?: string): ChartConfig;
463
492
  makeConfig(id?: string): {
464
493
  _chartId: any;
@@ -645,20 +674,8 @@ declare abstract class CartesianChartWrapper<TType extends CartesianChartType> e
645
674
  customLegend(obj: HtmlLegendOptions): this;
646
675
  }
647
676
 
648
- type AllChartTypes = keyof ChartTypeRegistry;
649
- declare enum ChartTypes {
650
- BAR = "bar",
651
- LINE = "line",
652
- DOUGHNUT = "doughnut",
653
- PIE = "pie",
654
- RADAR = "radar",
655
- BUBBLE = "bubble",
656
- SCATTER = "scatter",
657
- TREE = "tree"
658
- }
659
-
660
677
  declare class BarChartWrapper extends CartesianChartWrapper<'bar'> implements BarChartBuilder {
661
- constructor(type: ChartTypes.BAR, labels: (string | number)[], datasets: CartesianDataset<ChartTypes.BAR>[], options?: CustomBarChartOptions, plugins?: any);
678
+ constructor(type: 'bar', labels: (string | number)[], datasets: CartesianDataset<'bar'>[], options?: CustomBarChartOptions, plugins?: any);
662
679
  protected requireLabels(): boolean;
663
680
  makeConfig(id?: string): {
664
681
  _chartId: any;
@@ -789,8 +806,27 @@ declare class BarChartWrapper extends CartesianChartWrapper<'bar'> implements Ba
789
806
  }
790
807
 
791
808
  declare class LineChartWrapper extends CartesianChartWrapper<'line'> implements LineChartBuilder {
792
- constructor(type: ChartTypes.LINE, labels: (string | number)[], datasets: CartesianDataset<'line'>[], options?: CustomChartOptions<'line'>);
809
+ constructor(type: 'line', labels: (string | number)[], datasets: CartesianDataset<'line'>[], options?: CustomChartOptions<'line'>);
810
+ /**
811
+ *
812
+ * @protected
813
+ * @returns {boolean}
814
+ * @description 라인 차트는 카테고리형 x축일 때 라벨이 필수입니다.
815
+ * @Since 1.0.0
816
+ * @category config
817
+ * @override
818
+ */
793
819
  protected requireLabels(): boolean;
820
+ /**
821
+ *
822
+ * @param id
823
+ * @returns {ChartConfiguration}
824
+ * @description 차트 설정 객체를 생성합니다.
825
+ * @Since 1.0.0
826
+ * @category config
827
+ * @override
828
+ * @Deprecated use build() Method
829
+ */
794
830
  makeConfig(id?: string): {
795
831
  _chartId: any;
796
832
  type: any;
@@ -879,6 +915,58 @@ declare class LineChartWrapper extends CartesianChartWrapper<'line'> implements
879
915
  *
880
916
  */
881
917
  setAllPointHoverRadius(hoverRadius: number): this;
918
+ /**
919
+ *
920
+ * @param {number} datasetIndex - 대상 데이터셋 인덱스
921
+ * @param {number} steps - 그라디언트 단계 (2단계면 0,1 / 3단계면 0,0.5,1)
922
+ * @param {string[]} colors - 색상 배열 (steps와 같은 길이여야 함)
923
+ * @param {'vertical' | 'horizontal'} direction - 그라디언트 방향 (기본값: vertical)
924
+ * @description 지정된 데이터셋에 단계별 그라디언트를 적용합니다.
925
+ * @remarks step 인자는 2 이상만 지원할것입니다.
926
+ * @Since 1.0.0
927
+ * @category dataset
928
+ * @beta (기능 테스트 중)
929
+ */
930
+ setGradient(datasetIndex: number, steps: number, colors: string[], direction?: 'vertical' | 'horizontal'): this;
931
+ /**
932
+ *
933
+ * @param {number} steps - 그라디언트 단계
934
+ * @param {string[]} colors - 색상 배열
935
+ * @param {'vertical' | 'horizontal'} direction - 그라디언트 방향 (기본값: vertical)
936
+ * @description 모든 데이터셋에 동일한 그라디언트를 적용합니다.
937
+ * @Since 1.0.0
938
+ * @category dataset
939
+ * @beta (기능 테스트 중)
940
+ */
941
+ setAllGradient(steps: number, colors: string[], direction?: 'vertical' | 'horizontal'): this;
942
+ /**
943
+ *
944
+ * @param {number} datasetIndex - 대상 데이터셋 인덱스
945
+ * @description 지정된 데이터셋의 그라디언트를 제거합니다.
946
+ * @Since 1.0.0
947
+ * @category dataset
948
+ * @beta (기능 테스트 중)
949
+ */
950
+ removeGradient(datasetIndex: number): this;
951
+ /**
952
+ *
953
+ * @description 모든 데이터셋의 그라디언트를 제거합니다.
954
+ * @Since 1.0.0
955
+ * @category dataset
956
+ * @beta (기능 테스트 중)
957
+ */
958
+ removeAllGradients(): this;
959
+ /**
960
+ *
961
+ * @param {number} steps - 단계 수
962
+ * @returns {number[]} 0부터 1까지의 위치 배열
963
+ * @description 주어진 단계 수에 따라 그라디언트 위치를 계산합니다.
964
+ * @Since 1.0.0
965
+ * @category utility
966
+ * @private
967
+ * @beta (기능 테스트 중)
968
+ */
969
+ private calculateGradientPositions;
882
970
  }
883
971
 
884
972
  declare const noDataPlugin: {
@@ -1022,7 +1110,7 @@ declare namespace LocalDefaults {
1022
1110
  declare class ChartFactory {
1023
1111
  private static registry;
1024
1112
  static register<TType extends ChartType, TInstance>(type: TType, wrapperClass: Constructor<TType, TInstance>): void;
1025
- static create<TType extends ChartType>(type: TType, ...args: ConstructorParameters<Constructor<TType, any>>): any;
1113
+ static create<TType extends ChartType>(type: TType, labels: (string | number)[], datasets: ChartDataset<TType, (number | null)[]>[], options?: CustomChartOptions<TType>, plugins?: any): any;
1026
1114
  static has(type: ChartType): boolean;
1027
1115
  static clear(): void;
1028
1116
  }
@@ -1039,9 +1127,20 @@ declare class ChartInstance {
1039
1127
  static resize(id: string): void;
1040
1128
  }
1041
1129
 
1130
+ type AllChartTypes = keyof ChartTypeRegistry;
1131
+ declare enum ChartTypes {
1132
+ BAR = "bar",
1133
+ LINE = "line",
1134
+ DOUGHNUT = "doughnut",
1135
+ PIE = "pie",
1136
+ RADAR = "radar",
1137
+ BUBBLE = "bubble",
1138
+ SCATTER = "scatter",
1139
+ TREE = "tree"
1140
+ }
1141
+
1042
1142
  declare const ChartToolBox: {
1043
1143
  setErrorLog(enabled: boolean): void;
1044
- setDebugLog(enabled: boolean): void;
1045
1144
  };
1046
1145
  declare const T$: {
1047
1146
  readonly create: typeof ChartWrapper.create;
@@ -1054,7 +1153,6 @@ declare const T$: {
1054
1153
  readonly defaultsOptions: typeof LocalDefaults;
1055
1154
  readonly toolBox: {
1056
1155
  setErrorLog(enabled: boolean): void;
1057
- setDebugLog(enabled: boolean): void;
1058
1156
  };
1059
1157
  };
1060
1158