feat: close chart
This commit is contained in:
parent
2d318f270a
commit
fabf001076
7
src/views/ChartViewer/ChartViewer.css
Normal file
7
src/views/ChartViewer/ChartViewer.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.chartLabel {
|
||||||
|
text-align: center;
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.saveChartAsImageButton {
|
||||||
|
}
|
@ -3,6 +3,7 @@ import FocusChart from '../../Models/Chart/FocusChart'
|
|||||||
import { Doughnut, Bar, Line, Pie, Polar, Radar, Scatter, Bubble } from 'react-chartjs-2'
|
import { Doughnut, Bar, Line, Pie, Polar, Radar, Scatter, Bubble } from 'react-chartjs-2'
|
||||||
import { Button } from 'semantic-ui-react'
|
import { Button } from 'semantic-ui-react'
|
||||||
import download from 'downloadjs'
|
import download from 'downloadjs'
|
||||||
|
import './ChartViewer.css'
|
||||||
|
|
||||||
class ChartViewer extends Component {
|
class ChartViewer extends Component {
|
||||||
constructor () {
|
constructor () {
|
||||||
@ -17,6 +18,11 @@ class ChartViewer extends Component {
|
|||||||
document.addEventListener('setSelectedChart', this.setFocusChart)
|
document.addEventListener('setSelectedChart', this.setFocusChart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeChart = () => {
|
||||||
|
this.focusChart.chart = null
|
||||||
|
this.setFocusChart()
|
||||||
|
}
|
||||||
|
|
||||||
handleGroupByChange = (e, value) => {
|
handleGroupByChange = (e, value) => {
|
||||||
this.setState({ reportValue: value.value })
|
this.setState({ reportValue: value.value })
|
||||||
}
|
}
|
||||||
@ -28,12 +34,10 @@ class ChartViewer extends Component {
|
|||||||
|
|
||||||
setFocusChart = () => {
|
setFocusChart = () => {
|
||||||
const focusChart = this.focusChart.chart
|
const focusChart = this.focusChart.chart
|
||||||
if (focusChart) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
chart: focusChart
|
chart: focusChart
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
renderChart = () => {
|
renderChart = () => {
|
||||||
const { chart } = this.state
|
const { chart } = this.state
|
||||||
@ -50,11 +54,14 @@ class ChartViewer extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render = () => {
|
render = () => {
|
||||||
|
const chart = this.state.chart || {}
|
||||||
return (
|
return (
|
||||||
<div className='ChartViewer'>
|
<div className='ChartViewer'>
|
||||||
|
<h3 className='chartLabel'>{ chart.label }</h3>
|
||||||
{this.renderChart()}
|
{this.renderChart()}
|
||||||
<br />
|
<br />
|
||||||
{ this.state.chart ? <Button fluid onClick={this.saveChart}>Save As Image</Button> : '' }
|
{ this.state.chart ? <Button className='saveChartAsImageButton' fluid primary onClick={this.saveChart}>Save As Image</Button> : '' }
|
||||||
|
{ this.state.chart ? <Button className='closeChartButton' fluid onClick={this.closeChart}>Close Chart</Button> : '' }
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user