Java 类com.github.mikephil.charting.data.CombinedData 实例源码

项目:ecological-marine-unit-android    文件:SummaryChartFragment.java   
/**
 * Create a legend based on a dummy chart.  The legend
 * is used by all charts and is positioned
 * across the top of the screen.
 * @param data - CombinedData used to generate the legend
 */
private void prepareLegend(final CombinedData data){
  //The dummy chart is never shown, but it's legend is.
  final CombinedChart dummyChart = (CombinedChart) mRoot.findViewById(R.id.legend);
  dummyChart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
  dummyChart.getXAxis().setEnabled(false);
  dummyChart.getAxisRight().setEnabled(false);
  dummyChart.getAxisLeft().setEnabled(false);
  final Description description = new Description();
  description.setText("");
  description.setTextSize(10f);
  dummyChart.setDescription(description);
  dummyChart.setBackgroundColor(Color.WHITE);
  dummyChart.setDrawGridBackground(false);
  dummyChart.setData(data);

  final Legend l = dummyChart.getLegend();
  l.setEnabled(true);
  // The positioning of the legend effectively
  // hides the dummy chart from view.
  l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
  l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
  dummyChart.invalidate();
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Create dataset to be displayed in chart legend
 * @return CombinedData representing dummy data for a legend
 */
private CombinedData buildDummyDataForLegend(){
  CombinedData combinedData = new CombinedData();
  float xIndex = 1.5f;
  float close = 13;
  float open = 26f;
  float shadowH = 30.33f;
  float shadowL = -2.05f;
  float average = 20f;
  CandleData candleData = generateCandleData(xIndex, shadowH, shadowL, open, close, "EMU HI/LO" );
  ScatterData scatterData = generateScatterData(average, "EMU Mean");

  LineData s1 = generateOceanHiLo(close, open, "Ocean HI/LO");
  combinedData.setData(s1);
  combinedData.setData(candleData);
  combinedData.setData(scatterData);
  return combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing temperature data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildTempData(EMUObservation observation, EMUStat stat){
  CombinedData combinedData = new CombinedData();
  if (stat.getTemp_max() == null || stat.getTemp_min() == null || stat.getTemp_mean() == null || observation.getTemperature() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getTemp_min().doubleValue();
  float open = (float) stat.getTemp_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxTemperatureFromSummary().doubleValue();   // 30.33f; // Greatest max temp from summary table
  float shadowL = (float) mDataManager.getMinTemperatureFromSummary().doubleValue();  // -2.05f; // Lowest min temp from summary table

  float averageTemp = (float)observation.getTemperature().doubleValue();
  Log.i("SummaryChartPresenter", "Temperature: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageTemp);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, TEMPERATURE ));
  ScatterData sdata = generateScatterData(averageTemp, TEMPERATURE);
  combinedData.setData(sdata);
  return  combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing salinity data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildSalinityData(EMUObservation observation, EMUStat stat){
  CombinedData combinedData = new CombinedData();
  if (stat.getSalinity_max() == null || stat.getSalinity_min() == null || stat.getSalinity_mean() == null || observation.getSalinity() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getSalinity_min().doubleValue();
  float open = (float) stat.getSalinity_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxSalinityFromSummary().doubleValue();
  float shadowL = (float) mDataManager.getMinSalinityFromSummary().doubleValue();

  float avgSalinity = (float)observation.getSalinity().doubleValue();
  Log.i("SummaryChartPreseter", "Salinity: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ avgSalinity);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, SALINITY ));
  combinedData.setData(generateScatterData(avgSalinity, SALINITY));
  return  combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing oxygen data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildOxygenData(EMUObservation observation, EMUStat stat){

  CombinedData combinedData = new CombinedData();
  if (stat.getDisso2_max() == null || stat.getDisso2_min() == null || stat.getDisso2_mean() == null || observation.getOxygen() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getDisso2_min().doubleValue();
  float open = (float) stat.getDisso2_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxOxygenFromSummary().doubleValue();
  float shadowL = (float) mDataManager.getMinOxygenFromSummary().doubleValue();

  float averageOx = (float)observation.getOxygen().doubleValue();
  Log.i("SummaryChartPreseter", "Oxygen: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageOx);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, OXYGEN ));
  combinedData.setData(generateScatterData(averageOx, OXYGEN));
  return  combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing phosphate data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildPhosphateData(EMUObservation observation, EMUStat stat){
  CombinedData combinedData = new CombinedData();
  if (stat.getPhosphate_max() == null || stat.getPhosphate_min() == null || stat.getPhosphate_mean() == null || observation.getPhosphate() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getPhosphate_min().doubleValue();
  float open = (float) stat.getPhosphate_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxPhosphateFromSummary().doubleValue();
  float shadowL = (float) mDataManager.getMinPhosphateFromSummary().doubleValue();

  float averagePhos = (float)observation.getPhosphate().doubleValue();
  Log.i("SummaryChartPreseter", "Phosphate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averagePhos);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, PHOSPHATE ));
  combinedData.setData(generateScatterData(averagePhos, PHOSPHATE));
  return  combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing silicate data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildSilicateData(EMUObservation observation, EMUStat stat){
  CombinedData combinedData = new CombinedData();
  if (stat.getSilicate_max() == null || stat.getSilicate_min() == null || stat.getSilicate_mean() == null || observation.getSilicate() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getSilicate_min().doubleValue();
  float open = (float) stat.getSilicate_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxSilicateFromSummary().doubleValue();
  float shadowL = (float) mDataManager.getMinSilicateFromSummary().doubleValue();

  float averageSil = (float)observation.getSilicate().doubleValue();
  Log.i("SummaryChartPreseter", "Silicate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageSil);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, SILICATE ));
  combinedData.setData(generateScatterData(averageSil, SILICATE));
  return  combinedData;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Build a CombinedData object containing nitrate data
 * @param observation - EMUObservation
 * @param stat - EMUStat
 * @return - CombinedData
 */
private CombinedData buildNitrateData(EMUObservation observation, EMUStat stat){
  CombinedData combinedData = new CombinedData();
  if (stat.getNitrate_min() == null || stat.getNitrate_max() == null || stat.getNitrate_mean() == null || observation.getNitrate() == null){
    return combinedData;
  }
  float xIndex = 1.5f;
  float close = (float) stat.getNitrate_min().doubleValue();
  float open = (float) stat.getNitrate_max().doubleValue();
  float shadowH = (float)mDataManager.getMaxNitrateFromSummary().doubleValue();
  float shadowL = (float) mDataManager.getMinNitrateFromSummary().doubleValue();

  float averageN = (float)observation.getNitrate().doubleValue();
  Log.i("SummaryChartPreseter", "Nitrate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageN);

  combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, NITRATE ));
  combinedData.setData(generateScatterData(averageN, NITRATE));
  return combinedData;
}
项目:GitHub    文件:CombinedChart.java   
@Override
public void setData(CombinedData data) {
    super.setData(data);
    setHighlighter(new CombinedHighlighter(this, this));
    ((CombinedChartRenderer)mRenderer).createRenderers();
    mRenderer.initBuffers();
}
项目:GitHub    文件:CombinedChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    Chart chart = mChart.get();
    if (chart == null) return;

    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;

        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer)renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer)renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();

        int dataIndex = data == null ? -1
                : ((CombinedData)chart.getData()).getAllData().indexOf(data);

        mHighlightBuffer.clear();

        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                mHighlightBuffer.add(h);
        }

        renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
    }
}
项目:Stayfit    文件:CombinedChartActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_combined);

        mChart = (CombinedChart) findViewById(R.id.chart1);
        mChart.setDescription("");
        mChart.setBackgroundColor(Color.WHITE);
        mChart.setDrawGridBackground(false);
        mChart.setDrawBarShadow(false);

        // draw bars behind lines
        mChart.setDrawOrder(new DrawOrder[] {
                DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
        });

        YAxis rightAxis = mChart.getAxisRight();
        rightAxis.setDrawGridLines(false);
        rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

        XAxis xAxis = mChart.getXAxis();
        xAxis.setPosition(XAxisPosition.BOTH_SIDED);

        CombinedData data = new CombinedData(mMonths);

        data.setData(generateLineData());
        data.setData(generateBarData());
//        data.setData(generateBubbleData());
//         data.setData(generateScatterData());
//         data.setData(generateCandleData());

        mChart.setData(data);
        mChart.invalidate();
    }
项目:NetKnight    文件:CombinedChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    Chart chart = mChart.get();
    if (chart == null) return;

    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;

        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer)renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer)renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();

        int dataIndex = data == null
                ? -1
                : ((CombinedData)chart.getData()).getAllData().indexOf(data);

        ArrayList<Highlight> dataIndices = new ArrayList<>();
        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                dataIndices.add(h);
        }

        renderer.drawHighlighted(c, dataIndices.toArray(new Highlight[dataIndices.size()]));

    }
}
项目:NetKnight    文件:CombinedHighlighter.java   
/**
 * Returns a list of SelectionDetail object corresponding to the given xIndex.
 *
 * @param xIndex
 * @return
 */
@Override
protected List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex, int dataSetIndex) {

    List<SelectionDetail> vals = new ArrayList<SelectionDetail>();
    float[] pts = new float[2];

    CombinedData data = (CombinedData) mChart.getData();

    // get all chartdata objects
    List<ChartData> dataObjects = data.getAllData();

    for (int i = 0; i < dataObjects.size(); i++) {

        for(int j = 0; j < dataObjects.get(i).getDataSetCount(); j++) {

            IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);

            // dont include datasets that cannot be highlighted
            if (!dataSet.isHighlightEnabled())
                continue;

            // extract all y-values from all DataSets at the given x-index
            final float yVals[] = dataSet.getYValsForXIndex(xIndex);
            for (float yVal : yVals) {
                pts[1] = yVal;

                mChart.getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts);

                if (!Float.isNaN(pts[1])) {
                    vals.add(new SelectionDetail(pts[1], yVal, i, j, dataSet));
                }
            }
        }
    }

    return vals;
}
项目:ecological-marine-unit-android    文件:WaterProfileFragment.java   
/**
 * Set the data for the adapter
 * @param dataList - List<CombinedData> containing data points
 */
@Override public void showWaterProfiles(final List<CombinedData> dataList ) {
  //
  // Because this FragmentPagerAdapter is being used within a nested
  // fragment, we don't want to use the shared fragment manager.
  // USE A NEW INSTANCE OF THE FRAGMENT MANAGER rather than
  // using the fragment manager belonging to the activity.
  //
  TabPagerAdapter adapter = new TabPagerAdapter(getChildFragmentManager(), dataList);
  mViewPager.setAdapter(adapter);
  mViewPager.getAdapter().notifyDataSetChanged();

}
项目:ecological-marine-unit-android    文件:SummaryChartFragment.java   
/**
 * Display chart data
 * @param dataList - List<CombinedData> for populating charts
 */
@Override public void showChartData(final List<CombinedData> dataList) {
  if (dataList != null){
    final int size = dataList.size();
    for (int x = 0; x < (size - 1); x++){
      final CombinedData data = dataList.get(x);
      final int viewId = getIdForChartView(x);
      prepareChartView(viewId, data);
    }
    prepareLegend(dataList.get(size -1));
  }
}
项目:ecological-marine-unit-android    文件:SummaryChartFragment.java   
/**
 * Build out the charts for given dataset
 * @param id - int representing chart id
 * @param data - CombinedData displayed in the chart
 */
private void prepareChartView(final int id, final CombinedData data){
  final CombinedChart chart = (CombinedChart) mRoot.findViewById(id);
  chart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
  chart.getXAxis().setEnabled(false);
  chart.getAxisRight().setEnabled(false);
  chart.getAxisLeft().setDrawGridLines(false);
  chart.getDescription().setEnabled(false);
  chart.getLegend().setEnabled(false);
  chart.setBackgroundColor(Color.WHITE);
  chart.setDrawGridBackground(false);

  chart.setData(data);
  chart.invalidate();
}
项目:xs-android-architecture    文件:CombinedChart.java   
@Override
public void setData(CombinedData data) {
    super.setData(data);
    setHighlighter(new CombinedHighlighter(this, this));
    ((CombinedChartRenderer)mRenderer).createRenderers();
    mRenderer.initBuffers();
}
项目:xs-android-architecture    文件:CombinedChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    Chart chart = mChart.get();
    if (chart == null) return;

    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;

        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer)renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer)renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();

        int dataIndex = data == null ? -1
                : ((CombinedData)chart.getData()).getAllData().indexOf(data);

        mHighlightBuffer.clear();

        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                mHighlightBuffer.add(h);
        }

        renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
    }
}
项目:daily-dozen-android    文件:LoadServingsHistoryTask.java   
private CombinedData createLineAndBarData(List<String> xLabels, List<Entry> lineEntries, List<BarEntry> barEntries) {
    final CombinedData combinedData = createLineData(xLabels, lineEntries);
    if (combinedData != null) {
        combinedData.setData(getBarData(xLabels, barEntries));
    }
    return combinedData;
}
项目:daily-dozen-android    文件:LoadServingsHistoryTask.java   
private CombinedData createLineData(final List<String> xLabels, final List<Entry> lineEntries) {
    if (isCancelled()) {
        return null;
    } else {
        final CombinedData combinedData = new CombinedData(xLabels);
        combinedData.setData(getLineData(xLabels, lineEntries));
        return combinedData;
    }
}
项目:LETO-Toggl_Android    文件:CombinedChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    Chart chart = mChart.get();
    if (chart == null) return;

    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;

        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer)renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer)renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();

        int dataIndex = data == null ? -1
                : ((CombinedData)chart.getData()).getAllData().indexOf(data);

        mHighlightBuffer.clear();

        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                mHighlightBuffer.add(h);
        }

        renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
    }
}
项目:gadgetbridge_artikcloud    文件:WeekStepsChartFragment.java   
private DefaultChartsData refreshWeekBeforeSteps(DBHandler db, CombinedChart combinedChart, Calendar day, GBDevice device) {

        ActivityAnalysis analysis = new ActivityAnalysis();

        day = (Calendar) day.clone(); // do not modify the caller's argument
        day.add(Calendar.DATE, -7);
        List<BarEntry> entries = new ArrayList<>();
        List<String> labels = new ArrayList<>();

        for (int counter = 0; counter < 7; counter++) {
            entries.add(new BarEntry(analysis.calculateTotalSteps(getSamplesOfDay(db, day, device)), counter));
            labels.add(day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale));
            day.add(Calendar.DATE, 1);
        }

        BarDataSet set = new BarDataSet(entries, "");
        set.setColor(akActivity.color);

        BarData barData = new BarData(labels, set);
        barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);

        LimitLine target = new LimitLine(mTargetSteps);
        combinedChart.getAxisLeft().removeAllLimitLines();
        combinedChart.getAxisLeft().addLimitLine(target);

        CombinedData combinedData = new CombinedData(labels);
        combinedData.setData(barData);
        return new DefaultChartsData(combinedData);
    }
