Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Separate chart options from ChartPage component
Browse files Browse the repository at this point in the history
  • Loading branch information
miftahafina committed Mar 23, 2020
1 parent a7486ec commit b69b5ed
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
55 changes: 55 additions & 0 deletions src/Config/ChartOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const ChartOptions = {
responsive: true,
maintainAspectRatio: false,
legend:{
position: 'top',
labels:{
fontColor: "white",
}
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
// display: true,
// labelString: 'Tanggal update',
},
ticks: {
fontSize: 10,
autoSkip: true,
maxTicksLimit: 10
},
gridLines: {
display: false,
color: '#182025'
}
}],
yAxes: [{
ticks: {
fontSize: 10,
autoSkip: true,
maxTicksLimit: 7
},
gridLines: {
display: true,
color: '#182025',
height: 200
}
}]
},
elements: {
point:{
radius: 0
}
}
}

export default ChartOptions;
3 changes: 1 addition & 2 deletions src/Containers/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,5 @@ p > a:hover {
}

canvas {
/* width:1000px !important; */
height:225px !important;
height:210px !important;
}
60 changes: 3 additions & 57 deletions src/Containers/ChartPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { Line } from 'react-chartjs-2';

import ChartOptions from '../Config/ChartOptions';

const ChartPage = () => {
const [dailyReport, setDailyReport] = useState([]);
const [sortedDailyReport, setSortedDailyReport] = useState([]);
Expand Down Expand Up @@ -105,62 +107,6 @@ const ChartPage = () => {
));
}, [dateRange]);

const getChartOptions = () => {
return {
responsive: true,
maintainAspectRatio: false,
legend:{
position: 'top',
labels:{
fontColor: "white",
}
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
// display: true,
labelString: 'Tanggal update',
},
ticks: {
fontSize: 10,
autoSkip: true,
maxTicksLimit: 10
},
gridLines: {
display: false,
color: '#182025'
}
}],
yAxes: [{
ticks: {
fontSize: 10,
autoSkip: true,
maxTicksLimit: 7
},
gridLines: {
display: true,
color: '#182025',
height: 200
}
}]
},
elements: {
point:{
radius: 0
}
}
}
}

const getChartData = () => {
return {
labels: chartLabel,
Expand Down Expand Up @@ -198,7 +144,7 @@ const ChartPage = () => {
</h2>

<div className="card-chart">
<Line data={getChartData()} options={getChartOptions()}/>
<Line data={getChartData()} options={ChartOptions}/>
</div>

<div className="footer">
Expand Down

0 comments on commit b69b5ed

Please sign in to comment.