|
@@ -42,41 +42,41 @@ object AAOptionsConstructor {
|
|
aaChartModel:AAChartModel
|
|
aaChartModel:AAChartModel
|
|
):AAOptions {
|
|
):AAOptions {
|
|
val aaChart = AAChart()
|
|
val aaChart = AAChart()
|
|
- .type(aaChartModel.chartType)//绘图类型
|
|
|
|
- .inverted(aaChartModel.inverted)//设置是否反转坐标轴,使X轴垂直,Y轴水平。 如果值为 true,则 x 轴默认是 倒置 的。 如果图表中出现条形图系列,则会自动反转
|
|
|
|
- .backgroundColor(aaChartModel.backgroundColor)//设置图表的背景色(包含透明度的设置)
|
|
|
|
- .pinchType(aaChartModel.zoomType)//设置手势缩放方向
|
|
|
|
- .panning(true)//设置手势缩放后是否可平移
|
|
|
|
- .polar(aaChartModel.polar)//是否极化图表(开启极坐标模式)
|
|
|
|
- .marginLeft(aaChartModel.marginLeft)//图表左边距
|
|
|
|
- .marginRight(aaChartModel.marginRight)//图表右边距
|
|
|
|
|
|
+ .type(aaChartModel.chartType) //绘图类型
|
|
|
|
+ .inverted(aaChartModel.inverted) //设置是否反转坐标轴,使X轴垂直,Y轴水平。 如果值为 true,则 x 轴默认是 倒置 的。 如果图表中出现条形图系列,则会自动反转
|
|
|
|
+ .backgroundColor(aaChartModel.backgroundColor) //设置图表的背景色(包含透明度的设置)
|
|
|
|
+ .pinchType(aaChartModel.zoomType) //设置手势缩放方向
|
|
|
|
+ .panning(true) //设置手势缩放后是否可平移
|
|
|
|
+ .polar(aaChartModel.polar) //是否极化图表(开启极坐标模式)
|
|
|
|
+ .marginLeft(aaChartModel.marginLeft) //图表左边距
|
|
|
|
+ .marginRight(aaChartModel.marginRight) //图表右边距
|
|
|
|
|
|
val aaTitle = AATitle()
|
|
val aaTitle = AATitle()
|
|
- .text(aaChartModel.title)//标题文本内容
|
|
|
|
|
|
+ .text(aaChartModel.title) //标题文本内容
|
|
.style(AAStyle()
|
|
.style(AAStyle()
|
|
- .color(aaChartModel.titleFontColor)//Title font color
|
|
|
|
- .fontSize(aaChartModel.titleFontSize)//Title font size
|
|
|
|
- .fontWeight(aaChartModel.titleFontWeight)//Title font weight
|
|
|
|
|
|
+ .color(aaChartModel.titleFontColor) //Title font color
|
|
|
|
+ .fontSize(aaChartModel.titleFontSize) //Title font size
|
|
|
|
+ .fontWeight(aaChartModel.titleFontWeight) //Title font weight
|
|
)
|
|
)
|
|
|
|
|
|
val aaSubtitle = AASubtitle()
|
|
val aaSubtitle = AASubtitle()
|
|
- .text(aaChartModel.subtitle)//副标题内容
|
|
|
|
- .align(aaChartModel.subtitleAlign)//图表副标题文本水平对齐方式。可选的值有 “left”,”center“和“right”。 默认是:center.
|
|
|
|
|
|
+ .text(aaChartModel.subtitle) //副标题内容
|
|
|
|
+ .align(aaChartModel.subtitleAlign) //图表副标题文本水平对齐方式。可选的值有 “left”,”center“和“right”。 默认是:center.
|
|
.style(AAStyle()
|
|
.style(AAStyle()
|
|
- .color(aaChartModel.subtitleFontColor)//Subtitle font color
|
|
|
|
- .fontSize(aaChartModel.subtitleFontSize)//Subtitle font size
|
|
|
|
- .fontWeight(aaChartModel.subtitleFontWeight)//Subtitle font weight
|
|
|
|
|
|
+ .color(aaChartModel.subtitleFontColor) //Subtitle font color
|
|
|
|
+ .fontSize(aaChartModel.subtitleFontSize) //Subtitle font size
|
|
|
|
+ .fontWeight(aaChartModel.subtitleFontWeight) //Subtitle font weight
|
|
)
|
|
)
|
|
|
|
|
|
val aaTooltip = AATooltip()
|
|
val aaTooltip = AATooltip()
|
|
- .enabled(aaChartModel.tooltipEnabled)//启用浮动提示框
|
|
|
|
- .shared(true)//多组数据共享一个浮动提示框
|
|
|
|
- .crosshairs(true)//启用准星线
|
|
|
|
- .valueSuffix(aaChartModel.tooltipValueSuffix)//浮动提示框的单位名称后缀
|
|
|
|
|
|
+ .enabled(aaChartModel.tooltipEnabled) //启用浮动提示框
|
|
|
|
+ .shared(true) //多组数据共享一个浮动提示框
|
|
|
|
+ .crosshairs(true) //启用准星线
|
|
|
|
+ .valueSuffix(aaChartModel.tooltipValueSuffix) //浮动提示框的单位名称后缀
|
|
|
|
|
|
val aaPlotOptions = AAPlotOptions()
|
|
val aaPlotOptions = AAPlotOptions()
|
|
.series(AASeries()
|
|
.series(AASeries()
|
|
- .stacking(aaChartModel.stacking)//设置是否百分比堆叠显示图形
|
|
|
|
|
|
+ .stacking(aaChartModel.stacking) //设置是否百分比堆叠显示图形
|
|
)
|
|
)
|
|
|
|
|
|
if (aaChartModel.animationType != AAChartAnimationType.Linear.value) {
|
|
if (aaChartModel.animationType != AAChartAnimationType.Linear.value) {
|
|
@@ -91,7 +91,11 @@ object AAOptionsConstructor {
|
|
configureAAPlotOptionsDataLabels(aaPlotOptions, aaChartModel)
|
|
configureAAPlotOptionsDataLabels(aaPlotOptions, aaChartModel)
|
|
|
|
|
|
val aaLegend = AALegend()
|
|
val aaLegend = AALegend()
|
|
- .enabled(aaChartModel.legendEnabled)//是否显示 legend
|
|
|
|
|
|
+ .enabled(aaChartModel.legendEnabled) //是否显示 legend
|
|
|
|
+ .itemStyle(
|
|
|
|
+ AAItemStyle()
|
|
|
|
+ .color(aaChartModel.axesTextColor)
|
|
|
|
+ )
|
|
|
|
|
|
val aaOptions = AAOptions()
|
|
val aaOptions = AAOptions()
|
|
.chart(aaChart)
|
|
.chart(aaChart)
|
|
@@ -101,17 +105,18 @@ object AAOptionsConstructor {
|
|
.plotOptions(aaPlotOptions)
|
|
.plotOptions(aaPlotOptions)
|
|
.legend(aaLegend)
|
|
.legend(aaLegend)
|
|
.series(aaChartModel.series)
|
|
.series(aaChartModel.series)
|
|
- .colors(aaChartModel.colorsTheme)//设置颜色主题
|
|
|
|
- .touchEventEnabled(aaChartModel.touchEventEnabled)//是否支持点击事件
|
|
|
|
|
|
+ .colors(aaChartModel.colorsTheme) //设置颜色主题
|
|
|
|
+ .touchEventEnabled(aaChartModel.touchEventEnabled) //是否支持点击事件
|
|
|
|
|
|
configureAxisContentAndStyle(aaOptions, aaChartModel)
|
|
configureAxisContentAndStyle(aaOptions, aaChartModel)
|
|
|
|
|
|
return aaOptions
|
|
return aaOptions
|
|
}
|
|
}
|
|
|
|
|
|
- private fun configureAAPlotOptionsMarkerStyle(aaChartModel: AAChartModel,
|
|
|
|
- aaPlotOptions: AAPlotOptions
|
|
|
|
- ): AAPlotOptions {
|
|
|
|
|
|
+ private fun configureAAPlotOptionsMarkerStyle(
|
|
|
|
+ aaChartModel: AAChartModel,
|
|
|
|
+ aaPlotOptions: AAPlotOptions
|
|
|
|
+ ) {
|
|
val chartType = aaChartModel.chartType
|
|
val chartType = aaChartModel.chartType
|
|
//数据点标记相关配置,只有线性图(折线图、曲线图、折线区域填充图、曲线区域填充图,散点图)才有数据点标记
|
|
//数据点标记相关配置,只有线性图(折线图、曲线图、折线区域填充图、曲线区域填充图,散点图)才有数据点标记
|
|
if (chartType == AAChartType.Area.value
|
|
if (chartType == AAChartType.Area.value
|
|
@@ -120,12 +125,12 @@ object AAOptionsConstructor {
|
|
|| chartType == AAChartType.Spline.value
|
|
|| chartType == AAChartType.Spline.value
|
|
|| chartType == AAChartType.Scatter.value) {
|
|
|| chartType == AAChartType.Scatter.value) {
|
|
val aaMarker = AAMarker()
|
|
val aaMarker = AAMarker()
|
|
- .radius(aaChartModel.markerRadius)//曲线连接点半径,默认是4
|
|
|
|
- .symbol(aaChartModel.markerSymbol)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
|
|
|
|
|
+ .radius(aaChartModel.markerRadius) //曲线连接点半径,默认是4
|
|
|
|
+ .symbol(aaChartModel.markerSymbol) //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
|
if (aaChartModel.markerSymbolStyle == AAChartSymbolStyleType.InnerBlank.value) {
|
|
if (aaChartModel.markerSymbolStyle == AAChartSymbolStyleType.InnerBlank.value) {
|
|
- aaMarker.fillColor("#ffffff")//点的填充色(用来设置折线连接点的填充色)
|
|
|
|
- .lineWidth(2f)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
|
|
|
|
- .lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
|
|
|
|
|
|
+ aaMarker.fillColor("#ffffff") //点的填充色(用来设置折线连接点的填充色)
|
|
|
|
+ .lineWidth(2f) //外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
|
|
|
|
+ .lineColor("") //外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
|
|
} else if (aaChartModel.markerSymbolStyle == AAChartSymbolStyleType.BorderBlank.value) {
|
|
} else if (aaChartModel.markerSymbolStyle == AAChartSymbolStyleType.BorderBlank.value) {
|
|
aaMarker.lineWidth(2f)
|
|
aaMarker.lineWidth(2f)
|
|
.lineColor(aaChartModel.backgroundColor)
|
|
.lineColor(aaChartModel.backgroundColor)
|
|
@@ -133,15 +138,13 @@ object AAOptionsConstructor {
|
|
val aaSeries = aaPlotOptions.series
|
|
val aaSeries = aaPlotOptions.series
|
|
aaSeries?.marker(aaMarker)
|
|
aaSeries?.marker(aaMarker)
|
|
}
|
|
}
|
|
- return aaPlotOptions
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun configureAAPlotOptionsDataLabels(
|
|
private fun configureAAPlotOptionsDataLabels(
|
|
aaPlotOptions: AAPlotOptions,
|
|
aaPlotOptions: AAPlotOptions,
|
|
aaChartModel: AAChartModel
|
|
aaChartModel: AAChartModel
|
|
- ): AAPlotOptions {
|
|
|
|
-
|
|
|
|
|
|
+ ) {
|
|
val chartType = aaChartModel.chartType
|
|
val chartType = aaChartModel.chartType
|
|
|
|
|
|
var aaDataLabels = AADataLabels()
|
|
var aaDataLabels = AADataLabels()
|
|
@@ -194,8 +197,8 @@ object AAOptionsConstructor {
|
|
}
|
|
}
|
|
AAChartType.Columnrange.value -> {
|
|
AAChartType.Columnrange.value -> {
|
|
val aaColumnrange = AAColumnrange()
|
|
val aaColumnrange = AAColumnrange()
|
|
- .borderRadius(0f)//The color of the border surrounding each column or bar
|
|
|
|
- .borderWidth(0f)//The corner radius of the border surrounding each column or bar. default:0
|
|
|
|
|
|
+ .borderRadius(0f) //The color of the border surrounding each column or bar
|
|
|
|
+ .borderWidth(0f) //The corner radius of the border surrounding each column or bar. default:0
|
|
.dataLabels(aaDataLabels)
|
|
.dataLabels(aaDataLabels)
|
|
aaPlotOptions.columnrange(aaColumnrange)
|
|
aaPlotOptions.columnrange(aaColumnrange)
|
|
}
|
|
}
|
|
@@ -205,42 +208,64 @@ object AAOptionsConstructor {
|
|
aaPlotOptions.arearange(aaArearange)
|
|
aaPlotOptions.arearange(aaArearange)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return aaPlotOptions
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private fun configureAxisContentAndStyle(aaOptions: AAOptions,
|
|
|
|
- aaChartModel: AAChartModel) {
|
|
|
|
- if (aaChartModel.chartType != AAChartType.Pie.value
|
|
|
|
- && aaChartModel.chartType != AAChartType.Pyramid.value
|
|
|
|
- && aaChartModel.chartType != AAChartType.Funnel.value) {
|
|
|
|
- val aaXAxis = AAXAxis()
|
|
|
|
- .labels(AALabels()
|
|
|
|
- .enabled(aaChartModel.xAxisLabelsEnabled)//设置 x 轴是否显示文字
|
|
|
|
|
|
+ private fun configureAxisContentAndStyle(
|
|
|
|
+ aaOptions: AAOptions,
|
|
|
|
+ aaChartModel: AAChartModel
|
|
|
|
+ ) {
|
|
|
|
+ val chartType = aaChartModel.chartType
|
|
|
|
+ //x 轴和 Y 轴的相关配置,扇形图、金字塔图和漏斗图则不需要设置 X 轴和 Y 轴的相关内容
|
|
|
|
+ if ( chartType != AAChartType.Pie.value
|
|
|
|
+ && chartType != AAChartType.Pyramid.value
|
|
|
|
+ && chartType != AAChartType.Funnel.value) {
|
|
|
|
+ val aaXAxisLabelsEnabled = aaChartModel.xAxisLabelsEnabled
|
|
|
|
+ val aaXAxisLabels = AALabels()
|
|
|
|
+ .enabled(aaXAxisLabelsEnabled) //设置 x 轴是否显示文字
|
|
|
|
+ if (aaXAxisLabelsEnabled!!) {
|
|
|
|
+ aaXAxisLabels.style(
|
|
|
|
+ AAStyle()
|
|
|
|
+ .color(aaChartModel.axesTextColor)
|
|
)
|
|
)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val aaXAxis = AAXAxis()
|
|
|
|
+ .labels(aaXAxisLabels) //设置 x 轴是否显示文字
|
|
.reversed(aaChartModel.xAxisReversed)
|
|
.reversed(aaChartModel.xAxisReversed)
|
|
- .gridLineWidth(aaChartModel.xAxisGridLineWidth)//x轴网格线宽度
|
|
|
|
|
|
+ .gridLineWidth(aaChartModel.xAxisGridLineWidth) //x轴网格线宽度
|
|
.categories(aaChartModel.categories)
|
|
.categories(aaChartModel.categories)
|
|
- .visible(aaChartModel.xAxisVisible)//x轴是否可见
|
|
|
|
|
|
+ .visible(aaChartModel.xAxisVisible) //x轴是否可见
|
|
.tickInterval(aaChartModel.xAxisTickInterval) //x轴坐标点间隔数
|
|
.tickInterval(aaChartModel.xAxisTickInterval) //x轴坐标点间隔数
|
|
|
|
|
|
|
|
+ val aaYAxisLabelsEnabled = aaChartModel.yAxisLabelsEnabled
|
|
|
|
+ val aaYAxisLabels = AALabels()
|
|
|
|
+ .enabled(aaChartModel.yAxisLabelsEnabled)
|
|
|
|
+ if (aaYAxisLabelsEnabled!!) {
|
|
|
|
+ aaYAxisLabels.style(
|
|
|
|
+ AAStyle()
|
|
|
|
+ .color(aaChartModel.axesTextColor)
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
|
|
val aaYAxis = AAYAxis()
|
|
val aaYAxis = AAYAxis()
|
|
- .labels(AALabels()
|
|
|
|
- .enabled(aaChartModel.yAxisLabelsEnabled)
|
|
|
|
- )//设置 y 轴是否显示数字
|
|
|
|
- .min(aaChartModel.yAxisMin)//设置 y 轴最小值,最小值等于零就不能显示负值了
|
|
|
|
- .max(aaChartModel.yAxisMax)//y轴最大值
|
|
|
|
- .allowDecimals(aaChartModel.yAxisAllowDecimals)//是否允许显示小数
|
|
|
|
|
|
+ .labels(aaYAxisLabels) //设置 y 轴是否显示数字
|
|
|
|
+ .min(aaChartModel.yAxisMin) //设置 y 轴最小值,最小值等于零就不能显示负值了
|
|
|
|
+ .max(aaChartModel.yAxisMax) //y轴最大值
|
|
|
|
+ .allowDecimals(aaChartModel.yAxisAllowDecimals) //是否允许显示小数
|
|
.reversed(aaChartModel.yAxisReversed)
|
|
.reversed(aaChartModel.yAxisReversed)
|
|
- .gridLineWidth(aaChartModel.yAxisGridLineWidth)//y轴网格线宽度
|
|
|
|
- .title(AATitle()
|
|
|
|
- .text(aaChartModel.yAxisTitle)
|
|
|
|
- )//y 轴标题
|
|
|
|
- .lineWidth(aaChartModel.yAxisLineWidth)//设置 y轴轴线的宽度,为0即是隐藏 y轴轴线
|
|
|
|
|
|
+ .gridLineWidth(aaChartModel.yAxisGridLineWidth) //y轴网格线宽度
|
|
|
|
+ .title(
|
|
|
|
+ AATitle()
|
|
|
|
+ .text(aaChartModel.yAxisTitle)
|
|
|
|
+ .style(
|
|
|
|
+ AAStyle()
|
|
|
|
+ .color(aaChartModel.axesTextColor)
|
|
|
|
+ )
|
|
|
|
+ ) //y 轴标题
|
|
|
|
+ .lineWidth(aaChartModel.yAxisLineWidth) //设置 y轴轴线的宽度,为0即是隐藏 y轴轴线
|
|
.visible(aaChartModel.yAxisVisible)
|
|
.visible(aaChartModel.yAxisVisible)
|
|
|
|
|
|
-
|
|
|
|
aaOptions.xAxis(aaXAxis)
|
|
aaOptions.xAxis(aaXAxis)
|
|
.yAxis(aaYAxis)
|
|
.yAxis(aaYAxis)
|
|
}
|
|
}
|