项目:MPAndroidChart    文件:CombinedChart.java   
@Override
public void setData(CombinedData data) {
    super.setData(data);
    setHighlighter(new CombinedHighlighter(this, this));
    ((CombinedChartRenderer)mRenderer).createRenderers();
    mRenderer.initBuffers();
}
项目:MPAndroidChart    文件:CombinedChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    Chart chart = mChart.get();
    if (chart == null) return;

    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;

        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer)renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer)renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();

        int dataIndex = data == null ? -1
                : ((CombinedData)chart.getData()).getAllData().indexOf(data);

        mHighlightBuffer.clear();

        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                mHighlightBuffer.add(h);
        }

        renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
    }
}
项目:GitHub    文件:CombinedChart.java   
@Override
public CombinedData getCombinedData() {
    return mData;
}
项目:GitHub    文件:CombinedChartActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_combined);

    mChart = (CombinedChart) findViewById(R.id.chart1);
    mChart.getDescription().setEnabled(false);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    mChart.setHighlightFullBarEnabled(false);

    // draw bars behind lines
    mChart.setDrawOrder(new DrawOrder[]{
            DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
    });

    Legend l = mChart.getLegend();
    l.setWordWrapEnabled(true);
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setDrawGridLines(false);
    leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setAxisMinimum(0f);
    xAxis.setGranularity(1f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mMonths[(int) value % mMonths.length];
        }
    });

    CombinedData data = new CombinedData();

    data.setData(generateLineData());
    data.setData(generateBarData());
    data.setData(generateBubbleData());
    data.setData(generateScatterData());
    data.setData(generateCandleData());
    data.setValueTypeface(mTfLight);

    xAxis.setAxisMaximum(data.getXMax() + 0.25f);

    mChart.setData(data);
    mChart.invalidate();
}
项目:igrow-android    文件:EnvironmentalSensorDetailFragment.java   
protected void initChart() {
    mCombinedChart.getDescription().setEnabled(false);
    mCombinedChart.setBackgroundColor(Color.WHITE);
    mCombinedChart.setDrawGridBackground(false);
    mCombinedChart.setDrawBarShadow(false);
    mCombinedChart.setHighlightFullBarEnabled(false);

    // draw bars behind lines
    mCombinedChart.setDrawOrder(new CombinedChart.DrawOrder[]{
            CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE,
            CombinedChart.DrawOrder.CANDLE, CombinedChart.DrawOrder.LINE,
            CombinedChart.DrawOrder.SCATTER
    });

    Legend l = mCombinedChart.getLegend();
    l.setWordWrapEnabled(true);
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);

    YAxis rightAxis = mCombinedChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    YAxis leftAxis = mCombinedChart.getAxisLeft();
    leftAxis.setDrawGridLines(false);
    leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    XAxis xAxis = mCombinedChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
    xAxis.setAxisMinimum(0f);
    xAxis.setGranularity(1f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mMonths[(int) value % mMonths.length];
        }
    });

    CombinedData data = new CombinedData();

    data.setData(generateLineData());
    data.setData(generateBarData());
    data.setData(generateBubbleData());
    data.setData(generateScatterData());
    data.setData(generateCandleData());
    //data.setValueTypeface(mTfLight);

    xAxis.setAxisMaximum(data.getXMax() + 0.25f);

    mCombinedChart.setData(data);
    mCombinedChart.invalidate();
}
项目:shengyiplus-android    文件:HomeTricsActivity.java   
/**
     * 初始化报表
     *
     * @param showAnimation 是否显示动画
     */
    void initChart(boolean showAnimation) {

        int screenWidth = Utils.getScreenWidth(mContext);
        combinedChart.getLayoutParams().height = screenWidth * 300 / 640;

        //启用缩放和拖动
        combinedChart.setDragEnabled(true);//拖动
        combinedChart.setScaleEnabled(false);//缩放
        combinedChart.setOnChartValueSelectedListener(this);
        combinedChart.getDescription().setEnabled(false);
        combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
        combinedChart.setDrawGridBackground(false);
        combinedChart.setDrawBarShadow(false);
        combinedChart.setHighlightFullBarEnabled(false);

        Legend l = combinedChart.getLegend();
        l.setForm(Legend.LegendForm.NONE);//底部样式
        l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
        l.setWordWrapEnabled(false);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);

        YAxis rightAxis = combinedChart.getAxisRight();
        rightAxis.setEnabled(false);

        YAxis leftAxis = combinedChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setGranularityEnabled(false);
        leftAxis.setDrawAxisLine(false);
        leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
        leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));

        updateTitle(items.get(dateSelected));
        XAxis xAxis = combinedChart.getXAxis();
        xAxis.setTypeface(mTfLight);
        xAxis.setEnabled(true);//设置轴启用或禁用 如果禁用以下的设置全部不生效
        xAxis.setDrawAxisLine(true);//是否绘制轴线
        xAxis.setDrawGridLines(false);//设置x轴上每个点对应的线
        xAxis.setDrawLabels(true);//绘制标签  指x轴上的对应数值
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置x轴的显示位置
        xAxis.setTextSize(10f); //设置X轴文字大小
        xAxis.setGranularityEnabled(true);//是否允许X轴上值重复出现
        xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//设置X轴文字颜色
