com.github.mikephil.charting.charts.CombinedChart Java Examples

The following examples show how to use com.github.mikephil.charting.charts.CombinedChart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordGraphFragment.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addNewPitch(Entry pitch) {
    if (pitchDataSet == null || getView() == null)
        return;

    pitchData.addXValue("" + pitch.getXIndex());
    pitchDataSet.addEntry(pitch);

    genderBarData.clearValues();
    genderBarData.addDataSet(GraphLayout.getOverallRange(this.getContext(), pitchData.getXValCount()));

    CombinedChart chart = (CombinedChart) getView().findViewById(R.id.recording_chart);
    if (pitchData.getXValCount() == 1) {
        // If were starting fresh from live pitch graph we must initialize the bardata here since
        // it does not get initialized on view creation to avoid a bug with the chart library
        chartData.setData(genderBarData);
        chart.setData(chartData);
    }

    chartData.notifyDataChanged();
    chart.notifyDataSetChanged();
    chart.invalidate();
}
 
Example #2
Source File: StatisticsFragment.java    From HeartBeat with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setTouchEnabled(false);
    mChart.setDragEnabled(false);
    mChart.setScaleEnabled(false);
    mChart.setDescription("");
    mChart.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    mChart.setDrawOrder(
            new CombinedChart.DrawOrder[]{
                    CombinedChart.DrawOrder.BAR,
                    CombinedChart.DrawOrder.LINE
            });
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setValueFormatter(new IntValueFormatter());
    leftAxis.setDrawGridLines(false);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setDrawGridLines(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);
}
 
Example #3
Source File: ReportAdapter.java    From privacy-friendly-interval-timer with GNU General Public License v3.0 5 votes vote down vote up
public CombinedChartViewHolder(View itemView) {
    super(itemView);
    mChart = (CombinedChart) itemView.findViewById(R.id.chart);
    mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    mChart.getAxisRight().setEnabled(false);
    mChart.setTouchEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setPinchZoom(false);
    mChart.setDescription("");
    mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
            CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE, CombinedChart.DrawOrder.CANDLE, CombinedChart.DrawOrder.LINE, CombinedChart.DrawOrder.SCATTER
    });
}
 
Example #4
Source File: CombinedChartRenderer.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 *
 * @param chart
 * @param animator
 * @param viewPortHandler
 */
protected void createRenderers(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {

    mRenderers = new ArrayList<DataRenderer>();

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null)
                    mRenderers.add(new BarChartRenderer(chart, animator, viewPortHandler));
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null)
                    mRenderers.add(new BubbleChartRenderer(chart, animator, viewPortHandler));
                break;
            case LINE:
                if (chart.getLineData() != null)
                    mRenderers.add(new LineChartRenderer(chart, animator, viewPortHandler));
                break;
            case CANDLE:
                if (chart.getCandleData() != null)
                    mRenderers.add(new CandleStickChartRenderer(chart, animator, viewPortHandler));
                break;
            case SCATTER:
                if (chart.getScatterData() != null)
                    mRenderers.add(new ScatterChartRenderer(chart, animator, viewPortHandler));
                break;
        }
    }
}
 
Example #5
Source File: CombinedChartRenderer.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 */
public void createRenderers() {

    mRenderers.clear();

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

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null)
                    mRenderers.add(new BarChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null)
                    mRenderers.add(new BubbleChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case LINE:
                if (chart.getLineData() != null)
                    mRenderers.add(new LineChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case CANDLE:
                if (chart.getCandleData() != null)
                    mRenderers.add(new CandleStickChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case SCATTER:
                if (chart.getScatterData() != null)
                    mRenderers.add(new ScatterChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
        }
    }
}
 
Example #6
Source File: CombinedChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 */
public void createRenderers() {

    mRenderers.clear();

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

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null)
                    mRenderers.add(new BarChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null)
                    mRenderers.add(new BubbleChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case LINE:
                if (chart.getLineData() != null)
                    mRenderers.add(new LineChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case CANDLE:
                if (chart.getCandleData() != null)
                    mRenderers.add(new CandleStickChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case SCATTER:
                if (chart.getScatterData() != null)
                    mRenderers.add(new ScatterChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
        }
    }
}
 
Example #7
Source File: CombinedChartActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@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();
    }
 
Example #8
Source File: AppCombinedChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 */
public void createRenderers() {

    mRenderers.clear();

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

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null)
                    mRenderers.add(new BarChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null)
                    mRenderers.add(new BubbleChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case LINE:
                if (chart.getLineData() != null)
                    mRenderers.add(new AppLineChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case CANDLE:
                if (chart.getCandleData() != null)
                    mRenderers.add(new CandleStickChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
            case SCATTER:
                if (chart.getScatterData() != null)
                    mRenderers.add(new ScatterChartRenderer(chart, mAnimator, mViewPortHandler));
                break;
        }
    }
}
 
Example #9
Source File: CombinedChartRenderer.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 *
 * @param chart
 * @param animator
 * @param viewPortHandler
 */
protected void createRenderers(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {

    mRenderers = new ArrayList<DataRenderer>();

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null)
                    mRenderers.add(new BarChartRenderer(chart, animator, viewPortHandler));
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null)
                    mRenderers.add(new BubbleChartRenderer(chart, animator, viewPortHandler));
                break;
            case LINE:
                if (chart.getLineData() != null)
                    mRenderers.add(new LineChartRenderer(chart, animator, viewPortHandler));
                break;
            case CANDLE:
                if (chart.getCandleData() != null)
                    mRenderers.add(new CandleStickChartRenderer(chart, animator, viewPortHandler));
                break;
            case SCATTER:
                if (chart.getScatterData() != null)
                    mRenderers.add(new ScatterChartRenderer(chart, animator, viewPortHandler));
                break;
        }
    }
}
 
Example #10
Source File: CombinedChartRenderer.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 * 
 * @param chart
 * @param animator
 * @param viewPortHandler
 */
protected void createRenderers(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {

	mRenderers = new ArrayList<DataRenderer>();

	DrawOrder[] orders = chart.getDrawOrder();

	for (DrawOrder order : orders) {

		switch (order) {
		case BAR:
			if (chart.getBarData() != null)
				mRenderers.add(new BarChartRenderer(chart, animator, viewPortHandler));
			break;
		case BUBBLE:
			if (chart.getBubbleData() != null)
				mRenderers.add(new BubbleChartRenderer(chart, animator, viewPortHandler));
			break;
		case LINE:
			if (chart.getLineData() != null)
				mRenderers.add(new LineChartRenderer(chart, animator, viewPortHandler));
			break;
		case CANDLE:
			if (chart.getCandleData() != null)
				mRenderers.add(new CandleStickChartRenderer(chart, animator, viewPortHandler));
			break;
		case SCATTER:
			if (chart.getScatterData() != null)
				mRenderers.add(new ScatterChartRenderer(chart, animator, viewPortHandler));
			break;
		}
	}
}
 
Example #11
Source File: ReportAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
public CombinedChartViewHolder(View itemView) {
    super(itemView);
    mChart = (CombinedChart) itemView.findViewById(R.id.chart);
    mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    mChart.getAxisRight().setEnabled(false);
    mChart.setTouchEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setPinchZoom(false);
    mChart.setDescription("");
    mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
            CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE, CombinedChart.DrawOrder.CANDLE, CombinedChart.DrawOrder.LINE, CombinedChart.DrawOrder.SCATTER
    });
}
 
Example #12
Source File: CombinedChartRenderer.java    From iMoney with Apache License 2.0 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
	super(animator, viewPortHandler);

	createRenderers(chart, animator, viewPortHandler);
}
 
