bubble-chart-js 1.0.0
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/.eslintrc.json +15 -0
- package/.gitattributes +2 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +17 -0
- package/README.md +109 -0
- package/bubble-chart-js-1.0.0.tgz +0 -0
- package/dist/bundle.js +186 -0
- package/dist/canvas.d.ts +4 -0
- package/dist/constants/physics.d.ts +10 -0
- package/dist/core/renderer.d.ts +2 -0
- package/dist/features/textWrapper.d.ts +1 -0
- package/dist/features/tooltip.d.ts +3 -0
- package/dist/main.d.ts +1 -0
- package/dist/models/internal/dataItemInfo.d.ts +7 -0
- package/dist/models/public/configuration.d.ts +15 -0
- package/dist/models/public/dataItem.d.ts +4 -0
- package/dist/services/chartService.d.ts +5 -0
- package/dist/services/renderService.d.ts +3 -0
- package/dist/utils/config.d.ts +12 -0
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/validation.d.ts +5 -0
- package/jest.config.js +5 -0
- package/package.json +35 -0
- package/src/canvas.ts +17 -0
- package/src/constants/physics.ts +10 -0
- package/src/core/renderer.ts +110 -0
- package/src/features/textWrapper.ts +168 -0
- package/src/features/tooltip.ts +69 -0
- package/src/main.ts +5 -0
- package/src/models/internal/dataItemInfo.ts +8 -0
- package/src/models/public/configuration.ts +16 -0
- package/src/models/public/dataItem.ts +4 -0
- package/src/services/chartService.ts +24 -0
- package/src/services/renderService.ts +262 -0
- package/src/utils/config.ts +33 -0
- package/src/utils/helper.ts +3 -0
- package/src/utils/validation.ts +18 -0
- package/tsconfig.json +15 -0
- package/webpack.config.js +28 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Configuration } from "../models/public/configuration";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default configuration object.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_CONFIG: Omit<Configuration, "canvasContainerId" | "data"> =
|
|
7
|
+
{
|
|
8
|
+
colorMap: {},
|
|
9
|
+
defaultBubbleColor: "#3498db",
|
|
10
|
+
fontColor: "#ffffff",
|
|
11
|
+
minRadius: 10,
|
|
12
|
+
maxLines: 3,
|
|
13
|
+
textWrap: true,
|
|
14
|
+
isResizeCanvasOnWindowSizeChange: true,
|
|
15
|
+
fontSize: 14,
|
|
16
|
+
fontFamily: "Arial",
|
|
17
|
+
showToolTip: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Merges user config with defaults, ensuring `canvasContainerId` and `data` are required.
|
|
22
|
+
*/
|
|
23
|
+
export function mergeConfig(
|
|
24
|
+
customConfig: {
|
|
25
|
+
canvasContainerId: string;
|
|
26
|
+
data: Configuration["data"];
|
|
27
|
+
} & Partial<Configuration>
|
|
28
|
+
): Configuration {
|
|
29
|
+
return {
|
|
30
|
+
...DEFAULT_CONFIG,
|
|
31
|
+
...customConfig,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Configuration } from "../models/public/configuration";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates configuration and ensures required properties exist.
|
|
5
|
+
*/
|
|
6
|
+
export function validateConfig(config: Configuration): boolean {
|
|
7
|
+
if (!config) {
|
|
8
|
+
console.error("Invalid config object");
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!Array.isArray(config.data) || config.data.length === 0) {
|
|
13
|
+
console.error("Invalid or empty data array");
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return true;
|
|
18
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: "./src/main.ts", // Entry point for your application
|
|
5
|
+
output: {
|
|
6
|
+
filename: "bundle.js", // Output bundle file
|
|
7
|
+
path: path.resolve(__dirname, "dist"), // Output directory
|
|
8
|
+
},
|
|
9
|
+
resolve: {
|
|
10
|
+
extensions: [".ts", ".js"], // Resolve TypeScript and JavaScript files
|
|
11
|
+
},
|
|
12
|
+
module: {
|
|
13
|
+
rules: [
|
|
14
|
+
{
|
|
15
|
+
test: /\.ts$/, // Apply the loader to TypeScript files
|
|
16
|
+
use: "ts-loader",
|
|
17
|
+
exclude: /node_modules/,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
devServer: {
|
|
22
|
+
static: {
|
|
23
|
+
directory: path.join(__dirname, "dist"), // Serve files from the dist directory
|
|
24
|
+
},
|
|
25
|
+
compress: true,
|
|
26
|
+
port: 9000, // Port for the dev server
|
|
27
|
+
},
|
|
28
|
+
};
|