Skip to content

Commit 302351b

Browse files
committed
feat: charts css
1 parent 6cab5f2 commit 302351b

File tree

6 files changed

+66
-10
lines changed

6 files changed

+66
-10
lines changed

frontend/src/views/chat/RecommendQuestion.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ const props = withDefaults(
1010
currentChat?: ChatInfo
1111
questions?: string
1212
firstChat?: boolean
13+
disabled?: boolean
1314
}>(),
1415
{
1516
recordId: undefined,
1617
currentChat: () => new ChatInfo(),
1718
questions: '[]',
1819
firstChat: false,
20+
disabled: false,
1921
}
2022
)
2123
@@ -47,7 +49,9 @@ const computedQuestions = computed<string>(() => {
4749
const { t } = useI18n()
4850
4951
function clickQuestion(question: string): void {
50-
emits('clickQuestion', question)
52+
if (!props.disabled) {
53+
emits('clickQuestion', question)
54+
}
5155
}
5256
5357
const stopFlag = ref(false)

frontend/src/views/chat/component/BaseG2Chart.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export abstract class BaseG2Chart extends BaseChart {
99
this.chart = new Chart({
1010
container: id,
1111
autoFit: true,
12+
padding: 'auto',
1213
})
1314

1415
this.chart.theme({

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,23 @@ export class Bar extends BaseG2Chart {
3131
y: y[0].value,
3232
color: series.length > 0 ? series[0].value : undefined,
3333
},
34+
style: {
35+
radiusTopLeft: 4,
36+
radiusTopRight: 4,
37+
},
3438
axis: {
35-
x: { title: x[0].name },
39+
x: {
40+
title: x[0].name,
41+
labelFontSize: 12,
42+
labelAutoHide: {
43+
type: 'hide',
44+
keepHeader: true,
45+
keepTail: true,
46+
},
47+
labelAutoRotate: false,
48+
labelAutoWrap: true,
49+
labelAutoEllipsis: true,
50+
},
3651
y: { title: y[0].name },
3752
},
3853
scale: {
@@ -44,7 +59,8 @@ export class Bar extends BaseG2Chart {
4459
},
4560
},
4661
interaction: {
47-
elementHighlight: { background: true },
62+
elementHighlight: { background: true, region: true },
63+
tooltip: { series: series.length > 0, shared: true },
4864
},
4965
tooltip: (data) => {
5066
if (series.length > 0) {
@@ -60,8 +76,8 @@ export class Bar extends BaseG2Chart {
6076
{
6177
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
6278
transform: [
63-
{ type: 'overlapDodgeY' },
6479
{ type: 'contrastReverse' },
80+
{ type: 'exceedAdjust' },
6581
{ type: 'overlapHide' },
6682
],
6783
},

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,23 @@ export class Column extends BaseG2Chart {
3030
y: y[0].value,
3131
color: series.length > 0 ? series[0].value : undefined,
3232
},
33+
style: {
34+
radiusTopLeft: 4,
35+
radiusTopRight: 4,
36+
},
3337
axis: {
34-
x: { title: x[0].name },
38+
x: {
39+
title: x[0].name,
40+
labelFontSize: 12,
41+
labelAutoHide: {
42+
type: 'hide',
43+
keepHeader: true,
44+
keepTail: true,
45+
},
46+
labelAutoRotate: false,
47+
labelAutoWrap: true,
48+
labelAutoEllipsis: true,
49+
},
3550
y: { title: y[0].name },
3651
},
3752
scale: {
@@ -43,7 +58,8 @@ export class Column extends BaseG2Chart {
4358
},
4459
},
4560
interaction: {
46-
elementHighlight: { background: true },
61+
elementHighlight: { background: true, region: true },
62+
tooltip: { series: series.length > 0, shared: true },
4763
},
4864
tooltip: (data) => {
4965
if (series.length > 0) {
@@ -59,10 +75,9 @@ export class Column extends BaseG2Chart {
5975
{
6076
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
6177
position: 'top',
62-
dy: -25,
6378
transform: [
64-
{ type: 'overlapDodgeY' },
6579
{ type: 'contrastReverse' },
80+
{ type: 'exceedAdjust' },
6681
{ type: 'overlapHide' },
6782
],
6883
},

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@ export class Line extends BaseG2Chart {
3131
color: series.length > 0 ? series[0].value : undefined,
3232
},
3333
axis: {
34-
x: { title: x[0].name },
34+
x: {
35+
title: x[0].name,
36+
labelFontSize: 12,
37+
labelAutoHide: {
38+
type: 'hide',
39+
keepHeader: true,
40+
keepTail: true,
41+
},
42+
labelAutoRotate: false,
43+
labelAutoWrap: true,
44+
labelAutoEllipsis: true,
45+
},
3546
y: { title: y[0].name },
3647
},
3748
scale: {
@@ -42,9 +53,16 @@ export class Line extends BaseG2Chart {
4253
nice: true,
4354
},
4455
},
56+
interaction: {
57+
tooltip: { series: series.length > 0, shared: true },
58+
},
59+
4560
children: [
4661
{
4762
type: 'line',
63+
encode: {
64+
shape: 'smooth',
65+
},
4866
labels: [
4967
{
5068
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
@@ -53,7 +71,7 @@ export class Line extends BaseG2Chart {
5371
dy: -12,
5472
},
5573
transform: [
56-
{ type: 'overlapDodgeY' },
74+
{ type: 'contrastReverse' },
5775
{ type: 'exceedAdjust' },
5876
{ type: 'overlapHide' },
5977
],

frontend/src/views/chat/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
:current-chat="currentChat"
9898
:record-id="message.record?.id"
9999
:questions="message.recommended_question"
100+
:disabled="isTyping"
100101
:first-chat="message.first_chat"
101102
@click-question="quickAsk"
102103
@stop="onChatStop"
@@ -191,6 +192,7 @@
191192
:record-id="message.record?.id"
192193
:questions="message.recommended_question"
193194
:first-chat="message.first_chat"
195+
:disabled="isTyping"
194196
@click-question="quickAsk"
195197
@stop="onChatStop"
196198
/>

0 commit comments

Comments
 (0)