Example #13
Source File: RecordGraphFragment.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
    CombinedChart chart = (CombinedChart) view.findViewById(R.id.recording_chart);

    pitchDataSet = new LineDataSet(mListener.startingPitchEntries(), getResources().getString(R.string.progress));
    // generate x value strings
    // [1, 2, 3,... basically random numbers as the recorded pitch is based on processor speed]
    List<String> xVals = ChartData.generateXVals(0, pitchDataSet.getEntryCount());
    chartData = new CombinedData(xVals);

    pitchDataSet.setColor(getResources().getColor(R.color.canvas_dark));
    pitchDataSet.setDrawCircles(false);
    pitchDataSet.setLineWidth(2f);
    pitchDataSet.setDrawValues(false);
    pitchDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);

    pitchData = new LineData(xVals, pitchDataSet);
    chartData.setData(pitchData);

    genderBarData = new BarData(xVals, GraphLayout.getOverallRange(this.getContext(), xVals.size()));
    // Bug with chart lib that throws exception for empty bar charts so must skip adding it on init
    // if were coming from the live pitch graph.
    if (!xVals.isEmpty())
        chartData.setData(genderBarData);

    chart.setData(chartData);

    chart.setDrawValueAboveBar(false);
    chart.setDrawOrder(new CombinedChart.DrawOrder[]{
            CombinedChart.DrawOrder.BAR,
            CombinedChart.DrawOrder.BUBBLE,
            CombinedChart.DrawOrder.CANDLE,
            CombinedChart.DrawOrder.LINE,
            CombinedChart.DrawOrder.SCATTER
    });

    GraphLayout.FormatChart(chart);

    super.onViewCreated(view, savedInstanceState);
}
 
Example #14
Source File: ProgressFragment.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
    public void onViewCreated(View view, Bundle savedInstanceState)
    {
        CombinedChart chart = (CombinedChart) view.findViewById(R.id.progress_chart);
        this.recordings = new RecordingList(this.getContext());

        if (this.recordings != null)
        {
            List<String> dates = this.recordings.getDates();

            CombinedData data = new CombinedData(dates);

            LineDataSet dataSet = new LineDataSet(this.recordings.getGraphEntries(), getResources().getString(R.string.progress));
            LineData lineData = new LineData(dates, dataSet);
            BarData barData = new BarData(dates, GraphLayout.getOverallRange(this.getContext(), dates.size()));

            dataSet.setDrawCubic(true);
            dataSet.enableDashedLine(10, 10, 0);
            dataSet.setLineWidth(3f);
            dataSet.setDrawValues(false);

            dataSet.setCircleColor(getResources().getColor(R.color.canvas_dark));
            dataSet.setColor(getResources().getColor(R.color.canvas_dark));
            dataSet.setCircleSize(5f);

            dataSet.setCubicIntensity(0.05f);
            dataSet.setAxisDependency(YAxis.AxisDependency.LEFT);

            data.setData(lineData);
            data.setData(barData);
            chart.setData(data);
            GraphLayout.FormatChart(chart);

            chart.setTouchEnabled(true);
//            chart.setScaleEnabled(true);
            chart.setPinchZoom(true);
//            chart.setDoubleTapToZoomEnabled(true);

            chart.setDrawValueAboveBar(false);
            chart.setDrawOrder(new DrawOrder[]{
                    DrawOrder.BAR,
                    DrawOrder.BUBBLE,
                    DrawOrder.CANDLE,
                    DrawOrder.LINE,
                    DrawOrder.SCATTER
            });
        }

        super.onViewCreated(view, savedInstanceState);
    }
 
Example #15
Source File: CombinedChartRenderer.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = new WeakReference<Chart>(chart);
    createRenderers(chart, animator, viewPortHandler);
}
 
Example #16
Source File: CombinedChartRenderer.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);

    createRenderers(chart, animator, viewPortHandler);
}
 
