@oliasoft-open-source/charts-library 4.2.0 → 4.3.0-beta-1

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.
@@ -29,6 +29,7 @@ export interface ICommonAnnotationElement {
29
29
  scaleID?: string;
30
30
  borderColor?: string;
31
31
  borderWidth?: number;
32
+ radius?: number;
32
33
  label?: {
33
34
  content?: string;
34
35
  position?: string;
@@ -37,6 +38,10 @@ export interface ICommonAnnotationElement {
37
38
  };
38
39
  };
39
40
  }
41
+ export interface ICoordinates {
42
+ x: number;
43
+ y: number;
44
+ }
40
45
  export interface ICommonAnnotationsData {
41
46
  display?: boolean;
42
47
  hideLegend?: boolean;
@@ -51,6 +56,12 @@ export interface ICommonAnnotationsData {
51
56
  xMax: number;
52
57
  yMin: number;
53
58
  yMax: number;
59
+ xValue?: number;
60
+ yValue?: number;
61
+ enableDrag?: boolean;
62
+ onDragStart?: (coordinates: ICoordinates) => void;
63
+ onDrag?: (coordinates: ICoordinates) => void;
64
+ onDragEnd?: (coordinates: ICoordinates) => void;
54
65
  }
55
66
  export interface ICommonStyling {
56
67
  width?: number | string;
@@ -92,6 +103,7 @@ export interface ICommonAnnotation {
92
103
  export interface ICommonAnnotations {
93
104
  showAnnotations?: boolean;
94
105
  controlAnnotation?: boolean;
106
+ enableDragAnnotation?: boolean;
95
107
  annotationsData?: ICommonAnnotationsData[];
96
108
  labelAnnotation?: ICommonAnnotation;
97
109
  }
@@ -1,6 +1,6 @@
1
1
  import { Chart } from 'chart.js';
2
2
  import { Position } from './enums';
3
- import { ICommonAnnotationElement, ICommonAnnotationsData } from '../common.interface';
3
+ import { ICommonAnnotationElement, ICommonAnnotationsData, ICoordinates } from '../common.interface';
4
4
  export interface IGetAnnotationsProps {
5
5
  showAnnotations: boolean;
6
6
  annotationsData: ICommonAnnotationsData[];
@@ -28,7 +28,7 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
28
28
  backgroundColor: string;
29
29
  borderColor: string;
30
30
  borderWidth: number;
31
- borderDash: number[];
31
+ borderDash: number[] | undefined;
32
32
  type: string;
33
33
  adjustScaleRange: boolean;
34
34
  enter: ({ element, }: {
@@ -41,6 +41,9 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
41
41
  }, { chart, }: {
42
42
  chart: Chart;
43
43
  }) => void;
44
+ onDragStart: () => (cord: ICoordinates) => void;
45
+ onDrag: () => (cord: ICoordinates) => void;
46
+ onDragEnd: () => (cord: ICoordinates) => void;
44
47
  hideLegend?: boolean | undefined;
45
48
  annotationAxis: "x" | "y";
46
49
  color: string;
@@ -50,5 +53,8 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
50
53
  xMax: number;
51
54
  yMin: number;
52
55
  yMax: number;
56
+ xValue?: number | undefined;
57
+ yValue?: number | undefined;
58
+ enableDrag?: boolean | undefined;
53
59
  }[];
54
60
  export default getAnnotation;
@@ -0,0 +1,14 @@
1
+ import { ChartType, Plugin, Scale } from 'chart.js';
2
+ export interface IScales {
3
+ x: Scale;
4
+ y: Scale;
5
+ }
6
+ export interface AnnotationDraggerPluginOptions {
7
+ enabled: boolean;
8
+ }
9
+ declare module 'chart.js' {
10
+ interface PluginOptionsByType<TType extends ChartType> {
11
+ annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
12
+ }
13
+ }
14
+ export declare const annotationDraggerPlugin: Plugin;
@@ -0,0 +1,15 @@
1
+ export declare enum FontStyle {
2
+ DEFAULT = "14px Arial",
3
+ CUSTOM = "16px Arial"
4
+ }
5
+ export declare enum MouseEvents {
6
+ MOUSEDOWN = "mousedown",
7
+ MOUSEMOVE = "mousemove",
8
+ MOUSEUP = "mouseup"
9
+ }
10
+ export declare enum AnnotationType {
11
+ POINT = "point",
12
+ BOX = "box",
13
+ LINE = "line",
14
+ ELLIPSE = "ellipse"
15
+ }
@@ -0,0 +1,6 @@
1
+ import { Chart } from 'chart.js';
2
+ import { IScales } from '../../../common/plugins/annotation-dragger-plugin/annotation-dragger-plugin';
3
+ import { ICommonAnnotationsData } from '../../../common/common.interface';
4
+ export declare const handleAnnotationMouseDown: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales, annotations: Record<string, ICommonAnnotationsData>, setDraggingState: (isDragging: boolean, annotation: ICommonAnnotationsData | null, dragStartX: number, dragStartY: number) => void) => void;
5
+ export declare const handleAnnotationMouseMove: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales, isDragging: boolean, activeAnnotation: ICommonAnnotationsData | null, dragStartX: number, dragStartY: number, chart: Chart) => void;
6
+ export declare const handleAnnotationMouseUp: (isDragging: boolean, activeAnnotation: ICommonAnnotationsData | null, chart: Chart, setDraggingState: (isDragging: boolean, annotation: ICommonAnnotationsData | null) => void) => void;
@@ -0,0 +1,23 @@
1
+ import { ICommonAnnotationsData } from '../../../common/common.interface';
2
+ import { IScales } from '../../../common/plugins/annotation-dragger-plugin/annotation-dragger-plugin';
3
+ export declare const getMousePosition: (event: MouseEvent, canvas: HTMLCanvasElement) => {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ export declare const getMousePositionInCoordinates: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales) => {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ export declare const getActiveAnnotation: (x: number, y: number, annotations: Record<string, ICommonAnnotationsData>) => ICommonAnnotationsData;
12
+ export declare const calculateAnnotationMetricsInValues: (annotation: ICommonAnnotationsData) => {
13
+ centerX: number | undefined;
14
+ centerY: number | undefined;
15
+ width: number | undefined;
16
+ height: number | undefined;
17
+ };
18
+ export declare const calculateAnnotationMetricsInValuesInPixels: (annotation: ICommonAnnotationsData, scales: IScales) => {
19
+ centerX: number | undefined;
20
+ centerY: number | undefined;
21
+ width: number | undefined;
22
+ height: number | undefined;
23
+ };
@@ -12,6 +12,7 @@ export declare enum defaultTranslations {
12
12
  dragToZoom = "Drag to zoom",
13
13
  dragToPan = "Drag to pan",
14
14
  dragToMovePoints = "Drag to move points",
15
+ dragToMoveAnnotation = "Drag to move annotation",
15
16
  dragDisabled = "Drag disabled",
16
17
  hideLegend = "Hide Legend",
17
18
  showLegend = "Show Legend",
@@ -3,8 +3,11 @@ export interface IDragOptions {
3
3
  onToggleZoom: () => void;
4
4
  panEnabled: boolean;
5
5
  zoomEnabled: boolean;
6
- enableDragPoints: boolean;
6
+ enableDragPoints?: boolean;
7
+ enableDragAnnotation?: boolean;
7
8
  isDragDataAllowed?: boolean;
9
+ isDragAnnotationAllowed?: boolean;
10
+ onToggleDragAnnotation: () => void;
8
11
  onToggleDragPoints: () => void;
9
12
  onDisableDragOptions: () => void;
10
13
  translations: Record<string, string>;
@@ -2,4 +2,4 @@ import { IDragOptions } from './drag-options-interfaces';
2
2
  /**
3
3
  * @param {import('./drag-options-interfaces').IDragOptions} obj
4
4
  */
5
- export declare const DragOptions: ({ onTogglePan, onToggleZoom, panEnabled, zoomEnabled, enableDragPoints, isDragDataAllowed, onToggleDragPoints, onDisableDragOptions, translations: { dragToZoom, doubleClickToReset, dragToPan, orDoubleClickToCanvas, dragToMovePoints, dragDisabled, }, }: IDragOptions) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const DragOptions: ({ onTogglePan, onToggleZoom, panEnabled, zoomEnabled, enableDragPoints, enableDragAnnotation, isDragDataAllowed, isDragAnnotationAllowed, onToggleDragAnnotation, onToggleDragPoints, onDisableDragOptions, translations: { dragToZoom, doubleClickToReset, dragToPan, orDoubleClickToCanvas, dragToMovePoints, dragDisabled, dragToMoveAnnotation, }, }: IDragOptions) => import("react/jsx-runtime").JSX.Element;
@@ -7,5 +7,6 @@ export declare const useToggleHandlers: (dispatch: Dispatch<any>) => {
7
7
  onToggleTable: () => void;
8
8
  onToggleZoom: () => void;
9
9
  onToggleDragPoints: () => void;
10
+ onToggleDragAnnotation: () => void;
10
11
  onDisableDragOptions: () => void;
11
12
  };
@@ -1228,6 +1228,99 @@ export function FilterAnnotationWhenLegendClick(): import("react/jsx-runtime").J
1228
1228
  export function GroupedDS(): import("react/jsx-runtime").JSX.Element;
1229
1229
  export function SimilarValuesWithAnnotation(): import("react/jsx-runtime").JSX.Element;
1230
1230
  export function HideSpecificDatasetAndAnnotation(): import("react/jsx-runtime").JSX.Element;
1231
+ export function DragAnnotations(args: any): import("react/jsx-runtime").JSX.Element;
1232
+ export namespace DragAnnotations {
1233
+ export namespace args_45 {
1234
+ export namespace chart_43 {
1235
+ export namespace options_36 {
1236
+ export namespace legend_5 {
1237
+ const display_2: boolean;
1238
+ export { display_2 as display };
1239
+ }
1240
+ export { legend_5 as legend };
1241
+ export namespace annotations_5 {
1242
+ const showAnnotations_5: boolean;
1243
+ export { showAnnotations_5 as showAnnotations };
1244
+ export const enableDragAnnotation: boolean;
1245
+ const annotationsData_5: ({
1246
+ annotationAxis: string;
1247
+ label: string;
1248
+ value: number;
1249
+ enableDrag?: undefined;
1250
+ type?: undefined;
1251
+ xMin?: undefined;
1252
+ xMax?: undefined;
1253
+ yMin?: undefined;
1254
+ yMax?: undefined;
1255
+ color?: undefined;
1256
+ onDragStart?: undefined;
1257
+ onDrag?: undefined;
1258
+ onDragEnd?: undefined;
1259
+ xValue?: undefined;
1260
+ yValue?: undefined;
1261
+ radius?: undefined;
1262
+ } | {
1263
+ enableDrag: boolean;
1264
+ type: string;
1265
+ xMin: number;
1266
+ xMax: number;
1267
+ yMin: number;
1268
+ yMax: number;
1269
+ color: string;
1270
+ onDragStart: (cord: any) => void;
1271
+ onDrag: (cord: any) => void;
1272
+ onDragEnd: (cord: any) => void;
1273
+ annotationAxis?: undefined;
1274
+ label?: undefined;
1275
+ value?: undefined;
1276
+ xValue?: undefined;
1277
+ yValue?: undefined;
1278
+ radius?: undefined;
1279
+ } | {
1280
+ enableDrag: boolean;
1281
+ type: string;
1282
+ xMin: number;
1283
+ xMax: number;
1284
+ yMin: number;
1285
+ yMax: number;
1286
+ color: string;
1287
+ annotationAxis?: undefined;
1288
+ label?: undefined;
1289
+ value?: undefined;
1290
+ onDragStart?: undefined;
1291
+ onDrag?: undefined;
1292
+ onDragEnd?: undefined;
1293
+ xValue?: undefined;
1294
+ yValue?: undefined;
1295
+ radius?: undefined;
1296
+ } | {
1297
+ type: string;
1298
+ enableDrag: boolean;
1299
+ xValue: number;
1300
+ yValue: number;
1301
+ radius: number;
1302
+ color: string;
1303
+ onDragStart: (cord: any) => void;
1304
+ onDrag: (cord: any) => void;
1305
+ onDragEnd: (cord: any) => void;
1306
+ annotationAxis?: undefined;
1307
+ label?: undefined;
1308
+ value?: undefined;
1309
+ xMin?: undefined;
1310
+ xMax?: undefined;
1311
+ yMin?: undefined;
1312
+ yMax?: undefined;
1313
+ })[];
1314
+ export { annotationsData_5 as annotationsData };
1315
+ }
1316
+ export { annotations_5 as annotations };
1317
+ }
1318
+ export { options_36 as options };
1319
+ }
1320
+ export { chart_43 as chart };
1321
+ }
1322
+ export { args_45 as args };
1323
+ }
1231
1324
  import { LineChart } from './line-chart';
1232
1325
  declare namespace basicChart { }
1233
1326
  declare const customLegendContainerID: "custom-legend-container";
@@ -8,4 +8,5 @@ export declare const SAVE_INITIAL_AXES_RANGES = "SAVE_INITIAL_AXES_RANGES";
8
8
  export declare const RESET_AXES_RANGES = "RESET_AXES_RANGES";
9
9
  export declare const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
10
10
  export declare const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
11
+ export declare const TOGGLE_DRAG_ANNOTATION = "TOGGLE_DRAG_ANNOTATION";
11
12
  export declare const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
@@ -17,6 +17,7 @@ export interface InitialState {
17
17
  showAnnotationLineIndex?: number[];
18
18
  showTable: boolean;
19
19
  enableDragPoints: boolean;
20
+ enableDragAnnotation: boolean;
20
21
  }
21
22
  export interface IInitAxisRange {
22
23
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "4.2.0",
3
+ "version": "4.3.0-beta-1",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
6
6
  "resolutions": {