- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
dataset.addSeries 采用的参数如下(java.lang.Comparable key,
double[] values,
int bins,
double minimum,
double maximum)
现在,我正在尝试使用一个名为 Long[] v1
的变量在 double[] values
字段,无法弄清楚如何转换它。
最佳答案
摘自 Jon Skeet 在 How to convert array of floats to array of doubles in Java? 上的回答,我引用:
Basically something has to do the conversion of each value. There isn't an implicit conversion between the two array types because the code used to handle them after JITting would be different - they have a different element size, and the long would need a conversion whereas the double wouldn't. Compare this to array covariance for reference types, where no conversions are required when reading the data (the bit pattern is the same for a String reference as an Object reference, for example) and the element size is the same for all reference types.
In short, something will have to perform conversions in a loop. I don't know of any built-in methods to do this. I'm sure they exist in third party libraries somewhere, but unless you happen to be using one of those libraries already, I'd just write your own method.
以下是乔恩答案的改编实现,以适应您的问题:
public static double[] convertLongsToDoubles(Long[] input)
{
if (input == null)
{
return null; // Or throw an exception - your choice
}
double[] output = new double[input.length];
for (int i = 0; i < input.length; i++)
{
output[i] = input[i];
}
return output;
}
关于java - 将 dataset.addSeries 与 Long[] 值一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16092068/
好的, 我知道以前有人问过这个问题,但我仍然无法弄清楚。该图确实呈现,但在第二个事件中它不会更新。 我在highcharts中使用chart.addSeries。图表更新,但没有绘制新数据。使困惑。
我正在创建一个动态创建的图表,如果没有,则添加一个系列,如果有,则添加一个点。我收到未捕获的类型错误:无法调用未定义的方法“addSeries”。我环顾四周,找不到为什么它说该方法未定义。 $(d
例如我有一个这样的图表: $(function () { $('#KeywordTrend').highcharts({ chart:{ width:500 },
我正在使用 javascript (addSeries) 添加一个系列,当我使用较大的值执行此操作时,yaxis 不会重新缩放。 http://jsfiddle.net/7YhYT/11/ 要重现我们
本文整理了Java中org.jfree.data.xy.XYIntervalSeriesCollection.addSeries()方法的一些代码示例,展示了XYIntervalSeriesColle
本文整理了Java中org.jfree.data.xy.YIntervalSeriesCollection.addSeries()方法的一些代码示例,展示了YIntervalSeriesCollect
尝试将系列添加到 Highcharts 饼图时,仅显示系列的名称,而不显示图形本身。 如果我手动输入系列,图表会正确显示,但当它通过 .each 循环完成时,它只显示添加的系列名称。 这是我的代码:
这个问题已经有答案了: How to convert array of floats to array of doubles in Java? (3 个回答) 已关闭10 年前。 dataset.ad
本文整理了Java中org.matsim.core.utils.charts.XYLineChart.addSeries()方法的一些代码示例,展示了XYLineChart.addSeries()的具
我正在使用 afterSetExtremes 事件来检索最小和最大 x 和 y 坐标。然后,我在范围选择时添加该系列。问题是该系列在加载时不显示。最简单的解决方案是模拟范围选择在图表加载时。这可能吗?
我是一名优秀的程序员,十分优秀!