-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChart.jsx
More file actions
70 lines (64 loc) · 2.31 KB
/
Copy pathChart.jsx
File metadata and controls
70 lines (64 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { useState } from 'react';
import {widgets, widgetDict} from './Constants';
import EditModal from './EditModal';
import './Dashboards.css';
import DraftWidgetModal from './DraftWidgetModal';
const Chart = props => {
const WidgetRender = props.el.widgetType
? widgetDict[props.el.widgetType]
: widgets[0];
const [visible, setVisible] = useState(false);
return (
<span>
{
props.el.widgetType === "Text Box" ?
<DraftWidgetModal visible={visible}
setVisible={setVisible}
el={props.el}
onClose = {props.toggleDrag}
updateChart={props.updateChart}
/>
:
<EditModal visible={visible}
setVisible={setVisible}
el={props.el}
updateChart={props.updateChart}
onClose = {props.toggleDrag}
/>
}
<div onDoubleClick={() => {
props.toggleDrag();
setVisible(true);
}}
style={{height: '100%', width: '100%'}}
>
{props.el.widgetType !== "Text Box" &&
<div className="chart-title">
{props.el.chartTitle}
</div>
}
<div style={{width: '100%', height: props.el.widgetType !== "Text Box" && props.el.chartTitle
? 'calc(100% - 25px)' : '100%'
}}
>
<WidgetRender
{...props.el.dataProps} el={props.el} updateChart={props.updateChart}
/>
</div>
<div
className="remove"
style={{
position: "absolute",
right: "2px",
top: 0,
cursor: "pointer",
}}
onClick={() => props.onRemoveItem(props.el)}
>
x
</div>
</div>
</span>
)
}
export default Chart;