NegativeArraySizeException将散点数据添加到CombinedChart [英] NegativeArraySizeException adding Scatter Data to a CombinedChart

查看:377
本文介绍了NegativeArraySizeException将散点数据添加到CombinedChart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MPAndriodChart,我想将多个ScatterDataSet与一个LineDataSet结合起来

I use MPAndriodChart and I want to combine multiple ScatterDataSet with one LineDataSet

CombinedChart chart = (CombinedChart) findViewById(R.id.chart);
CombinedData chartData = new CombinedData();
ScatterData scatterData = data.getScatterData();
chartData.setData(scatterData);
chartData.setData(data.getLineData());
chart.setData(chartData);
chart.invalidate();

该行工作正常,但是在ScatterData上,我得到了NegativeArraySizeException:

The Line just works fine but on the ScatterData I get a NegativeArraySizeException:

java.lang.NegativeArraySizeException: -10 
 at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesScatter(Transformer.java:110)
 at com.github.mikephil.charting.renderer.ScatterChartRenderer.drawValues(ScatterChartRenderer.java:106)
 at com.github.mikephil.charting.renderer.CombinedChartRenderer.drawValues(CombinedChartRenderer.java:95)

我传递的内容似乎是完全有效的数据:

What I pass in seems to be perfectly valid data:

[Entry, x: 5.5699 y (sum): -0.5020655, Entry, x: 4.2394395 y (sum): 0.21312527, Entry, x: 3.5619884 y (sum): 0.45908606, Entry, x: 0.64683366 y (sum): 0.13041855, Entry, x: 5.2063227 y (sum): -0.3853986, Entry, x: 4.3252435 y (sum): -0.31767017, Entry, x: 5.9881873 y (sum): 0.2213649, Entry, x: 4.0705724 y (sum): 0.28665566, Entry, x: 3.1188233 y (sum): 0.33925194, Entry, x: 4.1558833 y (sum): 0.349967, Entry, x: 5.616512 y (sum): 0.76478994, Entry, x: 3.5945375 y (sum): 0.29368117, Entry, x: 4.4086146 y (sum): 0.085573964, Entry, x: 3.894157 y (sum): 0.6461969, Entry, x: 3.2885375 y (sum): 0.9365549, Entry, x: 3.2674248 y (sum): 0.86991787, Entry, x: 6.1956058 y (sum): -0.42813104, Entry, x: 5.3698792 y (sum): -0.22390603, Entry, x: 4.403929 y (sum): 0.08022818, Entry, x: 5.3132596 y (sum): 0.022318058, Entry, x: 5.8791475 y (sum): -0.0365236, Entry, x: 2.5035682 y (sum): -0.22752166]
[Entry, x: 0.7963708 y (sum): 0.12507936, Entry, x: 1.2852284 y (sum): 0.44808355]
[Entry, x: 6.883231 y (sum): -0.15286136]
[Entry, x: 5.358568 y (sum): -0.9050642]
[Entry, x: 6.221557 y (sum): -0.87225515]
[Entry, x: 3.392378 y (sum): -0.06295807, Entry, x: 3.9897776 y (sum): 0.21555887]
[Entry, x: 1.9450009 y (sum): 0.039005354, Entry, x: 3.6542387 y (sum): 0.13659218, Entry, x: 2.7017648 y (sum): -0.532821, Entry, x: 3.6622684 y (sum): 0.6588981, Entry, x: 4.9132524 y (sum): -0.04732264]

推荐答案

在大多数情况下,NegativeArraySizeException是由MPAndroidChart库的新3.0.0-beta1版本中的未排序数据引起的.对数据进行排序应该可以解决问题.

Most of the time the NegativeArraySizeException is caused by unsorted data in the new 3.0.0-beta1 version of the MPAndroidChart library. Sorting the data should resolve the issue.

这是因为该库依赖于排序的数据来进行性能优化,因此无法与未排序的数据一起正常工作.

This is because the library relies on sorted data for performance optimizations and thus doesn't work properly with unsorted data.

这篇关于NegativeArraySizeException将散点数据添加到CombinedChart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