//        //设置竖线的显示样式为虚线
//        //lineLength控制虚线段的长度
//        //spaceLength控制线之间的空间
        xAxis.enableGridDashedLine(10f, 10f, 0f);
        xAxis.setAxisMinimum(0f);//设置x轴的最小值
        xAxis.setAxisMaximum(mDatas.length);//设置最大值
        xAxis.setAvoidFirstLastClipping(true);//图表将避免第一个和最后一个标签条目被减掉在图表或屏幕的边缘
        xAxis.setLabelRotationAngle(0f);//设置x轴标签字体的旋转角度
//        设置x轴显示标签数量  还有一个重载方法第二个参数为布尔值强制设置数量 如果启用会导致绘制点出现偏差
        xAxis.setLabelCount(10);
        xAxis.setGridLineWidth(10f);//设置竖线大小
//        xAxis.setGridColor(Color.RED);//设置竖线颜色
        xAxis.setAxisLineColor(Color.GRAY);//设置x轴线颜色
        xAxis.setAxisLineWidth(1f);//设置x轴线宽度

        CombinedData combinedData = new CombinedData();
        combinedData.setData(generateLineData());
        combinedData.setData(generateBarData());
        combinedData.setValueTypeface(mTfLight);
        xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
        //X轴的数据格式
        ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
        xAxisFormatter.setmValues(xAxisValue);
        xAxis.setValueFormatter(xAxisFormatter);//格式化x轴标签显示字符
        combinedChart.setData(combinedData);
        combinedChart.invalidate();
        if (showAnimation) {
            combinedChart.animateY(2000);
        }
    }
