Пример #1
0
 public void init() {
   mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00)); // transparent margins
   mRenderer.setPanEnabled(false, false);
   mRenderer.setYAxisMax(-40);
   mRenderer.setYAxisMin(-100);
   mRenderer.setYLabels(3);
   mRenderer.setYTitle(LABEL_Y);
   mRenderer.setXAxisMin(0);
   mRenderer.setXAxisMax(300);
   mRenderer.setXLabels(15);
   mRenderer.setXTitle(LABEL_X);
   mRenderer.setShowGrid(true);
   mRenderer.setShowLabels(true);
   mRenderer.setShowLegend(false);
   mRenderer.setShowCustomTextGrid(true);
 }
  private void setupTopChart() {

    // Creating an  XYSeries for Sound
    visitsSeries = new XYSeries("");
    secondSeries = new XYSeries("");

    // Creating a dataset to hold each series
    dataset = new XYMultipleSeriesDataset();
    Sdataset = new XYMultipleSeriesDataset();

    // Adding Visits Series to the dataset
    dataset.addSeries(visitsSeries);
    Sdataset.addSeries(secondSeries);

    // Adding datasets together
    multiDateSet = new XYMultipleSeriesDataset();
    multiDateSet.addSeries(visitsSeries);
    multiDateSet.addSeries(secondSeries);

    // Creating XYSeriesRenderer to customize visitsSeries
    visitsRenderer = new XYSeriesRenderer();
    visitsRenderer.setColor(getResources().getColor(R.color.colorAccent));
    visitsRenderer.setPointStyle(PointStyle.CIRCLE);
    visitsRenderer.setFillPoints(true);
    visitsRenderer.setDisplayChartValues(false);
    visitsRenderer.setLineWidth(10);

    // Creating a XYMultipleSeriesRenderer to customize the whole chart
    multiRenderer = new XYMultipleSeriesRenderer();

    multiRenderer.setMargins(new int[] {0, 0, 0, 0});
    multiRenderer.setPanEnabled(false);
    multiRenderer.setShowLegend(false);
    multiRenderer.setChartTitle("");
    // multiRenderer.setFitLegend(true);

    // Eliminate the S***e
    multiRenderer.setApplyBackgroundColor(true);
    multiRenderer.setXTitle("");
    multiRenderer.setShowLabels(false);
    multiRenderer.setShowAxes(false);

    multiRenderer.setMarginsColor(Color.TRANSPARENT);
    multiRenderer.setBackgroundColor(Color.TRANSPARENT);
    multiRenderer.setXLabelsColor(Color.TRANSPARENT);
    multiRenderer.setYLabelsColor(0, Color.TRANSPARENT);
    multiRenderer.setGridColor(Color.TRANSPARENT);
    multiRenderer.setXLabelsPadding(0);
    multiRenderer.setYLabelsPadding(0);
    multiRenderer.setBarWidth(100);

    // Establish Beginning Dimensions
    multiRenderer.setXAxisMin(0);
    multiRenderer.setXAxisMax(10);
    multiRenderer.setYAxisMin(0);
    multiRenderer.setYAxisMax(0);

    // Make the bar graphs touching
    multiRenderer.setBarSpacing(0);

    // Adding visitsRenderer to multipleRenderer
    // Note: The order of adding dataseries to dataset and renderers to multipleRenderer
    // should be same
    multiRenderer.addSeriesRenderer(visitsRenderer);
    multiRenderer.addSeriesRenderer(visitsRenderer);

    // Getting a reference to LinearLayout of the RecordActivity Layout
    LinearLayout chartContainer = (LinearLayout) findViewById(R.id.chartTop);

    mChart =
        (GraphicalView)
            ChartFactory.getBarChartView(
                getBaseContext(),
                multiDateSet,
                multiRenderer,
                org.achartengine.chart.BarChart.Type.DEFAULT);

    // Adding the Line Chart to the LinearLayout
    chartContainer.addView(mChart);
  }