Skip to content

Commit c35ece5

Browse files
committed
fix: fix pie chart display showing incorrect visual proportions
1 parent 9a42139 commit c35ece5

File tree

2 files changed

+19
-7
lines changed
  • frontend/src/views/chat/component/charts
  • g2-ssr/charts

2 files changed

+19
-7
lines changed

frontend/src/views/chat/component/charts/Pie.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,24 @@ export class Pie extends BaseG2Chart {
3030
y: y[0].value,
3131
color: series[0].value,
3232
},
33+
scale: {
34+
x: {
35+
nice: true,
36+
},
37+
y: {
38+
type: 'linear',
39+
},
40+
},
3341
legend: {
3442
color: { position: 'bottom', layout: { justifyContent: 'center' } },
3543
},
44+
animate: { enter: { type: 'waveIn' } },
3645
labels: [
3746
{
38-
position: 'outside',
47+
position: 'spider',
3948
text: (data: any) => {
4049
return `${data[series[0].value]}: ${data[y[0].value]}${_data.isPercent ? '%' : ''}`
4150
},
42-
transform: [{ type: 'exceedAdjust' }, { type: 'overlapHide' }],
4351
},
4452
],
4553
tooltip: {

g2-ssr/charts/pie.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ function getPieOptions(baseOptions, axis, data) {
2121
y: y[0].value,
2222
color: series[0].value,
2323
},
24+
scale: {
25+
x: {
26+
nice: true,
27+
},
28+
y: {
29+
type: 'linear',
30+
},
31+
},
2432
legend: {
2533
color: {position: 'bottom', layout: {justifyContent: 'center'}},
2634
},
2735
labels: [
2836
{
29-
position: 'outside',
37+
position: 'spider',
3038
text: (data) =>
3139
`${data[series[0].value]}: ${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
32-
transform: [
33-
{ type: 'exceedAdjust' },
34-
{ type: 'overlapHide' },
35-
],
3640
},
3741
],
3842
tooltip: {

0 commit comments

Comments
 (0)