左轴值在MPAndroidChart的线图中重叠

时间:2017-11-22 05:03:23

标签: java android android-layout mpandroidchart

如何在全屏显示图表。左轴值重叠,因此图形也受到干扰。检查图形的xml和java代码。

请查看下图以获得说明。

image

我的xml--     <

com.github.mikephil.charting.charts.LineChart 
     android:id="@+id/LineChart_netSale" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 

Java代码:

LineDataSet setNetSale = new LineDataSet(yValsNetSale, "DataSet 1");
    setNetSale.setAxisDependency(YAxis.AxisDependency.LEFT);
    setNetSale.setFillAlpha(110);
    setNetSale.setFillColor(Color.rgb(93, 188, 210));
    setNetSale.setColor(Color.rgb(255, 255, 255));
    setNetSale.setCircleColor(Color.rgb(93, 188, 210));
    setNetSale.setLineWidth(3f);
    setNetSale.setDrawCircleHole(false);
    setNetSale.setValueTextSize(9f);
    setNetSale.setDrawCircles(false);

    List<ILineDataSet> dataSetsNetSale = new ArrayList<ILineDataSet>();
    dataSetsNetSale.add(setNetSale); // add the datasets

    // create a data object with the datasets
    LineData dataNetSale = new LineData(xValsNetSale, dataSetsNetSale);

    // set data
    LineChart_netSale.setData(dataNetSale);
    LineChart_netSale.animateXY(2000, 2000);
    LineChart_netSale.notifyDataSetChanged();
    LineChart_netSale.invalidate();

    Legend legend_netSale = LineChart_netSale.getLegend();
    legend_netSale.setForm(Legend.LegendForm.LINE);

    LineChart_netSale.getAxisRight().setDrawLabels(false);
    LineChart_netSale.setDescription("");    // Hide the description
    LineChart_netSale.getLegend().setEnabled(false);
    LineChart_netSale.getLineData().setDrawValues(false);
    LineChart_netSale.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    LineChart_netSale.getAxisLeft().setDrawGridLines(false);
    LineChart_netSale.getXAxis().setDrawGridLines(false);
    LineChart_netSale.setDrawGridBackground(false);
    LineChart_netSale.moveViewToX(10);
    LineChart_netSale.getAxisLeft().setAxisMinValue(0);
    LineChart_netSale.setNoDataText("No chart data available");

    YAxis yrlineNetSale = LineChart_netSale.getAxisRight();
    yrlineNetSale.setDrawAxisLine(true);
    yrlineNetSale.setDrawGridLines(false);

0 个答案:

没有答案