2
您好,我有條形圖麻煩,我必須刪除該貼在上面的數字X和Y軸,但我不知道如何做到這一點,這是我創建的代碼chart:`String [] monthDays = new String [lastDayOfMonth];
// Create month days labels
int[] x = new int[lastDayOfMonth];
for (int i = 0; i < monthDays.length; i++) {
monthDays[i] = "" + (i + 1);
x[i] = i + 1;
}
// Create series
XYSeries majorSeries = new XYSeries("Major");
XYSeries middleSeries = new XYSeries("Middle");
XYSeries minorSeries = new XYSeries("Minor");
XYSeries restSeries = new XYSeries("Rest");
// Add data to series
for(int i = 0; i < x.length; i++) {
majorSeries.add(i, majorData[i]);
middleSeries.add(i, middleData[i]);
minorSeries.add(i, minorData[i]);
restSeries.add(i, restData[i]);
}
// Create series data set
XYMultipleSeriesDataset xyMultipleSeriesDataset = new XYMultipleSeriesDataset();
// Add series to data set
xyMultipleSeriesDataset.addSeries(restSeries);
xyMultipleSeriesDataset.addSeries(minorSeries);
xyMultipleSeriesDataset.addSeries(middleSeries);
xyMultipleSeriesDataset.addSeries(majorSeries);
// Create series render for major data set
XYSeriesRenderer majorXySeriesRenderer = new XYSeriesRenderer();
majorXySeriesRenderer.setColor(Color.parseColor("#4797b4"));
majorXySeriesRenderer.setFillPoints(true);
majorXySeriesRenderer.setLineWidth(2);
// Create series render for middle data set
XYSeriesRenderer middleXySeriesRenderer = new XYSeriesRenderer();
middleXySeriesRenderer.setColor(Color.parseColor("#4ec697"));
middleXySeriesRenderer.setFillPoints(true);
middleXySeriesRenderer.setLineWidth(2);
// Create series render for minor data set
XYSeriesRenderer minorXySeriesRenderer = new XYSeriesRenderer();
minorXySeriesRenderer.setColor(Color.parseColor("#1fb1ba"));
minorXySeriesRenderer.setFillPoints(true);
minorXySeriesRenderer.setLineWidth(2);
// Create series render for rest data set
XYSeriesRenderer restXySeriesRenderer = new XYSeriesRenderer();
restXySeriesRenderer.setColor(Color.parseColor("#c2c2c2"));
restXySeriesRenderer.setFillPoints(true);
restXySeriesRenderer.setLineWidth(2);
// Creating XYMultipleSeriesRenderer to customize chart
XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
multiRenderer.setOrientation(XYMultipleSeriesRenderer.Orientation.HORIZONTAL);
// Add labels to x
for(int i = 0; i < monthDays.length; i++) {
multiRenderer.addXTextLabel(i, monthDays[i]);
}
multiRenderer.setXLabels(0);
multiRenderer.setYLabels(0);
multiRenderer.setXLabelsColor(Color.BLACK);
multiRenderer.setYLabelsColor(0, Color.BLACK);
multiRenderer.setLabelsTextSize(24);
multiRenderer.setZoomButtonsVisible(false);
multiRenderer.setPanEnabled(true, false);
multiRenderer.setPanLimits(new double[] {-0.75, 31, 0, 0});
multiRenderer.setClickEnabled(false);
multiRenderer.setZoomEnabled(false, false);
multiRenderer.setShowGridY(false);
multiRenderer.setShowGridX(false);
multiRenderer.setFitLegend(true);
multiRenderer.setShowAxes(false);
multiRenderer.setShowLegend(false);
multiRenderer.setShowGrid(false);
multiRenderer.setZoomEnabled(false);
multiRenderer.setExternalZoomEnabled(false);
multiRenderer.setAntialiasing(true);
multiRenderer.setInScroll(true);
multiRenderer.setLegendHeight(30);
multiRenderer.setXLabelsAlign(Paint.Align.CENTER);
multiRenderer.setYLabelsAlign(Paint.Align.LEFT);
multiRenderer.setTextTypeface("sans_serif", Typeface.NORMAL);
multiRenderer.setYAxisMax(maxValue + (maxValue * 2/100));
multiRenderer.addYTextLabel(0, currency + "0.0");
if (maxValue == 0) {
multiRenderer.setYAxisMax(500);
multiRenderer.addYTextLabel(500, currency + maxValue);
} else {
multiRenderer.addYTextLabel(multiRenderer.getYAxisMax(), currency + maxValue);
}
multiRenderer.setXAxisMin(-0.5);
multiRenderer.setXAxisMax(11);
multiRenderer.setBarSpacing(0.5);
multiRenderer.setBackgroundColor(Color.TRANSPARENT);
multiRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
multiRenderer.setApplyBackgroundColor(true);
multiRenderer.setMargins(new int[]{30, 30, 30, 30});
// Add all renders to multi render
multiRenderer.addSeriesRenderer(restXySeriesRenderer);
multiRenderer.addSeriesRenderer(minorXySeriesRenderer);
multiRenderer.addSeriesRenderer(middleXySeriesRenderer);
multiRenderer.addSeriesRenderer(majorXySeriesRenderer);
// Create array of chart types
CombinedXYChart.XYCombinedChartDef[] types = new CombinedXYChart.XYCombinedChartDef[]{
new CombinedXYChart.XYCombinedChartDef(BarChart.TYPE, 0),
new CombinedXYChart.XYCombinedChartDef(BarChart.TYPE, 1),
new CombinedXYChart.XYCombinedChartDef(BarChart.TYPE, 2),
new CombinedXYChart.XYCombinedChartDef(BarChart.TYPE, 3)};
// Get view of chart
GraphicalView graphicalView = ChartFactory.getCombinedXYChartView(getContext(), xyMultipleSeriesDataset, multiRenderer, types);
chart.removeAllViews();
chart.addView(graphicalView);`