From 3b297136fb779fc20ee3e7689603d6cfd370bef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sun, 11 Apr 2021 12:55:15 +0500 Subject: [PATCH] fix chart line color --- src/components/charts/ChartSaubDataOnline.jsx | 21 ++++++++++++------- src/pages/Well.jsx | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/charts/ChartSaubDataOnline.jsx b/src/components/charts/ChartSaubDataOnline.jsx index 48c1949..e98884b 100644 --- a/src/components/charts/ChartSaubDataOnline.jsx +++ b/src/components/charts/ChartSaubDataOnline.jsx @@ -1,8 +1,9 @@ -import { Chart, TimeScale, Legend, LineController, LineElement, PointElement } from 'chart.js' -import 'chartjs-adapter-date-fns'; import React, { useEffect, useRef} from 'react'; -Chart.register( TimeScale, LineController, LineElement, PointElement, Legend ); +//import { Chart, TimeScale, Legend, LineController, LineElement, PointElement, LinearScale } from 'chart.js' +import Chart from 'chart.js/auto'; +import 'chartjs-adapter-date-fns'; +//Chart.register( TimeScale, LinearScale, LineController, LineElement, PointElement, Legend ); const options = { //showLine :true, @@ -27,6 +28,10 @@ const options = { }, }, }, + + x:{ + type:'linear' + } }, } @@ -37,8 +42,8 @@ const data= { {x: 10, y: '2021-04-09T17:50:34.021679+05:00'}, {x: 15, y: '2021-04-09T17:50:33.021679+05:00'}, {x: 20, y: '2021-04-09T17:50:32.021679+05:00'}], - boderColor: 'rgba(0, 99, 132, 1)', - backgroundColor: 'rgba(0, 99, 132, 1)', + backgroundColor: 'rgb(255, 99, 132)', + borderColor: 'rgb(255, 99, 132)', }, { label: 'Pressure', @@ -46,9 +51,9 @@ const data= { {x: 11, y: '2021-04-09T17:50:34.021679+05:00'}, {x: 14, y: '2021-04-09T17:50:33.021679+05:00'}, {x: 21, y: '2021-04-09T17:50:32.021679+05:00'}], - boderColor: 'rgba(255, 99, 132, 1)', - backgroundColor: 'rgba(255, 99, 132, 1)', - borderDash: [5, 5], + + borderColor: 'rgba(0, 99, 132, 0.5)', + } ] } diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx index 2b24161..1cff26a 100644 --- a/src/pages/Well.jsx +++ b/src/pages/Well.jsx @@ -10,7 +10,8 @@ export default function Well(props){ const [saubData, setSaubData] = useState([]) const handleReceiveDataSaub = (data)=>{ - setSaubData(pre => [...pre, ...data].slice(-1024)) + if(data) + setSaubData(pre => [...pre, ...data].slice(-1024)) } useEffect( ()=> {