问题
I am trying to match the line chart background with the whole layout bg. so i tried following to set the background of chart. It matched with the bg but when i dragged the graph it goes out of view.
mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
Here is the screenshot:
If needed further information, let me know.
Please help guys.
Here is the code
XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
XYSeries mSeries = new XYSeries("Weight");
for (int i = 0; i < weight_list.size(); i++) {
mSeries.add(i + 1, Double.parseDouble(weight_list.get(i)));
}
mDataset.addSeries(mSeries);
XYSeriesRenderer seriesRenderer = new XYSeriesRenderer();
seriesRenderer.setPointStrokeWidth(25);
seriesRenderer.setShowLegendItem(false);
seriesRenderer.setPointStyle(PointStyle.SQUARE);
seriesRenderer.setFillPoints(true);
seriesRenderer.setChartValuesTextSize(30);
seriesRenderer.setColor(Color.CYAN);
seriesRenderer.setDisplayChartValues(true);
seriesRenderer.setLineWidth(3);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setApplyBackgroundColor(true);
// mRenderer.setBackgroundColor(Color.BLACK);
mRenderer.setLabelsTextSize(25);
mRenderer.setChartTitleTextSize(20);
mRenderer.setAxisTitleTextSize(25);
mRenderer.setAxesColor(Color.WHITE);
mRenderer.setXTitle("\nWeeks in Program");
mRenderer.setGridColor(Color.WHITE);
mRenderer.setYTitle("Weight (Lb)");
mRenderer.setShowGrid(true);
// mRenderer.setMargins(new int[] { 0, 60, 0, 0 });
// mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
mRenderer.setPointSize(5);
mRenderer.setPanEnabled(true, true);
mRenderer.setPanLimits(new double[] { 0, 50, 0, 500 });
mRenderer.addSeriesRenderer(seriesRenderer);
chartView = ChartFactory.getLineChartView(this, mDataset, mRenderer);
graphLayout.addView(chartView);
来源:https://stackoverflow.com/questions/22965479/graph-goes-out-of-view-when-margin-color-set-to-transparent-in-achartengine