如何在HighCharts中将动态文本内容设置为yAxis stackLabels?

时间:2018-03-24 09:09:30

标签: ios objective-c highcharts

我想动态设置yAxis stackLabels内容,如下面的链接所示。 良好,优秀,差,平均,低于平均

以下链接代码位于JavaScript,如何在Objective C中使用?

链接:Demo

yAxis.stackLabel在链接演示中没有qTotals的属性。

我想要一些像下面的图像或显示在上面给出的链接。

enter image description here

任何帮助将不胜感激。 在此先感谢。

1 个答案:

答案 0 :(得分:1)

这是解决方案。

如果我们想根据yAxis dataLabels total设置文字。

[HIStackLabels alloc]init];
yaxis.stackLabels.enabled = [[NSNumber alloc] initWithBool:true];
yaxis.stackLabels.formatter = [[HIFunction alloc] initWithFunction:@"function() { if(this.total > 9) return 'Good'; if(this.y == 30) return 'Average';}"];

如果我们要设置基于特定列的文本。

column1.dataLabels = [[HIDataLabels alloc]init];
column1.dataLabels.enabled = [NSNumber numberWithInteger:1];
column1.dataLabels.formatter = [[HIFunction alloc] initWithFunction:@"function() { if(this.y == 60) return 'Poor'; if(this.y == 30) return 'Average';}"];