Skip to content

Commit e4fe25b

Browse files
committed
#RI-3558 - add extrapolation for memory analysis
1 parent 4084f26 commit e4fe25b

File tree

22 files changed

+1520
-234
lines changed

22 files changed

+1520
-234
lines changed

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ module.exports = {
55
testURL: 'http://localhost/',
66
runner: 'groups',
77
moduleNameMapper: {
8-
'\\.(jpg|jpeg|png|ico|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
8+
'\\.(jpg|jpeg|png|ico|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
99
'<rootDir>/redisinsight/__mocks__/fileMock.js',
10+
'\\.svg': '<rootDir>/redisinsight/__mocks__/svg.js',
1011
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
1112
'uiSrc/(.*)': '<rootDir>/redisinsight/ui/src/$1',
1213
'monaco-editor': '<rootDir>/redisinsight/__mocks__/monacoMock.js',

redisinsight/__mocks__/svg.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export default 'SvgrURL'
2+
export const ReactComponent = 'div'

redisinsight/ui/src/components/charts/donut-chart/DonutChart.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface IProps {
4040
renderLabel?: (data: ChartData) => string
4141
renderTooltip?: (data: ChartData) => React.ReactElement | string
4242
labelAs?: 'value' | 'percentage'
43+
hideLabelTitle?: boolean
4344
}
4445

4546
const ANIMATION_DURATION_MS = 100
@@ -56,6 +57,7 @@ const DonutChart = (props: IProps) => {
5657
labelAs = 'value',
5758
renderLabel,
5859
renderTooltip,
60+
hideLabelTitle = false
5961
} = props
6062

6163
const margin = config?.margin || 98
@@ -134,7 +136,7 @@ const DonutChart = (props: IProps) => {
134136
.select(svgRef.current)
135137
.attr('width', width)
136138
.attr('height', height)
137-
.attr('data-testid', `donut-${name}`)
139+
.attr('data-testid', `donut-svg-${name}`)
138140
.attr('class', cx(classNames?.chart))
139141
.append('g')
140142
.attr('transform', `translate(${width / 2},${height / 2})`)
@@ -160,7 +162,7 @@ const DonutChart = (props: IProps) => {
160162
.append('text')
161163
.attr('class', cx(styles.chartLabel, classNames?.arcLabel))
162164
.attr('transform', getLabelPosition)
163-
.text((d) => (isShowLabel(d) ? d.data.name : ''))
165+
.text((d) => (isShowLabel(d) && !hideLabelTitle ? `${d.data.name}: ` : ''))
164166
.attr('data-testid', (d) => `label-${d.data.name}-${d.data.value}`)
165167
.style('text-anchor', (d) => ((d.endAngle + d.startAngle) / 2 > Math.PI ? 'end' : 'start'))
166168
.on('mouseenter mousemove', onMouseEnterSlice)
@@ -175,12 +177,11 @@ const DonutChart = (props: IProps) => {
175177
return renderLabel(d.data)
176178
}
177179

178-
const separator = ': '
179180
if (labelAs === 'percentage') {
180-
return `${separator}${getPercentage(d.value, sum)}%`
181+
return `${getPercentage(d.value, sum)}%`
181182
}
182183

183-
return `${separator}${truncateNumberToRange(d.value)}`
184+
return truncateNumberToRange(d.value)
184185
})
185186
.attr('class', cx(styles.chartLabelValue, classNames?.arcLabelValue))
186187
}, [data])
@@ -190,7 +191,7 @@ const DonutChart = (props: IProps) => {
190191
}
191192

192193
return (
193-
<div className={styles.wrapper}>
194+
<div className={styles.wrapper} data-testid={`donut-${name}`}>
194195
<svg ref={svgRef} />
195196
<div
196197
className={cx(styles.tooltip, classNames?.tooltip)}

0 commit comments

Comments
 (0)