是否可以删除两点之间的线?
这是我的代码:
public Intent execute(Context context){
String[] titles = new String[] { "Systolic Pressure", "Diastolic Pressure"}; List<double[]> x = new ArrayList<double[]>(); for (int i = 0; i < titles.length; i++) { x.add(new double[] { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 }); } List<double[]> values = new ArrayList<double[]>(); values.add(new double[] { 108, 110.5, 110, 115, 114, 118, 116, 119, 120, 125.3, 122.2, 123.9 }); values.add(new double[] { 75, 77, 80, 79, 82, 84, 83, 80, 86, 88, 85, 80 }); int[] colors = new int[] { Color.BLUE, Color.RED}; PointStyle[] styles = new PointStyle[] {PointStyle.TRIANGLE, PointStyle.TRIANGLE}; XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles); setChartSettings(renderer, " ", " ", " ", 0, 60, 0, 250,Color.WHITE,Color.WHITE); renderer.setXLabels(12); renderer.setYLabels(10); renderer.setShowGridY(true); renderer.setXLabelsAlign(Align.RIGHT); renderer.setYLabelsAlign(Align.RIGHT); renderer.setZoomButtonsVisible(true); renderer.setPanLimits(new double[] { 0,60, 0, 250 }); renderer.setZoomLimits(new double[] { 0, 60, 0, 250}); XYMultipleSeriesDataset dataset = buildDataset(titles, x, values); Intent intent = ChartFactory.getLineChartIntent(context, dataset, renderer,"Anesthesia Sheet"); return intent; }
这里是图形结果:
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9ma1p2aC5qcGcifQ==” alt =“在此处输入图像描述”>
而不是使用折线图,而是使用散点图。
更改:
Intent intent = ChartFactory.getLineChartIntent(上下文,数据集,渲染器,“麻醉表”);
收件人:
Intent intent = ChartFactory.getScatterChartIntent(上下文,数据集,渲染器,“麻醉表”);
[我尝试将应用中的折线图切换为散点图,并且按预期方式工作-点的绘制没有连接线。
我编辑Renderer.setLineWidth(0)
以尊重0条宽线。其差异看起来像这样:
+++ b/.../app/src/main/java/org/achartengine/chart/AbstractChart.java
@@ -302,6 +302,7 @@ public abstract class AbstractChart implements Serializable {
Path path = new Path();
int height = canvas.getHeight();
int width = canvas.getWidth();
+ float strokeWidth = paint.getStrokeWidth();^M
float[] tempDrawPoints;
if (points.size() < 4) {
@@ -310,7 +311,10 @@ public abstract class AbstractChart implements Serializable {
tempDrawPoints = calculateDrawPoints(points.get(0), points.get(1), points.get(2),
points.get(3), height, width);
path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
- path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);
+ if (strokeWidth > 0.0f)^M
+ path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);^M
+ else^M
+ path.moveTo(tempDrawPoints[2], tempDrawPoints[3]);^M
int length = points.size();
for (int i = 4; i < length; i += 2) {
@@ -323,7 +327,10 @@ public abstract class AbstractChart implements Serializable {
if (!circular) {
path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
}
- path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);
+ if (strokeWidth > 0.0)^M
+ path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);^M
+ else^M
+ path.moveTo(tempDrawPoints[2], tempDrawPoints[3]);^M
+++ b/.../app/src/main/java/org/achartengine/chart/LineChart.java
@@ -81,7 +81,8 @@ public class LineChart extends XYChart {
public void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer renderer,
float yAxisValue, int seriesIndex, int startIndex) {
float lineWidth = paint.getStrokeWidth();
- paint.setStrokeWidth(renderer.getLineWidth());
+ float lineWidth1 = renderer.getLineWidth();^M
+ paint.setStrokeWidth(lineWidth1);^M
final FillOutsideLine[] fillOutsideLine = renderer.getFillOutsideLine();
for (FillOutsideLine fill : fillOutsideLine) {
@@ -227,8 +228,13 @@ public class LineChart extends XYChart {
public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, Paint paint) {
float oldWidth = paint.getStrokeWidth();
- paint.setStrokeWidth(((XYSeriesRenderer) renderer).getLineWidth());
- canvas.drawLine(x, y, x + SHAPE_WIDTH, y, paint);
+ float lineWidth = ((XYSeriesRenderer) renderer).getLineWidth();^M
+^M
+ if (lineWidth > 0.0) {^M
+ paint.setStrokeWidth(lineWidth);^M
+ canvas.drawLine(x, y, x + SHAPE_WIDTH, y, paint);^M
+ }^M
+^M