hellocharts-android icon indicating copy to clipboard operation
hellocharts-android copied to clipboard

当折线图所有数据都是0的时候会没有显示

Open twp520 opened this issue 8 years ago • 3 comments

当折线图的数据全是0的时候,折线图会消失,这个问题怎么解决?

twp520 avatar Sep 12 '16 02:09 twp520

Hi, I'm not sure if I understand. Maybe the same case as in #143 and #169. Try to use custom viewport.

lecho avatar Sep 18 '16 18:09 lecho

请问这个问题解决了吗?

wwfighting avatar May 26 '17 07:05 wwfighting

var vp = Viewport().apply { for (line in data.lines) { for (value in line.values) { if (value.x < left) { left = value.x } if (value.x > right) { right = value.x } if (value.y < bottom) { bottom = value.y } if (value.y > top) { top = value.y } } } if(top == bottom){ if(top == 0f){ top = 1f }else{ top *= 2 } bottom = 0f } } lineChart.lineChartData = data lineChart.resetViewports() lineChart.maximumViewport = vp lineChart.currentViewport = vp

出现此种问题主要是因为Y轴所有值相同时候,设定的 maximumViewport 的top 和bottom 都一样导致绘制不出折线,所以需要先 resetViewports(),然后在赋值,亲测可行

xiaodxs avatar Nov 20 '18 06:11 xiaodxs