LineChart 和 CandleStickChart 的粒度不同
The granularity between LineChart and CandleStickChart is different
我有一个需求,CandleStickChart和LineChart显示在同一个table上,但是我发现了一个问题,rendering,
LineChart 和 CandleStickChart 的 YAxis 粒度不同
Layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CandleStickChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/linechart"
android:layout_width="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_height="match_parent" />
</RelativeLayout>
LineChart和CandleStickChart的YAxis设置代码:
YAxis axisLeft = linechart.getAxisLeft();
axisLeft.setAxisMinimum(0);
axisLeft.setGranularity(1);
axisLeft.setLabelCount(7, false);
axisLeft.setDrawGridLines(false);
axisLeft.setDrawAxisLine(false);
YAxis leftAxis = candleChart.getAxisLeft();
leftAxis.setAxisMinimum(0);
leftAxis.setGranularity(1);
leftAxis.setLabelCount(7, false);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawAxisLine(false);
虽然我设置了粒度,但它不起作用。我怎样才能让它们的粒度相同?任何人的帮助将不胜感激。
而不是这个:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CandleStickChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/linechart"
android:layout_width="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_height="match_parent" />
</RelativeLayout>
使用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CombinedChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
然后查看下方 link 中的组合图表示例:
我有一个需求,CandleStickChart和LineChart显示在同一个table上,但是我发现了一个问题,rendering, LineChart 和 CandleStickChart 的 YAxis 粒度不同
Layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CandleStickChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/linechart"
android:layout_width="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_height="match_parent" />
</RelativeLayout>
LineChart和CandleStickChart的YAxis设置代码:
YAxis axisLeft = linechart.getAxisLeft();
axisLeft.setAxisMinimum(0);
axisLeft.setGranularity(1);
axisLeft.setLabelCount(7, false);
axisLeft.setDrawGridLines(false);
axisLeft.setDrawAxisLine(false);
YAxis leftAxis = candleChart.getAxisLeft();
leftAxis.setAxisMinimum(0);
leftAxis.setGranularity(1);
leftAxis.setLabelCount(7, false);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawAxisLine(false);
虽然我设置了粒度,但它不起作用。我怎样才能让它们的粒度相同?任何人的帮助将不胜感激。
而不是这个:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CandleStickChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/linechart"
android:layout_width="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_height="match_parent" />
</RelativeLayout>
使用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.my.myapplication1.MainActivity">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="400dp">
<com.github.mikephil.charting.charts.CombinedChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
然后查看下方 link 中的组合图表示例: