Skip to content

Commit cb37679

Browse files
committed
working radial graph no data
1 parent 341dc0a commit cb37679

File tree

3 files changed

+130
-26
lines changed

3 files changed

+130
-26
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"@visx/zoom": "^1.0.0",
140140
"acorn": "^7.3.1",
141141
"acorn-jsx": "^5.2.0",
142+
"apexcharts": "^3.23.1",
142143
"cookie": "^0.4.1",
143144
"d3": "^5.16.0",
144145
"d3-scale-chromatic": "^2.0.0",
@@ -154,6 +155,7 @@
154155
"rc-slider": "^8.7.1",
155156
"rc-tooltip": "^3.7.3",
156157
"react": "^16.13.1",
158+
"react-apexcharts": "^1.3.7",
157159
"react-dom": "^16.13.1",
158160
"react-html-parser": "^2.0.2",
159161
"react-json-tree": "^0.11.2",

src/app/components/StateRoute.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Legend from './AtomsRelationshipLegend';
2222
import AtomsRelationship from './AtomsRelationship';
2323
import WebMetrics from './WebMetrics';
2424

25+
2526
const History = require('./History').default;
2627
const ErrorHandler = require('./ErrorHandler').default;
2728

@@ -117,7 +118,11 @@ const StateRoute = (props: StateRouteProps) => {
117118

118119
};
119120
const renderWebMetrics = () => {
120-
return <WebMetrics webMetrics={webMetrics}/>;
121+
return (
122+
<div>
123+
<WebMetrics webMetrics={webMetrics}/>
124+
</div>
125+
)
121126
};
122127

123128
const renderPerfView = () => {

src/app/components/WebMetrics.tsx

Lines changed: 122 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
import React, { useState } from 'react';
2-
import { JSCharting } from 'jscharting-react';
3-
4-
const config = {
5-
type: 'horizontal column',
6-
series: [
7-
{
8-
points: [
9-
{ x: 'A', y: 50 },
10-
{ x: 'B', y: 30 },
11-
{ x: 'C', y: 50 }
12-
]
13-
}
14-
]
15-
};
16-
17-
const divStyle = {
18-
maxWidth: '700px',
19-
height: '400px',
20-
margin: '0px auto'
21-
};
1+
import React, { Component } from 'react';
2+
import Charts from 'react-apexcharts'
3+
4+
5+
interface apexcharts {
6+
state: any
7+
}
228

239
// const WebMetrics = ({webMetrics}) => {
2410
// const [data, setData] = React.useState({});
@@ -35,13 +21,124 @@ const divStyle = {
3521
// const output = [];
3622
// const perfMetrics = Object.keys(webMetrics)
3723
// .map((metric) => output.push(<div><div>{metric}</div><div>{Math.round(webMetrics[metric])}</div></div>));
38-
3924

25+
// console.log('WM >>>', webMetrics)
26+
// console.log('output>>>', output)
27+
// return (
28+
// <div>
29+
// {output}
30+
// </div>
31+
// )
32+
33+
// }
34+
35+
36+
class WebMetrics extends React.Component {
37+
constructor(props) {
38+
super(props);
39+
40+
this.state = {
41+
42+
series: [75],
43+
options: {
44+
chart: {
45+
height: 350,
46+
type: 'radialBar',
47+
toolbar: {
48+
show: true
49+
}
50+
},
51+
plotOptions: {
52+
radialBar: {
53+
startAngle: -135,
54+
endAngle: 225,
55+
hollow: {
56+
margin: 0,
57+
size: '70%',
58+
background: '#fff',
59+
image: undefined,
60+
imageOffsetX: 0,
61+
imageOffsetY: 0,
62+
position: 'front',
63+
dropShadow: {
64+
enabled: true,
65+
top: 3,
66+
left: 0,
67+
blur: 4,
68+
opacity: 0.24
69+
}
70+
},
71+
track: {
72+
background: '#fff',
73+
strokeWidth: '67%',
74+
margin: 0, // margin is in pixels
75+
dropShadow: {
76+
enabled: true,
77+
top: -3,
78+
left: 0,
79+
blur: 4,
80+
opacity: 0.35
81+
}
82+
},
83+
84+
dataLabels: {
85+
show: true,
86+
name: {
87+
offsetY: -10,
88+
show: true,
89+
color: '#888',
90+
fontSize: '17px'
91+
},
92+
value: {
93+
formatter: function(val) {
94+
return parseInt(val);
95+
},
96+
color: '#111',
97+
fontSize: '36px',
98+
show: true,
99+
}
100+
}
101+
}
102+
},
103+
fill: {
104+
type: 'gradient',
105+
gradient: {
106+
shade: 'dark',
107+
type: 'horizontal',
108+
shadeIntensity: 0.5,
109+
gradientToColors: ['#ABE5A1'],
110+
inverseColors: true,
111+
opacityFrom: 1,
112+
opacityTo: 1,
113+
stops: [0, 100]
114+
}
115+
},
116+
stroke: {
117+
lineCap: 'round'
118+
},
119+
labels: ['Percent'],
120+
},
121+
122+
123+
};
124+
const { webMetrics} = props;
125+
console.log('props', props, webMetrics)
126+
}
127+
128+
129+
130+
render() {
131+
return (
132+
40133

134+
<div id="card">
135+
<div id="chart">
136+
<Charts options={this.state.options} series={this.state.series} type="radialBar" height={350} />
137+
</div>
138+
</div>
41139

42-
return (
43-
<div id="chartDiv" style="width: 100%; height: 400px;"></div>
44-
)
140+
)
141+
}
45142
}
46143

47144
export default WebMetrics;

0 commit comments

Comments
 (0)