@cehlers88/chart 1.1.1 → 1.2.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.
- package/README.md +145 -3
- package/dist/ChartEngine.d.ts +72 -0
- package/dist/Factory/DataGroupFactory.d.ts +34 -1
- package/dist/Registry/DiagramRegistry.d.ts +8 -0
- package/dist/Utils/ChartStyle.d.ts +69 -0
- package/dist/customElement/CanvasDiagram.d.ts +44 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +23 -12
- package/dist/interface/ICanvasDiagram.d.ts +15 -0
- package/dist/interface/IChartEngine.d.ts +9 -0
- package/dist/interface/IChartPlugin.d.ts +2 -0
- package/dist/plugin/AbstractDiagramPlugin.d.ts +2 -4
- package/dist/plugin/AbstractPlugin.d.ts +32 -0
- package/dist/plugin/DiagramLine.d.ts +71 -8
- package/dist/plugin/LegendsPlugin.d.ts +17 -1
- package/dist/type/TData.d.ts +1 -0
- package/dist/type/TDataGroup.d.ts +2 -0
- package/package.json +4 -2
|
@@ -1,42 +1,105 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Library DiagramLine
|
|
3
3
|
* Created 26.11.22
|
|
4
|
+
* Last modified 29.09.26
|
|
4
5
|
*
|
|
5
6
|
* @author Christoph Ehlers
|
|
6
7
|
*/
|
|
7
8
|
import AbstractPlugin from "./AbstractPlugin";
|
|
8
9
|
import { TDataGroup } from "../type/TDataGroup";
|
|
9
|
-
import {
|
|
10
|
+
import { IChartPlugin } from "../interface/IChartPlugin";
|
|
10
11
|
import AbstractDiagramPlugin from "./AbstractDiagramPlugin";
|
|
11
12
|
export declare enum ERangeType {
|
|
12
13
|
ZERO_BASED = "zero_based",
|
|
13
14
|
MIN_MAX = "min_max"
|
|
14
15
|
}
|
|
15
16
|
export default class DiagramLine extends AbstractDiagramPlugin {
|
|
17
|
+
private static X_AXIS_HEIGHT;
|
|
18
|
+
private static PLOT_INSET_TOP;
|
|
19
|
+
private static PLOT_INSET_BOTTOM;
|
|
20
|
+
static TOOLTIP_ENTITY_SOURCE: string;
|
|
21
|
+
private static _instanceCounter;
|
|
22
|
+
private _tooltipEntityId;
|
|
16
23
|
private bulletPointRadius;
|
|
17
24
|
private bulletPointRadiusHover;
|
|
18
25
|
private dataPoints;
|
|
19
|
-
private
|
|
26
|
+
private hoverIndex;
|
|
20
27
|
private hoverPosition;
|
|
28
|
+
private maxDataLength;
|
|
29
|
+
private plotRect;
|
|
30
|
+
private pointGap;
|
|
21
31
|
private rangeType;
|
|
22
|
-
private
|
|
23
|
-
private zeroLineValue;
|
|
24
|
-
private zeroLineValuePercentage;
|
|
32
|
+
private yAxis;
|
|
25
33
|
constructor(props?: {
|
|
34
|
+
decimals?: number;
|
|
26
35
|
fill?: boolean;
|
|
36
|
+
lineWidth?: number;
|
|
37
|
+
maxYTicks?: number;
|
|
27
38
|
padding?: number;
|
|
28
39
|
showBulletPoints?: boolean;
|
|
40
|
+
showGrid?: boolean;
|
|
29
41
|
showHelpLines?: boolean;
|
|
42
|
+
showTooltip?: boolean;
|
|
43
|
+
showXLabels?: boolean;
|
|
44
|
+
showYLabels?: boolean;
|
|
30
45
|
showZeroLine?: boolean;
|
|
46
|
+
smooth?: boolean;
|
|
47
|
+
[key: string]: any;
|
|
31
48
|
});
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
drawBuffer(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Draws the buffer and on top of it everything that must not scroll with
|
|
52
|
+
* the camera or changes with every pointer move: the value axis and the
|
|
53
|
+
* hover crosshair with its tooltip.
|
|
54
|
+
*/
|
|
55
|
+
draw(forceRedraw?: boolean): IChartPlugin;
|
|
34
56
|
handleHover(x: number, y: number): AbstractPlugin;
|
|
35
57
|
updateDataGroups(dataGroups: TDataGroup[]): {
|
|
36
58
|
dataGroups: TDataGroup[];
|
|
37
59
|
};
|
|
38
|
-
getDrawAreaRect(): TRect;
|
|
39
60
|
getName(): string;
|
|
40
61
|
private _showZeroLine;
|
|
62
|
+
private calcPlotRect;
|
|
41
63
|
private calcPointGap;
|
|
64
|
+
private indexToX;
|
|
65
|
+
private valueToY;
|
|
66
|
+
/**
|
|
67
|
+
* Empty values interrupt the line instead of being drawn as 0.
|
|
68
|
+
*/
|
|
69
|
+
private splitIntoSegments;
|
|
70
|
+
private drawSegment;
|
|
71
|
+
private createFillStyle;
|
|
72
|
+
/**
|
|
73
|
+
* Adds the line through the given points to the current path (the path
|
|
74
|
+
* has to be at the first point already). With `smooth` the points are
|
|
75
|
+
* connected by a monotone cubic curve (Fritsch-Carlson): it runs through
|
|
76
|
+
* every value and never overshoots, so no peak is drawn that was never
|
|
77
|
+
* measured.
|
|
78
|
+
*/
|
|
79
|
+
private tracePath;
|
|
80
|
+
private drawGrid;
|
|
81
|
+
private isGridEnabled;
|
|
82
|
+
/**
|
|
83
|
+
* Labels of the values along the x axis (e.g. the time of a measurement).
|
|
84
|
+
* Only as many as fit next to each other are drawn.
|
|
85
|
+
*/
|
|
86
|
+
private drawXLabels;
|
|
87
|
+
private drawYLabels;
|
|
88
|
+
private drawHover;
|
|
89
|
+
private drawTooltip;
|
|
90
|
+
/**
|
|
91
|
+
* Tells the other plugins of the chart (e.g. the legend) where the tooltip
|
|
92
|
+
* is drawn in this frame - `null` when there is none.
|
|
93
|
+
*/
|
|
94
|
+
private publishTooltipRect;
|
|
95
|
+
/**
|
|
96
|
+
* The index of the value next to the pointer, -1 if the pointer is not
|
|
97
|
+
* over the chart.
|
|
98
|
+
*/
|
|
99
|
+
private findHoverIndex;
|
|
100
|
+
private pointsAt;
|
|
101
|
+
private commonUnit;
|
|
102
|
+
private toScreenX;
|
|
103
|
+
private toScreenY;
|
|
104
|
+
private toBufferX;
|
|
42
105
|
}
|
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Library LegendsPlugin
|
|
3
3
|
* Created 30.09.24
|
|
4
|
-
* Last modified
|
|
4
|
+
* Last modified 29.09.26
|
|
5
5
|
*
|
|
6
6
|
* @author Christoph Ehlers
|
|
7
7
|
*/
|
|
8
8
|
import AbstractPlugin from "./AbstractPlugin";
|
|
9
|
+
import { IChartPlugin } from "../interface/IChartPlugin";
|
|
9
10
|
export declare enum ERangeType {
|
|
10
11
|
ZERO_BASED = "zero_based",
|
|
11
12
|
MIN_MAX = "min_max"
|
|
12
13
|
}
|
|
13
14
|
export default class LegendsPlugin extends AbstractPlugin {
|
|
14
15
|
static NAME: string;
|
|
16
|
+
private _legendRect;
|
|
15
17
|
constructor(props?: {
|
|
16
18
|
x?: number;
|
|
17
19
|
y?: number;
|
|
20
|
+
hideOnHover?: boolean;
|
|
21
|
+
showSingleGroup?: boolean;
|
|
22
|
+
[key: string]: any;
|
|
18
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* The groups the legend lists. A single group needs no legend - the
|
|
26
|
+
* tooltip and the surrounding page name it already.
|
|
27
|
+
*/
|
|
28
|
+
private getVisibleGroups;
|
|
19
29
|
drawBuffer(): void;
|
|
30
|
+
draw(forceRedraw?: boolean): IChartPlugin;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a tooltip published by another plugin (see
|
|
33
|
+
* DiagramLine.TOOLTIP_ENTITY_SOURCE) overlaps the legend in this frame.
|
|
34
|
+
*/
|
|
35
|
+
private isCoveredByTooltip;
|
|
20
36
|
getName(): string;
|
|
21
37
|
}
|
package/dist/type/TData.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cehlers88/chart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A library to create charts using JavaScript and Canvas-Element.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "webpack",
|
|
11
11
|
"watch": "webpack --watch",
|
|
12
|
-
"test": "jest"
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"prepublishOnly": "npm test && npm run build"
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"@types/jest": "^29.5.13",
|
|
35
36
|
"css-loader": "^7.1.2",
|
|
36
37
|
"jest": "^29.7.0",
|
|
38
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
37
39
|
"style-loader": "^4.0.0",
|
|
38
40
|
"ts-jest": "^29.2.5",
|
|
39
41
|
"ts-loader": "^9.5.1",
|