Skip to content

Commit eea7210

Browse files
committed
Fix #246
1 parent 3a55381 commit eea7210

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sample/src/main/java/com/github/aachartmodel/aainfographics/demo/chartcomposer/JSFunctionForAAOptionsComposer.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,30 @@ function () {
179179
return aaOptions
180180
}
181181

182+
//https://github.com/AAChartModel/AAChartCore-Kotlin/issues/246
183+
//自定义x坐标轴上标题的宽度
184+
fun customizeXAxisCategoriesLabelsWidth(): AAOptions {
185+
return AAOptions()
186+
.chart(AAChart().type(AAChartType.Column))
187+
.xAxis(AAXAxis()
188+
.categories(arrayOf("很长的标题1三国演义", "很长的标题2水浒传", "很长的标题3红楼梦", "很长的标题4西游记", "很长的标题5金瓶梅"))
189+
.labels(AALabels()
190+
.useHTML(true)
191+
.autoRotation(false)
192+
.formatter("""
193+
function() {
194+
return '<div style=\"width:50px; text-align:left; word-wrap:break-word; overflow-wrap:break-word; white-space:normal;\">' + this.value + '</div>';
195+
}
196+
""".trimIndent())
197+
198+
)
199+
)
200+
.series(arrayOf(
201+
AASeriesElement()
202+
.data(arrayOf(29.9, 71.5, 106.4, 129.2, 144.0))
203+
))
204+
}
205+
182206
//https://github.com/AAChartModel/AAChartKit-Swift/issues/404
183207
fun configureColorfulDataLabelsForPieChart(): AAOptions {
184208
return AAOptions()

0 commit comments

Comments
 (0)