-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into fix/key-auth
- Loading branch information
Showing
66 changed files
with
2,224 additions
and
1,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
|
||
.apm_dashboard { | ||
margin-top: 16px; | ||
height: calc(100vh - 14vh); | ||
height: calc(100vh - 16vh); | ||
overflow-y: auto; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,73 @@ | ||
import React, { useEffect, useRef } from "react"; | ||
import React, {useEffect, useRef} from "react"; | ||
import * as echarts from 'echarts'; | ||
import {formatNumber} from "@/utils/utils"; | ||
|
||
export const BarGraph = ({ data, type, color }) => { | ||
const chartRef = useRef(null); | ||
const containerRef = useRef(null); | ||
export const BarGraph = ({data, type, color}) => { | ||
const chartRef = useRef(null); | ||
const containerRef = useRef(null); | ||
|
||
useEffect(() => { | ||
const chartInstance = echarts.getInstanceByDom(chartRef.current); | ||
const chart = chartInstance ? chartInstance : echarts.init(chartRef.current); | ||
useEffect(() => { | ||
const chartInstance = echarts.getInstanceByDom(chartRef.current); | ||
const chart = chartInstance ? chartInstance : echarts.init(chartRef.current); | ||
|
||
const option = { | ||
color: color, | ||
tooltip: { | ||
trigger: 'axis', | ||
axisPointer: { | ||
type: 'shadow' | ||
} | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: data.map(item => item.name), | ||
axisLabel: { | ||
interval: 0, | ||
rotate: 45, | ||
color: '#888' | ||
} | ||
}, | ||
yAxis: { | ||
type: 'value', | ||
axisLabel: { | ||
formatter: function(value) { | ||
if (value >= 1000) { | ||
return `${value / 1000}k`; | ||
} else { | ||
return value; | ||
} | ||
} | ||
}, | ||
splitLine: { | ||
lineStyle: { | ||
color: 'rgba(255, 255, 255, 0.08)' | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: data.map(item => type === 'tokens_per_call' ? (item.tokens_consumed/item.calls) : item[type]), | ||
type: 'bar' | ||
}], | ||
responsive: true | ||
}; | ||
const option = { | ||
color: color, | ||
tooltip: { | ||
trigger: 'axis', | ||
axisPointer: { | ||
type: 'shadow' | ||
} | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: data.map(item => item.name), | ||
axisLabel: { | ||
interval: 0, | ||
rotate: 45, | ||
color: '#888' | ||
} | ||
}, | ||
yAxis: { | ||
type: 'value', | ||
axisLabel: { | ||
formatter: function (value) { | ||
if (value >= 1000) { | ||
return `${value / 1000}k`; | ||
} else { | ||
return value; | ||
} | ||
} | ||
}, | ||
splitLine: { | ||
lineStyle: { | ||
color: 'rgba(255, 255, 255, 0.08)' | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: data.map(item => type === 'tokens_per_call' ? (item.tokens_consumed / item.calls) : item[type]), | ||
type: 'bar' | ||
}], | ||
responsive: true | ||
}; | ||
|
||
chart.setOption(option); | ||
chart.setOption(option); | ||
|
||
const resizeObserver = new ResizeObserver(entries => { | ||
entries.forEach(entry => { | ||
chart.resize(); | ||
}); | ||
}); | ||
const resizeObserver = new ResizeObserver(entries => { | ||
entries.forEach(entry => { | ||
chart.resize(); | ||
}); | ||
}); | ||
|
||
resizeObserver.observe(containerRef.current); | ||
resizeObserver.observe(containerRef.current); | ||
|
||
return () => resizeObserver.disconnect(); | ||
}, [data, type]); | ||
return () => resizeObserver.disconnect(); | ||
}, [data, type]); | ||
|
||
return ( | ||
<div ref={containerRef} style={{ width: '100%', height: '100%' }}> | ||
<div ref={chartRef} style={{ width: '100%', height: '100%' }}></div> | ||
</div> | ||
); | ||
return ( | ||
<div ref={containerRef} style={{width: '100%', height: '100%'}}> | ||
<div ref={chartRef} style={{width: '100%', height: '100%'}}></div> | ||
</div> | ||
); | ||
} | ||
|
||
export default BarGraph; |
Oops, something went wrong.