@cehlers88/chart 1.0.3 → 1.0.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.
@@ -0,0 +1,4 @@
1
+ export interface ICanvasDiagram {
2
+ addPlugin(plugin: any): ICanvasDiagram;
3
+ start(): ICanvasDiagram;
4
+ }
@@ -0,0 +1,7 @@
1
+ import IRectangleBase from "@cehlers88/ceutils/dist/Interfaces/IRectangleBase";
2
+ export interface IChartEntity extends IRectangleBase {
3
+ data: {
4
+ [key: string]: any;
5
+ };
6
+ source: string;
7
+ }
@@ -6,13 +6,26 @@
6
6
  */
7
7
  import { TDataGroup } from "../type/TDataGroup";
8
8
  import { TRect } from "../type/TRect";
9
- import { TChartEngineCallbacks } from "../type/TChartEngineCallbacks";
10
9
  export interface IChartPlugin {
11
- create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[], engineCallbacks: TChartEngineCallbacks): IChartPlugin;
12
- draw(): IChartPlugin;
10
+ create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[]): {
11
+ plugin: IChartPlugin;
12
+ dataGroups: TDataGroup[];
13
+ };
14
+ draw(forceRedraw?: boolean): IChartPlugin;
13
15
  getDrawAreaRect(): TRect;
14
16
  getName(): string;
15
17
  getProperty(propertyName: string, defaultResult: any): any;
18
+ getPriority(): number;
19
+ handleClick(x: number, y: number): IChartPlugin;
20
+ handleHover(x: number, y: number): IChartPlugin;
21
+ handleLeave(): IChartPlugin;
22
+ handleScroll(x: number, y: number): IChartPlugin;
23
+ setCamera(camera: any): IChartPlugin;
24
+ setDrawAreaRect(rect: TRect): IChartPlugin;
25
+ setEntityRegistry(entityRegistry: any): IChartPlugin;
16
26
  setProperty(propertyName: string, value: any): IChartPlugin;
17
- update(dataGroups: TDataGroup[]): TDataGroup[];
27
+ update(dataGroups: TDataGroup[]): {
28
+ dataGroups: TDataGroup[];
29
+ };
30
+ get needsRedraw(): boolean;
18
31
  }
@@ -0,0 +1,13 @@
1
+ import AbstractPlugin from "./AbstractPlugin";
2
+ import { TDataGroup } from "../type/TDataGroup";
3
+ export default abstract class AbstractDiagramPlugin extends AbstractPlugin {
4
+ constructor(props?: {
5
+ padding?: number;
6
+ viewSize?: number;
7
+ [key: string]: any;
8
+ });
9
+ update(dataGroups: TDataGroup[]): {
10
+ dataGroups: TDataGroup[];
11
+ };
12
+ protected updateBufferSize(dataGroups: any): number;
13
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Library AbstractChartPlugin
3
+ * Created 26.11.22
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import { IChartPlugin } from "../interface/IChartPlugin";
8
+ import { TDataGroup } from "../type/TDataGroup";
9
+ import { TRect } from "../type/TRect";
10
+ import Camera from "../Camera";
11
+ import EntityRegistry from "../Registry/EntityRegistry";
12
+ import { IChartEntity } from "../interface/IChartEntity";
13
+ export default abstract class AbstractPlugin implements IChartPlugin {
14
+ private _buffer;
15
+ protected _camera: Camera;
16
+ protected _dataGroups: TDataGroup[];
17
+ private _drawAreaRect;
18
+ protected _entityRegistry: EntityRegistry;
19
+ protected _fixed: boolean;
20
+ private _properties;
21
+ protected _priority: number;
22
+ protected bufferCtx: CanvasRenderingContext2D;
23
+ protected ctx: CanvasRenderingContext2D;
24
+ protected redrawBuffer: boolean;
25
+ abstract getName(): string;
26
+ constructor(props?: {
27
+ enabled?: boolean;
28
+ [key: string]: any;
29
+ });
30
+ update(dataGroups: TDataGroup[]): {
31
+ dataGroups: TDataGroup[];
32
+ };
33
+ updateDataGroups(dataGroups: TDataGroup[]): {
34
+ dataGroups: TDataGroup[];
35
+ };
36
+ addEntity(entity: IChartEntity): AbstractPlugin;
37
+ protected createBuffer(canvasElement: HTMLCanvasElement, width?: number | null, height?: number | null): void;
38
+ create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[]): {
39
+ dataGroups: TDataGroup[];
40
+ plugin: AbstractPlugin;
41
+ };
42
+ drawBuffer(): void;
43
+ draw(forceRedraw?: boolean): IChartPlugin;
44
+ getDrawAreaRect(): TRect;
45
+ getPriority(): number;
46
+ getProperty(propertyName: string, defaultResult: any): any;
47
+ handleClick(x: number, y: number): AbstractPlugin;
48
+ handleHover(x: number, y: number): AbstractPlugin;
49
+ handleLeave(): IChartPlugin;
50
+ handleScroll(x: number, y: number): AbstractPlugin;
51
+ setBuffer(buffer: HTMLCanvasElement): AbstractPlugin;
52
+ setCamera(camera: Camera): AbstractPlugin;
53
+ setDrawAreaRect(rect: TRect): AbstractPlugin;
54
+ setEntityRegistry(entityRegistry: EntityRegistry): AbstractPlugin;
55
+ setProperty(propertyName: string, value: any): AbstractPlugin;
56
+ init(): AbstractPlugin;
57
+ get needsRedraw(): boolean;
58
+ }
@@ -4,22 +4,28 @@
4
4
  *