Example #17
Source File: GraphsActivity.java    From your-local-weather with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initializeWeatherForecastReceiver(UpdateWeatherService.ACTION_GRAPHS_UPDATE_RESULT);
    setContentView(R.layout.activity_graphs);
    localityView = (TextView) findViewById(R.id.graph_locality);
    combinedChart = (CombinedChart) findViewById(R.id.combined_chart);
    combinedChartCard = (CardView) findViewById(R.id.combined_chart_card);
    mTemperatureChart = (LineChart) findViewById(R.id.temperature_chart);
    temperatureChartCard = (CardView) findViewById(R.id.temperature_chart_card);
    mWindChart = (LineChart) findViewById(R.id.wind_chart);
    windChartCard = (CardView) findViewById(R.id.wind_chart_card);
    mRainChart = (LineChart) findViewById(R.id.rain_chart);
    rainChartCard = (CardView) findViewById(R.id.rain_chart_card);
    mSnowChart = (LineChart) findViewById(R.id.snow_chart);
    snowChartCard = (CardView) findViewById(R.id.snow_chart_card);
    mPressureChart = (LineChart) findViewById(R.id.pressure_chart);
    pressureChartCard = (CardView) findViewById(R.id.pressure_chart_card);
    rainBarChart = (BarChart) findViewById(R.id.bar_rain_chart);
    rainBarCard = (CardView) findViewById(R.id.rain_bar_chart_card);
    snowBarChart = (BarChart) findViewById(R.id.bar_snow_chart);
    snowBarCard = (CardView) findViewById(R.id.snow_bar_chart_card);
    TextView temperatureLabel = (TextView) findViewById(R.id.graphs_temperature_label);
    temperatureLabel.setText(getString(R.string.label_temperature) +
                                     ", " +
                                    TemperatureUtil.getTemperatureUnit(this));
    TextView windLabel = (TextView) findViewById(R.id.graphs_wind_label);
    windLabel.setText(getString(R.string.label_wind) + ", " + AppPreference.getWindUnit(this));
    TextView rainLabel = (TextView) findViewById(R.id.graphs_rain_label);
    rainLabel.setText(getString(R.string.label_rain) + ", " + getString(AppPreference.getRainOrSnowUnit(this)));
    TextView snowLabel = (TextView) findViewById(R.id.graphs_snow_label);
    snowLabel.setText(getString(R.string.label_snow) + ", " + getString(AppPreference.getRainOrSnowUnit(this)));
    TextView rainBarLabel = (TextView) findViewById(R.id.graphs_bar_rain_label);
    rainBarLabel.setText(getString(R.string.label_rain) + ", " + getString(AppPreference.getRainOrSnowUnit(this)));
    TextView snowBarLabel = (TextView) findViewById(R.id.graphs_bar_snow_label);
    snowBarLabel.setText(getString(R.string.label_snow) + ", " + getString(AppPreference.getRainOrSnowUnit(this)));
    TextView pressureLabel = (TextView) findViewById(R.id.graphs_pressure_label);
    pressureLabel.setText(getString(R.string.label_pressure) + ", " + AppPreference.getPressureUnit(this));
    visibleGraphs = AppPreference.getGraphsActivityVisibleGraphs(this);
    combinedGraphValues = AppPreference.getCombinedGraphValues(this);
    forecastType = (Switch) findViewById(R.id.forecast_forecastType);

    forecastType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AppPreference.setForecastType(getBaseContext(), isChecked ? 2 : 1);
            updateUI();
        }
    });
    updateUI();
    android.support.v4.widget.NestedScrollView mRecyclerView = (android.support.v4.widget.NestedScrollView) findViewById(R.id.graph_scroll_view);
    mRecyclerView.setOnTouchListener(new ActivityTransitionTouchListener(
            WeatherForecastActivity.class,
            null, this));
}
 
Example #18
Source File: AppCombinedChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
public AppCombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = new WeakReference<Chart>(chart);
    createRenderers();
}
 
Example #19
Source File: CombinedChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = new WeakReference<Chart>(chart);
    createRenderers();
}
 
Example #20
Source File: CombinedChartRenderer.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = new WeakReference<Chart>(chart);
    createRenderers();
}
 
