Open naq219 opened 9 years ago
If you want to make LineChartView
bigger in the sample application you better increase the weight of LineChartView
. Otherwise to use dp I would recommend you to define your own layout. I can assure you that it works.
Same issue here... what do you mean by define your own layout if you want to use dp? this is my layout file:
` <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:fillViewport="true"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.db.chart.view.LineChartView
android:id="@+id/chart1"
android:layout_width="1000dp"
android:layout_height="300dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
</LinearLayout>
</HorizontalScrollView>`
By defining his own layout I simply meant not copy pasting the sample application and expect it to work as he wanted, without understanding the layout itself.
Can you edit your message, I think something went wrong when you posted the code of or layout?
i don't know why the editor can not format my code snippet.... that is just a HorizontalScrollView
actually layout height for chart view does not work with all values .
chart disappears when i set layout_height="300dp" but works when i use 200dp!
I looked into the problem but unfortunately I still cannot understand why is it happening.
What I could observe so far is that theonDraw
method doesn't get called if values too big are defined for height or width. Checking the size of the view in onMeasure
everything seems nominal. Also onPreDrawListener
gets called and with a proper view size.
For instance, in my tests, defining the values width="996dp"
and height="171dp"
the chart is displayed without problems, increasing the width in 1dp (997dp) it's not anymore displayed.
A few more bits of information can be found in #152 . All in all, for the time being I still can't point out the root cause.
Does it occur when chart lies inside ScrollView? How about http://stackoverflow.com/questions/34374363/behavior-of-setwillnotdrawfalse ?? Maybe that's the root cause?
Don't think so, I have it under onAttachedToWindow
. But anyway, I can give it a try moving it into the constructor, not sure it will make any difference.
It didn't do the trick. :/
I've found the problem "BarChartView not displayed because it is too large to fit into a software layer (or drawing cache), needs 15913800 bytes, only 8294400 available" Not sure how to solve it. Looks like scrolling should be baked into the chart itself.
Thanks for sharing. I also think this should be the case, but I haven't had the time to look into it. Maybe someone from the thread can contribute.
@diogobernardino I temporarily solved this by setting android:layerType="software"
on the ScrollView. Animations may be not as smooth, tho, so it's only a workaround
This issue persists in v3 of the library.
i tryed your example , when set height to 300dp, it not work
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/app_background">