@@ -72,6 +72,7 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
72
72
protected isExpanded = false ;
73
73
protected legendData : Array < { name : string ; color : string } > = [ ] ;
74
74
protected headerHeight : number ;
75
+ protected positionTooltip = 'bottom' ;
75
76
protected popupActions : Array < PoPopupAction > = [
76
77
{
77
78
label : this . literals . exportCSV ,
@@ -94,6 +95,7 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
94
95
] ;
95
96
private chartInstance ! : echarts . ECharts ;
96
97
private currentRenderer : 'svg' | 'canvas' ;
98
+ private boundaryGap = false ;
97
99
98
100
constructor (
99
101
private el : ElementRef ,
@@ -201,13 +203,20 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
201
203
202
204
this . chartInstance . on ( 'mouseover' , ( params : any ) => {
203
205
if ( ! params . value ) return ;
204
- if ( params . seriesType === 'line' ) {
206
+ if ( params . seriesType ) {
205
207
const divTooltipElement = this . el . nativeElement . querySelector ( '#custom-tooltip' ) ;
206
208
if ( divTooltipElement ) {
207
209
const chartElement = this . el . nativeElement . querySelector ( '#chart-id' ) ;
210
+ if ( params . seriesType === 'bar' ) {
211
+ this . positionTooltip = 'top' ;
212
+ }
213
+ const customTooltipText = params . seriesName
214
+ ? `<b>${ params . name } </b><br>
215
+ ${ params . seriesName } : <b>${ params . value } </b>`
216
+ : `${ params . name } <b>${ params . value } </b>` ;
208
217
this . tooltipText = this . series [ params . seriesIndex ] . tooltip
209
218
? this . series [ params . seriesIndex ] . tooltip
210
- : ` ${ params . seriesName } : ${ params . value } ` ;
219
+ : customTooltipText ;
211
220
divTooltipElement . style . left = `${ params . event . offsetX + chartElement . offsetLeft + 3 } px` ;
212
221
divTooltipElement . style . top = `${ chartElement . offsetTop + params . event . offsetY + 3 } px` ;
213
222
this . poTooltip . toggleTooltipVisibility ( true ) ;
@@ -243,12 +252,12 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
243
252
grid : {
244
253
top : paddingTop ,
245
254
left : this . options ?. axis ?. paddingLeft || 48 ,
246
- right : 16 ,
255
+ right : this . options ?. axis ?. paddingRight || 32 ,
247
256
borderWidth : tokenBorderWidthSm
248
257
} ,
249
258
xAxis : {
250
259
type : 'category' ,
251
- boundaryGap : false ,
260
+ boundaryGap : this . boundaryGap ,
252
261
data : this . categories ,
253
262
axisLabel : {
254
263
fontFamily : this . getCSSVariable ( '--font-family-grid' , '.po-chart' ) ,
@@ -313,7 +322,7 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
313
322
realtime : true ,
314
323
bottom : 'calc(100%)' ,
315
324
height : 20 ,
316
- right : 16 ,
325
+ right : this . options ?. axis ?. paddingRight || 32 ,
317
326
xAxisIndex : [ 0 ]
318
327
} ,
319
328
{
@@ -387,11 +396,10 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
387
396
const hasArea = this . type === 'area' || this . series . some ( serie => serie . type === 'area' ) ;
388
397
const newSeries : Array < any > = [ ...this . colorService . getColors < PoChartSerie > ( this . series , true , hasArea ) ] ;
389
398
const tokenBorderWidthMd = this . resolvePx ( '--border-width-md' ) ;
399
+ const widthTypeColumn = this . resolvePx ( '--spacing-sm' , '.po-chart' ) ;
390
400
391
401
return newSeries . map ( ( serie , index ) => {
392
- if ( serie . label && typeof serie . label === 'string' ) {
393
- serie . name = serie . label ;
394
- }
402
+ serie . name = serie . label && typeof serie . label === 'string' ? serie . label : '' ;
395
403
396
404
if ( ! serie . type || serie . type === 'area' || serie . type === 'column' ) {
397
405
! serie . type ? this . setTypeSerie ( serie , this . type ) : this . setTypeSerie ( serie , serie . type ) ;
@@ -402,22 +410,25 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
402
410
: serie . color ;
403
411
404
412
this . setSerieEmphasis ( serie , colorVariable , tokenBorderWidthMd ) ;
413
+ this . setSerieTypeLine ( serie , tokenBorderWidthMd , colorVariable ) ;
405
414
this . setSerieTypeArea ( serie , index ) ;
415
+ this . setSerieTypeColumn ( serie , widthTypeColumn , colorVariable ) ;
406
416
407
- const isTypeLine = this . type === 'line' || serie . type === 'line' ;
408
- if ( isTypeLine ) {
409
- serie . symbolSize = 8 ;
410
- serie . symbol = 'circle' ;
411
- }
417
+ return serie ;
418
+ } ) ;
419
+ }
420
+
421
+ private setSerieTypeLine ( serie , tokenBorderWidthMd : number , color : string ) {
422
+ if ( serie . type === 'line' ) {
423
+ serie . symbolSize = 8 ;
424
+ serie . symbol = 'circle' ;
412
425
serie . itemStyle = {
413
- color :
414
- isTypeLine && ! this . options ?. fillPoints ? this . getCSSVariable ( '--color-neutral-light-00' ) : colorVariable ,
415
- borderColor : colorVariable ,
426
+ color : ! this . options ?. fillPoints ? this . getCSSVariable ( '--color-neutral-light-00' ) : color ,
427
+ borderColor : color ,
416
428
borderWidth : tokenBorderWidthMd
417
429
} ;
418
- serie . lineStyle = { color : colorVariable , width : tokenBorderWidthMd } ;
419
- return serie ;
420
- } ) ;
430
+ serie . lineStyle = { color : color , width : tokenBorderWidthMd } ;
431
+ }
421
432
}
422
433
423
434
private setSerieTypeArea ( serie , index : number ) {
@@ -434,6 +445,20 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
434
445
}
435
446
}
436
447
448
+ private setSerieTypeColumn ( serie , width : number , color : string ) {
449
+ if ( serie . isTypeColumn ) {
450
+ serie . barWidth = width ;
451
+ serie . itemStyle = {
452
+ borderRadius : this . resolvePx ( '--border-radius-bar' , '.po-chart' ) ,
453
+ color : color
454
+ } ;
455
+ serie . emphasis = {
456
+ focus : 'series'
457
+ } ;
458
+ this . boundaryGap = true ;
459
+ }
460
+ }
461
+
437
462
private setSerieEmphasis ( serie , color : string , tokenBorder : number ) {
438
463
serie . emphasis = {
439
464
itemStyle : {
@@ -469,6 +494,7 @@ export class PoChartNewComponent extends PoChartNewBaseComponent implements Afte
469
494
serie . type = 'bar' ;
470
495
break ;
471
496
case PoChartType . Column :
497
+ serie . isTypeColumn = true ;
472
498
serie . type = 'bar' ;
473
499
break ;
474
500
case PoChartType . Donut :
0 commit comments