项目:ecological-marine-unit-android    文件:TabPagerAdapter.java   
public TabPagerAdapter(final FragmentManager fm, final List<CombinedData> data) {
  super(fm);
  mChartDataList = data;
}
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Prepare data for displaying in charts
 * @param stat - EMUStat
 * @param waterColumn - WaterColumn
 * @param emuName - int representing EMU name
 */
@Override public void prepareDataForCharts(@NonNull EMUStat stat, @NonNull WaterColumn waterColumn, int emuName) {
  checkNotNull(stat);
  checkNotNull(waterColumn);

  // Get the EMUs specific to this location from the water column
  List<EMUObservation> list = waterColumn.getEMUObservations(emuName);
  // The observation list should contain at least one EMUObservation!!
  // Grab the first one for now..
  if (list.size() > 0){
    EMUObservation observation = list.get(0);

    List<CombinedData> dataList = new ArrayList<>();

    dataList.add(0, buildTempData(observation, stat));
    dataList.add(1, buildSalinityData(observation,stat));
    dataList.add(2, buildOxygenData(observation,stat));
    dataList.add(3, buildNitrateData(observation,stat));
    dataList.add(4, buildPhosphateData(observation,stat));
    dataList.add(5, buildSilicateData(observation,stat));
    dataList.add(6, buildDummyDataForLegend());

    mDataList = dataList;
    double tempOfCurrentEMu = observation.getTemperature() != null ? observation.getTemperature(): 0d;
    double salinityOfcurrentEMu = observation.getSalinity() != null ? observation.getSalinity() : 0d;
    double oxygenOfCurrentEmu = observation.getOxygen() != null ? observation.getOxygen() : 0d;
    double phosphateOfCurrentEmu = observation.getPhosphate() != null ? observation.getPhosphate(): 0d;
    double silicateOfCurrentEmu = observation.getSilicate() != null ? observation.getSilicate() : 0d;
    double nitrateOfCurrentEmu = observation.getNitrate() != null ? observation.getNitrate() : 0d;

    mView.setTemperatureText(tempOfCurrentEMu);
    mView.setSalinityText(salinityOfcurrentEMu);
    mView.setOxygenText(oxygenOfCurrentEmu);
    mView.setPhosphateText(phosphateOfCurrentEmu);
    mView.setSilicateText(silicateOfCurrentEmu);
    mView.setNitrateText(nitrateOfCurrentEmu);

    mView.showChartData(mDataList);
    mView.hideProgressBar();
  }else{
    mView.hideProgressBar();
    mView.showMessage("No chart data found for layer");
  }
}
项目:xs-android-architecture    文件:MainActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mChart = (CombinedChart) findViewById(R.id.chart1);
        //描述
        mChart.getDescription().setEnabled(false);

        mChart.setBackgroundColor(Color.WHITE);

        mChart.setDrawGridBackground(false);
        mChart.setDrawBarShadow(false);
        mChart.setHighlightFullBarEnabled(false);

        mChart.setScaleEnabled(false);
        mChart.setScaleYEnabled(false);
        mChart.setScaleXEnabled(false);

        mChart.setPinchZoom(false);
