chart tree shake

This commit is contained in:
Фролов 2021-04-11 15:29:53 +05:00
parent 3b297136fb
commit 34a73ec9b1
4 changed files with 43 additions and 8 deletions

29
package-lock.json generated
View File

@ -2441,11 +2441,28 @@
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.2.3.tgz", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.2.3.tgz",
"integrity": "sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA==" "integrity": "sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA=="
}, },
"@types/prop-types": {
"version": "15.7.3",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
"integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
"dev": true
},
"@types/q": { "@types/q": {
"version": "1.5.4", "version": "1.5.4",
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz",
"integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==" "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug=="
}, },
"@types/react": {
"version": "17.0.3",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.3.tgz",
"integrity": "sha512-wYOUxIgs2HZZ0ACNiIayItyluADNbONl7kt8lkLjVK8IitMH5QMyAh75Fwhmo37r1m7L2JaFj03sIfxBVDvRAg==",
"dev": true,
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"@types/resolve": { "@types/resolve": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz",
@ -2454,6 +2471,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/scheduler": {
"version": "0.16.1",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz",
"integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==",
"dev": true
},
"@types/source-list-map": { "@types/source-list-map": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
@ -5032,6 +5055,12 @@
} }
} }
}, },
"csstype": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.7.tgz",
"integrity": "sha512-KxnUB0ZMlnUWCsx2Z8MUsr6qV6ja1w9ArPErJaJaF8a5SOWoHLIszeCTKGRGRgtLgYrs1E8CHkNSP1VZTTPc9g==",
"dev": true
},
"cyclist": { "cyclist": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz",

View File

@ -49,6 +49,7 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^17.0.3",
"openapi-typescript": "^3.2.0", "openapi-typescript": "^3.2.0",
"openapi-typescript-codegen": "^0.9.3" "openapi-typescript-codegen": "^0.9.3"
} }

View File

@ -1,13 +1,13 @@
import React, { useEffect, useRef} from 'react'; import React, { useEffect, useRef} from 'react';
//import { Chart, TimeScale, Legend, LineController, LineElement, PointElement, LinearScale } from 'chart.js' import { Chart, TimeScale, LinearScale, Legend, LineController, PointElement, LineElement } from 'chart.js'
import Chart from 'chart.js/auto'; //import Chart from 'chart.js/auto';
import 'chartjs-adapter-date-fns'; import 'chartjs-adapter-date-fns';
//Chart.register( TimeScale, LinearScale, LineController, LineElement, PointElement, Legend ); Chart.register( TimeScale, LinearScale, LineController, LineElement, PointElement, Legend );
const options = { const options = {
//showLine :true, //showLine :true,
indexAxis:'y', //indexAxis:'y',
//maintainAspectRatio: false, //maintainAspectRatio: false,
//responsive:false, //responsive:false,
scales: { scales: {
@ -58,7 +58,12 @@ const data= {
] ]
} }
export function ChartSaubDataOnline(props){ // export type LineConfig = {
// login?: string | null;
// password?: string | null;
// }
export function ChartTime(/*props*/){
const chartRef = useRef(null) const chartRef = useRef(null)
useEffect(()=>{ useEffect(()=>{
@ -67,7 +72,7 @@ export function ChartSaubDataOnline(props){
data, data,
options}) options})
//chart.canvas.parentNode.style.height = '128px'; //chart.canvas.parentNode.style.height = '128px';
return _ => chart.destroy() return () => chart.destroy()
},[]) },[])
return(<canvas ref={chartRef} />) return(<canvas ref={chartRef} />)

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect} from 'react'; import React, { useState, useEffect} from 'react';
import {ChartSaubDataOnline} from '../components/charts/ChartSaubDataOnline' import {ChartTime} from '../components/charts/ChartTime'
import {useParams} from 'react-router-dom' import {useParams} from 'react-router-dom'
import {Subscribe} from '../services/signalr' import {Subscribe} from '../services/signalr'
@ -26,6 +26,6 @@ export default function Well(props){
return(<div> return(<div>
Well id: {id}; points count: {saubData.length} Well id: {id}; points count: {saubData.length}
<ChartSaubDataOnline/> <ChartTime/>
</div>) </div>)
} }