Skip to content

Commit 38e4137

Browse files
committed
grafana update, working well
1 parent f6e23fc commit 38e4137

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/charts/GrafanaEventChart.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface EventChartProps {
1919
*/
2020
const GrafanaEventChart: React.FC<EventChartProps> = React.memo(props => {
2121
const { metricName } = props;
22+
const [graphType, setGraphType] = useState<string>("timeseries");
2223
// const [solo, setSolo] = useState<SoloStyles | null>(null);
2324
console.log("inside GrafanaEventChart")
2425

@@ -37,13 +38,17 @@ const GrafanaEventChart: React.FC<EventChartProps> = React.memo(props => {
3738
console.log("uid: ", uid)
3839
console.log("parsedName: ", parsedName)
3940

41+
const handleSelectionChange = (event) => {
42+
setGraphType(event.target.value);
43+
fetch('http://localhost:1111/random')
44+
}
45+
4046
return (
4147
<div className="chart" data-testid="Grafana Event Chart">
42-
<br />
4348
<h2>{parsedName}</h2>
44-
{/* create chart using grafana */}
49+
{/* create chart using grafana iframe tag*/}
4550
<iframe src={`http://localhost:32000/d-solo/${uid}/${parsedName}?orgId=1&refresh=10s&from=now-5m&to=now&panelId=1`} width="650" height="400" ></iframe>
46-
<select name="cars" id="cars">
51+
<select name="graphType" id="graphType" value={graphType} onChange={handleSelectionChange}>
4752
<option value="timeseries">Time Series</option>
4853
<option value="barchart">Bar Chart</option>
4954
<option value="stat">Stat</option>

chronos_npm_package/server/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ app.use(express.urlencoded());
1313

1414
app.get('/random', (req, res) => {
1515
console.log('random endpoint hit')
16+
console.log('number: ', Math.floor(Math.random() * Math.floor(100)))
1617
res.json({
1718
number: Math.floor(Math.random() * Math.floor(100))
1819
})

0 commit comments

Comments
 (0)