Open
Description
void setUpAAPlotLinesChartView() {
AAChartView aaChartView = findViewById(R.id.aa_chart_view);
AASeriesElement[] configurePlotLinesChartSeriesArray = configurePlotLinesChartSeriesArray();
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Line)
.title("流式荧光检测")
.subtitle("实验数据")
.backgroundColor("#ffffff")
.categories(new String[]{})
.dataLabelsEnabled(false)
.yAxisGridLineWidth(0f)
.yAxisTitle("电压值(V)")
.zoomType(AAChartZoomType.X)
.scrollablePlotArea(new AAScrollablePlotArea()
.minWidth(8000)
.scrollPositionX(0f))
.series(configurePlotLinesChartSeriesArray);
AAPlotLinesElement[] aaPlotLinesElementsArr = {
new AAPlotLinesElement()
.color("#1e90ff")//颜色值(16进制)
.dashStyle(AAChartLineDashStyleType.LongDashDotDot)//样式:Dash,Dot,Solid等,默认Solid
.width((1f)) //标示线粗细
.value((1.4f)) //所在位置
.zIndex((1)) //层叠,标示线在图表中显示的层叠级别,值越大,显示越向前
.label(new AALabel()
.useHTML(true)
.text("分割线1")
.style(new AAStyle()
.color("#FFD700")
.backgroundColor("black")
.borderRadius(5)
.border("3px solid #000000")
.opacity(1.0)
.fontWeight(AAChartFontWeightType.Bold)
)
)
,
new AAPlotLinesElement()
.color("#ef476f")//颜色值(16进制)
.dashStyle(AAChartLineDashStyleType.LongDashDot)//样式:Dash,Dot,Solid等,默认Solid
.width((1f)) //标示线粗细
.value((2.2f)) //所在位置
.zIndex((1)) //层叠,标示线在图表中显示的层叠级别,值越大,显示越向前
.label(new AALabel()
.useHTML(true)
.text("分割线2")
.style(new AAStyle()
.color("red")
.backgroundColor("black")
.borderRadius(5)
.border("3px solid red")
.opacity(1.0)
.fontWeight(AAChartFontWeightType.Bold)))
};
AAOptions aaOptions = AAOptionsConstructor.INSTANCE.configureChartOptions(aaChartModel);
AAYAxis aaYAxis = aaOptions.getYAxis();
assert aaYAxis != null;
aaYAxis.plotLines(aaPlotLinesElementsArr);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
// aaChartView.aa_drawChartWithChartModel(aaChartModel);
}
private AASeriesElement[] configurePlotLinesChartSeriesArray() {
Map map1 = new HashMap();
map1.put("value", 1.4);
map1.put("color", "#1e90ff");
Map map2 = new HashMap();
map2.put("value", 2.2);
map2.put("color", "#ef476f");
Map map3 = new HashMap();
map3.put("color", "#ffd066");
Map[] zonesArr = new Map[]{map1, map2, map3};
return new AASeriesElement[]{
new AASeriesElement()
.name("第一次数据")
.data(InputFileReader.toArrayByInputStreamReader(this, R.raw.b))
// .fillOpacity(0.5f)
// .lineWidth(2f)
.zones(zonesArr)
};
}
上面是我的代码,下面是运行的截图
InputFileReader.toArrayByInputStreamReader(this, R.raw.b)函数是读取我本地的txt处理后返回double数组
求帮助!