AAChartKit-Swift
AAChartKit-Swift copied to clipboard
i need to change the max value for each AASeriesElement in solidgaugeChart.
i need to change the max value of AAYAxis() for each AASeriesElement in solidgaugeChart. because i will use the chart as nested chart.
Could you share the visual design or layout of the chart?
I'm not sure if this is the effect you wanted:
/**
* In the chart render event, add icons on top of the circular shapes
*/
function renderIcons() {
this.series.forEach(series => {
if (!series.icon) {
series.icon = this.renderer
.text(
`<i class="fa fa-${series.options.custom.icon}"></i>`,
0,
0,
true
)
.attr({
zIndex: 10
})
.css({
color: series.options.custom.iconColor,
fontSize: '1.5em'
})
.add(this.series[2].group);
}
series.icon.attr({
x: this.chartWidth / 2 - 15,
y: this.plotHeight / 2 -
series.points[0].shapeArgs.innerR -
(
series.points[0].shapeArgs.r -
series.points[0].shapeArgs.innerR
) / 2 +
8
});
});
}
const trackColors = Highcharts.getOptions().colors.map(color =>
new Highcharts.Color(color).setOpacity(0.3).get()
);
Highcharts.chart('container', {
chart: {
type: 'solidgauge',
height: '110%',
events: {
render: renderIcons
}
},
title: {
text: 'Multiple KPI gauge',
style: {
fontSize: '24px'
}
},
tooltip: {
formatter: function() {
var point = this.point,
series = point.series,
yAxisMax = series.yAxis.options.max;
return `<span style="color:${point.color}">\u25CF</span> ${series.name}: <b>${point.y}</b><br/>Ratio to max: <b>${(point.y / yAxisMax).toFixed(2)}</b>`;
},
positioner: function (labelWidth) {
return {
x: (this.chart.chartWidth - labelWidth) / 2,
y: (this.chart.plotHeight / 2) + 15
};
}
},
pane: {
startAngle: 0,
endAngle: 360,
background: [{ // Track for Conversion
outerRadius: '112%',
innerRadius: '88%',
backgroundColor: trackColors[0],
borderWidth: 0
}, { // Track for Engagement
outerRadius: '87%',
innerRadius: '63%',
backgroundColor: trackColors[1],
borderWidth: 0
}, { // Track for Feedback
outerRadius: '62%',
innerRadius: '38%',
backgroundColor: trackColors[2],
borderWidth: 0
}]
},
yAxis: [{
min: 0,
max: 200,
lineWidth: 0,
tickPositions: [],
title: {
text: '第一组'
}
}, {
min: 0,
max: 300,
lineWidth: 0,
tickPositions: [],
title: {
text: '第二组'
},
opposite: true // 将第二个 yAxis 放在右侧
},
{
min: 0,
max: 400,
lineWidth: 0,
tickPositions: [],
title: {
text: '第三组'
},
opposite: true // 将第二个 yAxis 放在右侧
},
],
plotOptions: {
solidgauge: {
dataLabels: {
enabled: false
},
linecap: 'round',
stickyTracking: false,
rounded: true
}
},
series: [{
name: 'Conversion',
yAxis: 0, // 使用第一个 yAxis
data: [{
color: Highcharts.getOptions().colors[0],
radius: '112%',
innerRadius: '88%',
y: 100
}],
custom: {
icon: 'filter',
iconColor: '#303030'
}
}, {
name: 'Engagement',
yAxis: 1, // 使用第二个 yAxis
data: [{
color: Highcharts.getOptions().colors[1],
radius: '87%',
innerRadius: '63%',
y: 100
}],
custom: {
icon: 'comments-o',
iconColor: '#ffffff'
}
}, {
name: 'Feedback',
yAxis: 2, // 使用第二个 yAxis
data: [{
color: Highcharts.getOptions().colors[2],
radius: '62%',
innerRadius: '38%',
y: 100
}],
custom: {
icon: 'commenting-o',
iconColor: '#303030'
}
}]
});
you can copy this code into the online editor:
- https://jsfiddle.net/api/post/library/pure/
You will notice that while the y-values of each AASeriesElement are the same, the ratios relative to their corresponding y-axis maximum values differ, resulting in different proportions in the final chart.