//        mChart.setScaleMinima(2f, 1f);
//        mChart.setAutoScaleMinMaxEnabled(true);

        // draw bars behind lines
        mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
                CombinedChart.DrawOrder.BAR
        });

        //图例
        Legend l = mChart.getLegend();
        l.setWordWrapEnabled(true);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);


        YAxis rightAxis = mChart.getAxisRight();
        rightAxis.setEnabled(false);
        rightAxis.setAxisMinimum(0f);

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setEnabled(false);
        leftAxis.setAxisMinimum(0f);

        XAxis xAxis = mChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);
//        xAxis.setAvoidFirstLastClipping(true);
        xAxis.setAxisMinimum(0.5f);
        xAxis.setGranularity(1f);
        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                if (value % 1 == 0&&value>=1) {
                    return mMonths[(int) value % mMonths.length-1];
                } else {
                    return "";
                }
            }
        });

        CombinedData data = new CombinedData();
        data.setData(generateBarData(1f, 1f));
        xAxis.setAxisMaximum(data.getXMax() + 0.25f);

        mChart.setData(data);
        mChart.setVisibleXRange(3, 5);
        mChart.setExtraOffsets(10, 0, 0, 0);
        mChart.invalidate();

    }
项目:xs-android-architecture    文件:MainActivity2.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mChart = (CombinedChart) findViewById(R.id.chart1);
        //描述
        mChart.getDescription().setEnabled(false);

        mChart.setBackgroundColor(Color.WHITE);

        mChart.setDrawGridBackground(false);
        mChart.setDrawBarShadow(false);
        mChart.setHighlightFullBarEnabled(false);

        mChart.setScaleEnabled(false);
        mChart.setScaleYEnabled(false);
        mChart.setScaleXEnabled(false);

        mChart.setPinchZoom(false);
