From 55e9969a8c21c38a0d53efd9a786031e62144cc8 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Thu, 11 Nov 2021 16:18:18 +0700 Subject: [PATCH] Updated chartjs --- .npmignore | 15 +++++++++++++++ examples/line-chart-example/package.json | 10 +++++----- package.json | 12 ++++++------ src/ReactChartJs.tsx | 13 +++++++++---- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.npmignore b/.npmignore index aec90cc..36a8b63 100644 --- a/.npmignore +++ b/.npmignore @@ -8,3 +8,18 @@ # Lock File yarn.lock package.lock.json +examples +test +jest.config.js +yarn-error.log +.eslintrc.js +.prettierrc.js +.stylelintrc.js +.babelrc +.eslintignore +.prettierignore +.stylelintignore +.gitignore +.gitattributes +.editorconfig +.env \ No newline at end of file diff --git a/examples/line-chart-example/package.json b/examples/line-chart-example/package.json index f6b3000..7ff199e 100644 --- a/examples/line-chart-example/package.json +++ b/examples/line-chart-example/package.json @@ -3,16 +3,16 @@ "version": "0.1.0", "private": true, "dependencies": { - "@cubetiq/react-chart-js": "^1.0.0", + "@cubetiq/react-chart-js": "^1.1.6", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "@types/jest": "^24.0.0", "@types/node": "^12.0.0", - "@types/react": "^16.9.0", - "@types/react-dom": "^16.9.0", - "react": "^16.14.0", - "react-dom": "^16.14.0", + "@types/react": "^17.0.2", + "@types/react-dom": "^17.0.2", + "react": "^17.0.2", + "react-dom": "^17.0.2", "react-scripts": "3.4.3", "typescript": "~3.7.2" }, diff --git a/package.json b/package.json index 55df4ff..6017a97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cubetiq/react-chart-js", - "version": "1.1.5", + "version": "1.1.7", "description": "Chart.js for React and TypeScript", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -30,7 +30,7 @@ "scripts": { "build": "tsc", "test": "jest", - "pub": "npm publish --access public", + "pub": "yarn build && npm publish --access public", "build:test": "yarn jest && yarn build", "run:example": "cd examples/line-chart-example && yarn start" }, @@ -41,7 +41,7 @@ "@types/chart.js": "^2.9.25", "@types/jest": "^26.0.10", "@types/node": "^14.6.1", - "@types/react": "^16.9.52", + "@types/react": "^17.0.34", "@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/parser": "^3.10.1", "babel-jest": "^26.3.0", @@ -52,10 +52,10 @@ "jest": "^26.4.2", "lint-staged": "^10.2.13", "prettier": "^2.1.1", - "react": "^16.14.0", + "react": "^17.0.2", "ts-jest": "^26.3.0", "tsc": "^1.20150623.0", - "typescript": "^4.0.2" + "typescript": "^4.4.4" }, "husky": { "hooks": { @@ -71,6 +71,6 @@ ] }, "dependencies": { - "chart.js": "^2.9.3" + "chart.js": "^3.6.0" } } diff --git a/src/ReactChartJs.tsx b/src/ReactChartJs.tsx index 3ea6c80..1758eb5 100644 --- a/src/ReactChartJs.tsx +++ b/src/ReactChartJs.tsx @@ -3,6 +3,10 @@ import React, { FunctionComponent, useEffect, useRef } from 'react'; interface ReactChartJSProps { chartConfig?: ChartConfiguration; + width?: number; + height?: number; + containerProps: any; + canvasProps: any; } interface RefForChartInstance { @@ -10,7 +14,7 @@ interface RefForChartInstance { } const ReactChartJs: FunctionComponent = (props: any) => { - const { chartConfig } = props; + const { chartConfig, containerProps, canvasProps } = props; const canvasDomRef = useRef(); @@ -27,13 +31,14 @@ const ReactChartJs: FunctionComponent = (props: any) => { }, [chartConfig]); return ( -
+
{ canvasDomRef.current = instance!; }} - width="400" - height="200" + width={props.width || 'auto'} + height={props.height || 'auto'} + {...canvasProps} />
);