I want that my chart has two YAxis with different scales like the image . How I can change the scale for each axis?

Version 2.0.0-beta was released over the weekend with a CombinedChart, which allows plotting Line-, Bar-, Scatter- and CandleData in one chart. So the feature is finally available.
One note about what I found during my upgrade, you can't simply addDataSet() for each one, you have to generate the individual DataSet types (Bar, Line, Scatter, etc) and then use SetData() for the appropriate type, to trigger rendering.
Here is the example code.
The author of MPAndroidChart library clearly specifies here, (MPChart - Scatter Chart and LineChart in same plot), that this function is not yet available. So, I am also looking for a nicer approach.
As such, you can display two different chart types as one, still using this library, only by overlapping them.
I have done this on my side as it follows:
1. Edit the activity layout xml, having a FrameLayout as charts container.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
.......
<FrameLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/root_view">
</FrameLayout>
.......
</LinearLayout>
// construct the charts, as different objects
// make sure to have valid Data Sets
LineChartItem lineChart = new LineChartItem(lineChartDataset, getApplicationContext());
BarChartItem barChart = new BarChartItem(barChartDataset, getApplicationContext());
// get the charts' container
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.root_view);
// populate the container with the charts' views
frameLayout.addView(lineChart.getView(0, null, getApplicationContext()));
frameLayout.addView(barChart.getView(1, null, getApplicationContext()));
PROs/CONs for such a practice:
PROs
I hope for a quick release of this great lib having this option. Thank you in advance Philipp Jahoda!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With