5
5
  * @author Christoph Ehlers
6
6
  */
7
- import AbstractChartPlugin from "./AbstractChartPlugin";
7
+ import AbstractPlugin from "./AbstractPlugin";
8
8
  import { TDataGroup } from "../type/TDataGroup";
9
9
  import { IChartPlugin } from "../interface/IChartPlugin";
10
+ import AbstractDiagramPlugin from "./AbstractDiagramPlugin";
10
11
  export declare enum ERangeType {
11
12
  ZERO_BASED = "zero_based",
12
13
  MIN_MAX = "min_max"
13
14
  }
14
- export default class BarsPlugin extends AbstractChartPlugin {
15
- private dataGroups;
15
+ export default class BarsPlugin extends AbstractDiagramPlugin {
16
+ private barGroups;
17
+ private hoverPosition;
16
18
  private rangeType;
17
- private showZeroLine;
18
- private syncGroupsPosition;
19
- private zeroLineValue;
20
- private zeroLineValuePercentage;
21
- draw(): IChartPlugin;
22
- private calcPointGap;
23
- update(dataGroups: TDataGroup[]): TDataGroup[];
19
+ constructor(props?: {
20
+ animationSpeed?: number;
21
+ enableAnimations?: boolean;
22
+ padding?: number;
23
+ });
24
+ drawBuffer(): void;
25
+ handleHover(x: number, y: number): AbstractPlugin;
26
+ updateDataGroups(dataGroups: TDataGroup[]): {
27
+ dataGroups: TDataGroup[];
28
+ };
29
+ updateAnimations(): IChartPlugin;
24
30
  getName(): string;
25
31
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Library DiagramLine
3
+ * Created 26.11.22
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import AbstractPlugin from "./AbstractPlugin";
8
+ import { TDataGroup } from "../type/TDataGroup";
9
+ export default class CameraMove extends AbstractPlugin {
10
+ constructor(props: {
11
+ allowScrollX?: boolean;
12
+ allowScrollY?: boolean;
13
+ speed?: number;
14
+ });
15
+ handleScroll(x: number, y: number): AbstractPlugin;
16
+ setCameraXDestination(): void;
17
+ create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[]): {
18
+ dataGroups: TDataGroup[];
19
+ plugin: AbstractPlugin;
20
+ };
21
+ update(dataGroups: TDataGroup[]): {
22
+ dataGroups: TDataGroup[];
23
+ };
24
+ getName(): string;
25
+ }
@@ -4,22 +4,35 @@
4
4
  *
5
5
  * @author Christoph Ehlers
6
6
  */
7
- import AbstractChartPlugin from "./AbstractChartPlugin";
7
+ import AbstractPlugin from "./AbstractPlugin";
8
8
  import { TDataGroup } from "../type/TDataGroup";
9
- import { IChartPlugin } from "../interface/IChartPlugin";
9
+ import { TRect } from "../type/TRect";
10
+ import AbstractDiagramPlugin from "./AbstractDiagramPlugin";
10
11
  export declare enum ERangeType {
11
12
  ZERO_BASED = "zero_based",
12
13
  MIN_MAX = "min_max"
13
14
  }
14
- export default class DiagramLine extends AbstractChartPlugin {
15
- private dataGroups;
15
+ export default class DiagramLine extends AbstractDiagramPlugin {
16
+ private bulletPointRadius;
17
+ private bulletPointRadiusHover;
18
+ private dataPoints;
19
+ private helpLines;
20
+ private hoverPosition;
16
21
  private rangeType;
17
22
  private syncGroupsPosition;
18
23
  private zeroLineValue;
19
24
  private zeroLineValuePercentage;
25
+ constructor(props?: {
26
+ showBulletPoints?: boolean;
27
+ });
20
28
  private _showZeroLine;
21
- draw(): IChartPlugin;
29
+ drawHelpLines(): this;
30
+ drawBuffer(): this;
22
31
  private calcPointGap;
23
- update(dataGroups: TDataGroup[]): TDataGroup[];
32
+ handleHover(x: number, y: number): AbstractPlugin;
33
+ updateDataGroups(dataGroups: TDataGroup[]): {
34
+ dataGroups: TDataGroup[];
35
+ };
36
+ getDrawAreaRect(): TRect;
24
37
  getName(): string;
25
38
  }
@@ -4,9 +4,13 @@
4
4
  *
5
5
  * @author Christoph Ehlers
6
6
  */
7
- import AbstractChartPlugin from "./AbstractChartPlugin";
7
+ import AbstractPlugin from "./AbstractPlugin";
8
8
  import { TDataGroup } from "../type/TDataGroup";
9
- export default class EnrichGroupInfosPlugin extends AbstractChartPlugin {
10
- update(dataGroups: TDataGroup[]): TDataGroup[];
9
+ export default class EnrichGroupInfosPlugin extends AbstractPlugin {
10
+ constructor();
11
+ updateDataGroups(dataGroups: TDataGroup[]): {
12
+ dataGroups: TDataGroup[];
13
+ };
14
+ getLargestDecimalStep(x: number): number;
11
15
  getName(): string;
12
16
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Library LegendsPlugin
3
+ * Created 30.09.24
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import AbstractPlugin from "./AbstractPlugin";
8
+ export declare enum ERangeType {
9
+ ZERO_BASED = "zero_based",
10
+ MIN_MAX = "min_max"
11
+ }
12
+ export default class LegendsPlugin extends AbstractPlugin {
13
+ constructor(props?: {
14
+ x?: number;
15
+ y?: number;
16
+ });
17
+ drawBuffer(): void;
18
+ getName(): string;
19
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Library PaginationPlugin
3
+ * Created 03.10.24
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import AbstractPlugin from "./AbstractPlugin";
8
+ import { TDataGroup } from "../type/TDataGroup";
9
+ export default class PaginationPlugin extends AbstractPlugin {
10
+ private static DEFAULT_PAGE_SIZE;
11
+ private static DEFAULT_CURRENT_PAGE;
12
+ private _dataGroupsRaw;
13
+ private _dataGroupsCurrentPage;
14
+ private _pages;
15
+ private _lastUpdatedPage;
16
+ constructor(props?: {
17
+ currentPage?: number;
18
+ pageSize?: number;
19
+ });
20
+ create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[]): {
21
+ dataGroups: TDataGroup[];
22
+ plugin: AbstractPlugin;
23
+ };
24
+ getName(): string;
25
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Library PaginationPlugin
3
+ * Created 03.10.24
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import AbstractPlugin from "./AbstractPlugin";
8
+ import { TDataGroup } from "../type/TDataGroup";
9
+ export default class TimelinePlugin extends AbstractPlugin {
10
+ private static DIRECTION_HORIZONTAL;
11
+ private static DIRECTION_VERTICAL;
12
+ private static VIEW_TYPE_HOUR;
13
+ private static VIEW_TYPE_DAY;
14
+ private static VIEW_TYPE_WEEK;
15
+ private static VIEW_TYPE_MONTH;
16
+ private static VIEW_TYPE_YEAR;
17
+ constructor(props?: {
18
+ direction?: number;
19
+ mainSections?: number | Array<string>;
20
+ resolution?: number;
21
+ });
22
+ private getMainSectionHeight;
23
+ create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[]): {
24
+ dataGroups: TDataGroup[];
25
+ plugin: AbstractPlugin;
26
+ };
27
+ protected createBuffer(canvasElement: HTMLCanvasElement, width?: number | null, height?: number | null): void;
28
+ drawMainSection(x: number, y: number, width: number, height: number, color?: string): void;
29
+ drawBuffer(): void;
30
+ getName(): string;
31
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Library TooltipPlugin
3
+ * Created 30.09.24
4
+ *
5
+ * @author Christoph Ehlers
6
+ */
7
+ import AbstractPlugin from "./AbstractPlugin";
8
+ export declare enum ERangeType {
9
+ ZERO_BASED = "zero_based",
10
+ MIN_MAX = "min_max"
11
+ }
12
+ export default class TooltipPlugin extends AbstractPlugin {
13
+ getName(): string;
14
+ }
@@ -8,4 +8,6 @@ export type TData = {
8
8
  empty: boolean;
9
9
  label: string;
10
10
  value: number;
11
+ valueStart?: number;
12
+ hasLabel?: boolean;
11
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cehlers88/chart",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A library to create charts using JavaScript and Canvas-Element.",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "webpack",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "watch": "webpack --watch",
12
+ "test": "jest"
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",
@@ -30,9 +31,18 @@
30
31
  "homepage": "https://github.com/cEhlers88/Chart#readme",
31
32
  "types": "dist/index.d.ts",
32
33
  "devDependencies": {
34
+ "@types/jest": "^29.5.13",
35
+ "css-loader": "^7.1.2",
36
+ "jest": "^29.7.0",
37
+ "style-loader": "^4.0.0",
38
+ "ts-jest": "^29.2.5",
33
39
  "ts-loader": "^9.5.1",
34
- "typescript": "^5.4.5",
40
+ "typescript": "^5.6.2",
35
41
  "webpack": "^5.91.0",
36
42
  "webpack-cli": "^5.1.4"
43
+ },
44
+ "dependencies": {
45
+ "@cehlers88/ceutils": "^1.2.68",
46
+ "core-js": "^3.47.0"
37
47
  }
38
48
  }
@@ -1,23 +0,0 @@
1
- /**
2
- * Library AbstractChartPlugin
3
- * Created 26.11.22
4
- *
5
- * @author Christoph Ehlers
6
- */
7
- import { IChartPlugin } from "../interface/IChartPlugin";
8
- import { TDataGroup } from "../type/TDataGroup";
9
- import { TRect } from "../type/TRect";
10
- import { TChartEngineCallbacks } from "../type/TChartEngineCallbacks";
11
- export default abstract class AbstractChartPlugin implements IChartPlugin {
12
- private _drawAreaRect;
13
- private _properties;
14
- protected ctx: CanvasRenderingContext2D;
15
- abstract getName(): string;
16
- abstract update(dataGroups: TDataGroup[]): TDataGroup[];
17
- create(canvasElement: HTMLCanvasElement, dataGroups: TDataGroup[], engineCallbacks: TChartEngineCallbacks): AbstractChartPlugin;
18
- draw(): IChartPlugin;
19
- getDrawAreaRect(): TRect;
20
- getProperty(propertyName: string, defaultResult: any): any;
21
- setProperty(propertyName: string, value: any): AbstractChartPlugin;
22
- init(): AbstractChartPlugin;
23
- }