Example #21
Source File: MyCombinedChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void createRenderers() {

    mRenderers.clear();

    CombinedChart chart = (CombinedChart) mChart.get();
    if (chart == null) {
        return;
    }

    CombinedChart.DrawOrder[] orders = chart.getDrawOrder();

    for (CombinedChart.DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null) {
                    mRenderers.add(new TimeBarChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null) {
                    mRenderers.add(new BubbleChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case LINE:
                if (chart.getLineData() != null) {
                    mRenderers.add(new LineChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case CANDLE:
                if (chart.getCandleData() != null) {
                    mRenderers.add(new MyCandleStickChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case SCATTER:
                if (chart.getScatterData() != null) {
                    mRenderers.add(new ScatterChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            default:
                break;
        }
    }
}
 
Example #22
Source File: MyCombinedChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
public MyCombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(chart, animator, viewPortHandler);
}
 
Example #23
Source File: CombinedChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
/**
 * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into
 * consideration.
 */
public void createRenderers() {

    mRenderers.clear();

    CombinedChart chart = (CombinedChart) mChart.get();
    if (chart == null) {
        return;
    }

    DrawOrder[] orders = chart.getDrawOrder();

    for (DrawOrder order : orders) {

        switch (order) {
            case BAR:
                if (chart.getBarData() != null) {
                    mRenderers.add(new BarChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case BUBBLE:
                if (chart.getBubbleData() != null) {
                    mRenderers.add(new BubbleChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case LINE:
                if (chart.getLineData() != null) {
                    mRenderers.add(new LineChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case CANDLE:
                if (chart.getCandleData() != null) {
                    mRenderers.add(new CandleStickChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
            case SCATTER:
                if (chart.getScatterData() != null) {
                    mRenderers.add(new ScatterChartRenderer(chart, mAnimator, mViewPortHandler));
                }
                break;
        }
    }
}
 
Example #24
Source File: CombinedChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = new WeakReference<Chart>(chart);
    createRenderers();
}
 
Example #25
Source File: GraphUtils.java    From your-local-weather with GNU General Public License v3.0 4 votes vote down vote up
public static Bitmap getCombinedChart(Context context,
                                      int widgetId,
                                      Float heightMultiplier,
                                      List<DetailedWeatherForecast> weatherForecastList,
                                      long locationId,
                                      Locale locale) {

    if (combinedGraphs.get(widgetId) != null) {
        return combinedGraphs.get(widgetId);
    }

    WidgetSettingsDbHelper widgetSettingsDbHelper = WidgetSettingsDbHelper.getInstance(context);
    Boolean showLegend = widgetSettingsDbHelper.getParamBoolean(widgetId, "combinedGraphShowLegend");

    if (showLegend == null) {
        showLegend = true;
    }

    int[] size = getWidgetSize(context, widgetId);
    int width = size[0];
    int height;
    if (heightMultiplier == null) {
        height = size[1];
    } else {
        height = (int) (width * heightMultiplier);
    }

    int yAxisValues = 4;
    if (height > 800) {
        yAxisValues += 6;
    } else if (height > 700) {
        yAxisValues += 4;
    } else if (height > 500) {
        yAxisValues += 2;
    }

    CombinedChart combinedChart = generateCombinedGraph(context,
                                null,
                                                        getCombinedGraphValuesFromSettings(context, widgetSettingsDbHelper, widgetId),
                                                        weatherForecastList,
                                                        locationId,
                                                        locale,
                                                        18f,
                                                        yAxisValues,
                                                        0,
                                                        AppPreference.getTextColor(context),
                                                        AppPreference.getWidgetBackgroundColor(context),
                                                        AppPreference.getWidgetGraphGridColor(context),
                                                        showLegend);

    combinedChart.setBackgroundColor(ContextCompat.getColor(context,
            R.color.widget_transparentTheme_colorBackground));

    int bitmapHeight = height;

    if (!showLegend) {
        bitmapHeight += 20;
    }

    Bitmap.Config bitmapConfig = Bitmap.Config.ARGB_8888;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        bitmapConfig = Bitmap.Config.RGBA_F16;
    }
    Bitmap combinedChartBitmap = Bitmap.createBitmap(width, bitmapHeight, bitmapConfig);
    Canvas combinedChartCanvas = new Canvas(combinedChartBitmap);
    combinedChart.layout(0, 0, width, height);
    combinedChart.draw(combinedChartCanvas);
    combinedGraphs.put(widgetId, combinedChartBitmap);
    return combinedChartBitmap;
}