Skip to content

Commit

Permalink
Format frontend code (TransformerOptimus#782)
Browse files Browse the repository at this point in the history
* format code

* image file issue

* minor fixes

* agent create scroll bug fixed

* minor fixes

---------

Co-authored-by: NishantBorthakur <nist.16br@gmail.com>
  • Loading branch information
nborthy and NishantBorthakur authored Jul 17, 2023
1 parent 9741d44 commit 6b8c80d
Show file tree
Hide file tree
Showing 30 changed files with 1,715 additions and 1,525 deletions.
2 changes: 1 addition & 1 deletion gui/pages/Content/APM/Apm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

.apm_dashboard {
margin-top: 16px;
height: calc(100vh - 14vh);
height: calc(100vh - 16vh);
overflow-y: auto;
}
721 changes: 393 additions & 328 deletions gui/pages/Content/APM/ApmDashboard.js

Large diffs are not rendered by default.

123 changes: 61 additions & 62 deletions gui/pages/Content/APM/BarGraph.js
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;
Loading

0 comments on commit 6b8c80d

Please sign in to comment.