I need to insert long text in the center of a radial bar so that it fits properly, for example with a line break. The text I want to change is in the example location placed as "text here..."
Angular is being used with the apexchart library installed in its environment.
I've already looked in the documentation for ways to change the label, but I couldn't find one that applies to a radial bar.
Project on stackblitz: go to project
Code: component.ts
public chartOptions: Partial<ChartOptions>;
hexChartColor = '#3076B5';
hexTrackColor = '#DAE7FD';
percentValue = 70;
textChart = `text here text here text here text`;
constructor() {
this.chartOptions = {
colors: [this.hexChartColor],
series: [this.percentValue],
chart: {
height: 400,
width: '100%',
type: 'radialBar',
background: '#f1f1f1'
},
plotOptions: {
radialBar: {
inverseOrder: false,
startAngle: 0,
endAngle: 360,
offsetX: 0, // Move chart sides
offsetY: 0, // Move chart top, bottom
hollow: {
margin: 5,
size: '60%',
background: 'transparent',
position: 'front'
},
track: {
show: true,
startAngle: undefined,
endAngle: undefined,
background: this.hexTrackColor,
strokeWidth: '97%',
opacity: 1,
margin: 5
},
dataLabels: {
show: true,
name: {
show: true,
fontSize: '14px',
fontFamily: undefined,
fontWeight: 600,
color: '#3076B5',
offsetY: 20
},
value: {
show: true,
fontSize: '44px',
fontFamily: undefined,
fontWeight: 600,
color: '#3076B5',
offsetY: -20,
formatter: function(val) {
return val + '%';
}
}
}
}
},
labels: ['text here text here text here text text here']
};
}
code component.html
<div id="chart">
<apx-chart
[series]="chartOptions.series"
[chart]="chartOptions.chart"
[plotOptions]="chartOptions.plotOptions"
[labels]="chartOptions.labels"
[colors]="chartOptions.colors">
</apx-chart>
</div>
