stz-chart-maker 2.3.2 → 2.3.4

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/README.md CHANGED
@@ -64,7 +64,14 @@ import { setChartConfig } from 'stz-chart-maker';
64
64
  setChartConfig({
65
65
  errorLogging: true,
66
66
  silentMode: false,
67
- defaultColor: ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A', '#98D8C8', '#F7DC6F']
67
+ defaultColor: ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A', '#98D8C8', '#F7DC6F'],
68
+ zoom: true,
69
+ legend: {
70
+ position: 'top'
71
+ },
72
+ tooltip: {
73
+ enabled: true
74
+ }
68
75
  });
69
76
  ```
70
77
 
@@ -86,6 +93,12 @@ module.exports = {
86
93
  | `errorLogging` | `boolean` | `true` | 에러 로그 출력 여부 |
87
94
  | `silentMode` | `boolean` | `true` | 에러 발생 시 예외를 던지지 않고 처리 |
88
95
  | `defaultColor` | `string[]` | 내부 기본 팔레트 | 차트 전역 기본 색상 배열 |
96
+ | `zoom` | `boolean \| object` | `false` | `line`, `bar`, `bubble` 차트에 전역 zoom 기본값 적용 |
97
+ | `legend` | `object` | 차트 기본값 사용 | 차트 전역 legend 기본 옵션 적용 |
98
+ | `tooltip` | `object` | 차트 기본값 사용 | 차트 전역 tooltip 기본 옵션 적용 |
99
+
100
+ ### 변경기록
101
+ [CHANGELOG.md](./CHANGELOG.md) 파일을 참조하세요.
89
102
 
90
103
  ### 주의사항
91
104
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChartTypeRegistry, ChartType, ChartDataset, GridLineOptions, FontSpec, Tick, PluginOptionsByType, Chart as Chart$1, ChartOptions, ChartEvent, ActiveElement, LegendOptions, Plugin as Plugin$1, TooltipItem } from 'chart.js';
1
+ import { ChartTypeRegistry, ChartType, ChartDataset, GridLineOptions, FontSpec, Tick, PluginOptionsByType, Chart as Chart$1, ChartOptions, ChartEvent, ActiveElement, LegendOptions, TooltipOptions, 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
4
 
@@ -494,6 +494,7 @@ interface ChartBuilder<TType extends ChartType> {
494
494
  }) => void): this;
495
495
  setTitle(titleOptions: CommonCartesianTitleConfig): this;
496
496
  setLegend(legendOptions: DeepPartial<LegendOptions<any>>): this;
497
+ setTooltip(tooltipOptions: DeepPartial<TooltipOptions<any>>): this;
497
498
  mergeOptions(options: DeepPartial<CustomChartOptions<TType>>): this;
498
499
  getChartData(uid: string): CustomChartDatasets<TType>;
499
500
  setChartData(uid: string, data: CustomChartDatasets<TType>): void;
@@ -515,6 +516,7 @@ interface CartesianChartBuilder<TType extends CartesianChartType> extends ChartB
515
516
  color?: string;
516
517
  lineWidth?: number;
517
518
  }): this;
519
+ setZoom(enabled: boolean, zoomOption?: DeepPartialZoomType): this;
518
520
  addZoom(defaultZoom?: boolean, zoomOption?: object): this;
519
521
  addDataLabels(defultDataLabels?: boolean, dataLabelsOptions?: PartialDataLabels): this;
520
522
  setYAxisForDataset(datasetIndex: number, axisId?: string): this;
@@ -731,6 +733,7 @@ declare abstract class Chart<TType extends ChartType, TOptions extends CustomCha
731
733
  static has(type: ChartType): boolean;
732
734
  protected cloneValue<T>(value: T): T;
733
735
  protected clonePlugins<TPlugins>(plugins: TPlugins): TPlugins;
736
+ protected applyGlobalPluginConfig(): void;
734
737
  protected requireDatasets(): CustomChartDatasets<TType>[];
735
738
  protected resolveDatasetIndex(uidOrIndex: string | number): number;
736
739
  protected getDatasetByTarget(uidOrIndex: string | number): CustomChartDatasets<TType>;
@@ -826,6 +829,20 @@ declare abstract class Chart<TType extends ChartType, TOptions extends CustomCha
826
829
  * });
827
830
  */
828
831
  setLegend(legendOptions: DeepPartial<LegendOptions<TType>>): this;
832
+ /**
833
+ * @description 차트의 툴팁을 설정합니다.
834
+ * 전역 `setChartConfig({ tooltip: ... })` 설정이 있으면 이를 기본값으로 사용하고, 이 메서드 호출값으로 병합합니다.
835
+ * @param {DeepPartial<TooltipOptions<TType>>} tooltipOptions
836
+ * @returns {this}
837
+ * @Since 2.4.0
838
+ * @category options
839
+ * @example
840
+ * chart.setTooltip({
841
+ * enabled: true,
842
+ * backgroundColor: 'rgba(8, 26, 61, 0.95)'
843
+ * });
844
+ */
845
+ setTooltip(tooltipOptions: DeepPartial<TooltipOptions<TType>>): this;
829
846
  /**
830
847
  * @description 기존 옵션에 부분 옵션을 병합합니다.
831
848
  * @param {DeepPartial<TOptions>} options
@@ -1043,6 +1060,7 @@ declare abstract class CartesianChart<TType extends CartesianChartType> extends
1043
1060
  } | {
1044
1061
  id: string;
1045
1062
  _tooltips: WeakMap<WeakKey, any>;
1063
+ _resolveLegendDatasetIndex(legendItem: any): number | undefined;
1046
1064
  afterInit(chart: any, args: any, options: any): void;
1047
1065
  beforeUpdate(chart: any, args: any, options: any): void;
1048
1066
  _handleGroupVisibility(chart: any, datasets: any[]): void;
@@ -1056,6 +1074,9 @@ declare abstract class CartesianChart<TType extends CartesianChartType> extends
1056
1074
  protected isLine(): boolean;
1057
1075
  protected isScatter(): boolean;
1058
1076
  protected isBar(): boolean;
1077
+ protected applyGlobalZoomConfig(): void;
1078
+ protected ensureZoomResetPlugin(): void;
1079
+ protected removeZoomResetPlugin(): void;
1059
1080
  protected normalize(): void;
1060
1081
  protected configAop(config: any): any;
1061
1082
  /**
@@ -1186,14 +1207,31 @@ declare abstract class CartesianChart<TType extends CartesianChartType> extends
1186
1207
  lineWidth?: number;
1187
1208
  }): this;
1188
1209
  /**
1189
- * @description 줌 기능을 추가합니다. 해당 기능은 플러그인 설치가 필요합니다.
1190
- * @param defaultZoom
1191
- * @param zoomOption
1210
+ * @description 줌 기능을 설정합니다. `false`를 전달하면 현재 차트의 줌 설정을 제거합니다.
1211
+ * 전역 `setChartConfig({ zoom: true })` 설정이 있더라도 이 메서드로 차트별 비활성화가 가능합니다.
1212
+ * @param {boolean} enabled
1213
+ * @param {CustomZoomType<TType>} zoomOption
1214
+ * @returns {this}
1215
+ * @since 2.4.0
1216
+ * @category Plugins
1217
+ */
1218
+ setZoom(enabled: boolean, zoomOption?: DeepPartialZoomType): this;
1219
+ /**
1220
+ * @deprecated `setZoom(enabled, zoomOption)`을 사용하세요.
1221
+ * @description 레거시 줌 설정 메서드입니다. 내부적으로 `setZoom(true, ...)`를 호출합니다.
1222
+ * @param defaultZoom - `true`이면 기본 줌 옵션을 적용합니다.
1223
+ * @param zoomOption - 사용자 정의 줌 옵션입니다.
1192
1224
  * @returns {this}
1193
1225
  * @since 1.0.0
1194
1226
  * @category Plugins
1195
1227
  * @defaultValue defaultZoom = false
1228
+ * @example
1229
+ * // 기존 방식
1230
+ * chart.addZoom(true);
1196
1231
  *
1232
+ * @example
1233
+ * // 권장 방식
1234
+ * chart.setZoom(true);
1197
1235
  */
1198
1236
  addZoom(defaultZoom?: boolean, zoomOption?: object): this;
1199
1237
  /**
@@ -2740,6 +2778,7 @@ declare const chartMountPlugin: {
2740
2778
  declare const customDatasetPlugins: {
2741
2779
  id: string;
2742
2780
  _tooltips: WeakMap<WeakKey, any>;
2781
+ _resolveLegendDatasetIndex(legendItem: any): number | undefined;
2743
2782
  afterInit(chart: any, args: any, options: any): void;
2744
2783
  beforeUpdate(chart: any, args: any, options: any): void;
2745
2784
  _handleGroupVisibility(chart: any, datasets: any[]): void;
@@ -3096,6 +3135,9 @@ interface StzConfig {
3096
3135
  errorLogging?: boolean;
3097
3136
  silentMode?: boolean;
3098
3137
  defaultColor?: string[];
3138
+ zoom?: boolean | DeepPartialZoomType;
3139
+ legend?: DeepPartial<LegendOptions<any>>;
3140
+ tooltip?: DeepPartial<TooltipOptions<any>>;
3099
3141
  /** @deprecated no-op. Built-in chart types are bootstrapped at package load time. */
3100
3142
  autoRegister?: boolean;
3101
3143
  /** @deprecated no-op. Built-in chart types are bootstrapped at package load time. */
@@ -3112,7 +3154,14 @@ interface StzConfig {
3112
3154
  * setChartConfig({
3113
3155
  * errorLogging: true,
3114
3156
  * silentMode: false,
3115
- * defaultColor: ['#111111', '#22c55e', '#3b82f6']
3157
+ * defaultColor: ['#111111', '#22c55e', '#3b82f6'],
3158
+ * zoom: true,
3159
+ * legend: {
3160
+ * position: 'top'
3161
+ * },
3162
+ * tooltip: {
3163
+ * enabled: true
3164
+ * }
3116
3165
  * });
3117
3166
  * ```
3118
3167
  *