//        mChart.setScaleMinima(2f, 1f);
//        mChart.setAutoScaleMinMaxEnabled(true);

        // draw bars behind lines
        mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
                CombinedChart.DrawOrder.BAR
        });

        //图例
        Legend l = mChart.getLegend();
        l.setWordWrapEnabled(true);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);


        YAxis rightAxis = mChart.getAxisRight();
        rightAxis.setEnabled(false);
        rightAxis.setAxisMinimum(0f);

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setEnabled(false);
        leftAxis.setAxisMinimum(0f);

        XAxis xAxis = mChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);
//        xAxis.setAvoidFirstLastClipping(true);
        xAxis.setAxisMinimum(0.5f);
        xAxis.setGranularity(1f);
        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                if (value % 1 == 0&&value>=1) {
                    return mMonths[(int) value % mMonths.length-1];
                } else {
                    return "";
                }
            }
        });

        CombinedData data = new CombinedData();
        data.setData(generateBarData(1f, 1f));
        xAxis.setAxisMaximum(data.getXMax() + 0.25f);

        mChart.setData(data);
        mChart.setVisibleXRange(4, 6);
        mChart.setExtraOffsets(10, 0, 0, 0);
        mChart.invalidate();

    }
项目:xs-android-architecture    文件:CombinedChart.java   
@Override
public CombinedData getCombinedData() {
    return mData;
}
项目:xs-android-architecture    文件:CombinedChartActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_combined);

    mChart = (CombinedChart) findViewById(R.id.chart1);
    mChart.getDescription().setEnabled(false);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    mChart.setHighlightFullBarEnabled(false);

    // draw bars behind lines
    mChart.setDrawOrder(new DrawOrder[]{
            DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
    });

    Legend l = mChart.getLegend();
    l.setWordWrapEnabled(true);
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setDrawGridLines(false);
    leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setAxisMinimum(0f);
    xAxis.setGranularity(1f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mMonths[(int) value % mMonths.length];
        }
    });

    CombinedData data = new CombinedData();

    data.setData(generateLineData());
    data.setData(generateBarData());
    data.setData(generateBubbleData());
    data.setData(generateScatterData());
    data.setData(generateCandleData());
    data.setValueTypeface(mTfLight);

    xAxis.setAxisMaximum(data.getXMax() + 0.25f);

    mChart.setData(data);
    mChart.invalidate();
}
项目:daily-dozen-android    文件:LoadServingsHistoryCompleteEvent.java   
public LoadServingsHistoryCompleteEvent(final CombinedData chartData,
                                        final int timeScale) {
    this.chartData = chartData;
    this.timeScale = timeScale;
}
项目:daily-dozen-android    文件:LoadServingsHistoryCompleteEvent.java   
public CombinedData getChartData() {
    return chartData;
}
项目:daily-dozen-android    文件:LoadServingsHistoryTask.java   
private LoadServingsHistoryCompleteEvent createCompleteEvent(final CombinedData combinedData,
                                                             @TimeScale.Interface final int timeScale) {
    return new LoadServingsHistoryCompleteEvent(combinedData, timeScale);
}
项目:LETO-Toggl_Android    文件:CombinedChart.java   
@Override
public CombinedData getCombinedData() {
    return mData;
}
项目:gadgetbridge_artikcloud    文件:AbstractChartFragment.java   
public DefaultChartsData(CombinedData combinedData) {
    this.combinedData = combinedData;
}
项目:gadgetbridge_artikcloud    文件:AbstractChartFragment.java   
public CombinedData getCombinedData() {
    return combinedData;
}