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

The following examples show how to use com.github.mikephil.charting.charts.CombinedChart.DrawOrder. 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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: CombinedChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 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);

    setTitle("CombinedChartActivity");

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

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

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

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

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

    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setAxisMinimum(0f);
    xAxis.setGranularity(1f);
    xAxis.setValueFormatter(new ValueFormatter() {
        @Override
        public String getFormattedValue(float value) {
            return months[(int) value % months.length];
        }
    });

    CombinedData data = new CombinedData();

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

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

    chart.setData(data);
    chart.invalidate();
}
 
Example #10
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);
    }