gpt4 book ai didi

javascript - 在 Android 数字上运行的 Java web 应用程序

转载 作者:行者123 更新时间:2023-11-30 00:12:03 25 4
gpt4 key购买 nike

我用 C3 js 开发了一个 java web 应用程序来绘制图形。在 C3 js 工具提示中,我尝试打印一个至少包含 4 个小数位的数字。我在多种环境、桌面和移动设备(IOS 和 Android)上测试了该应用程序,但在 Android 中,工具提示中的数字仅使用 3 个小数位打印。

这是 C3 js 用于绘制工具提示的我的 js 代码:

tooltip: {
grouped: false,
contents: function(d, defaultTitleFormat, defaultValueFormat, color) {
var $$ = this, config = $$.config, titleFormat = config.tooltip_format_title || defaultTitleFormat, nameFormat = config.tooltip_format_name
|| function(name) {
return name;
}, valueFormat = config.tooltip_format_value || defaultValueFormat, text, i, title, value, name, bgcolor;

for (i = 0; i < d.length; i++) {
if (!(d[i] && (d[i].value || d[i].value === 0))) {
continue;
}

if (!text) {
title = titleFormat ? titleFormat(d[i].x) : d[i].x;
text = "<table class='" + $$.CLASS.tooltip + "'>"
+ (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : "");
}

name = nameFormat(d[i].name);

var fundName = dojo.query('#hiddenFundName')[0].value;
var raiffeisenAcumulareFundName = 'raiffeisen acumulare';
if (fundName.toLowerCase() == raiffeisenAcumulareFundName) {
value = valueFormat(d[i].value.toLocaleString("en-US", {
minimumFractionDigits: 6
}), d[i].ratio, d[i].id, d[i].index);
} else {
value = valueFormat(d[i].value.toLocaleString("en-US", {
minimumFractionDigits: 4
}), d[i].ratio, d[i].id, d[i].index);
}
bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id);
var initialNAV = dojo.attr(query("#initialnavPU")[0], "value");
text += "<tr class='" + $$.CLASS.tooltipName + "-" + d[i].id + "'>";
text += "<td class='value'>" + '<h5>' + titleFormat(d[i].x) + '</h5>' + '<h5>Valoarea unitatii de fond: ' + value
+ '</h5>' + '<h5>Randament: ' + ((d[i].value / initialNAV - 1) * 100).toFixed(2) + '%' + '</h5></td>';
text += "</tr>";
}

return text + "</table>";
}
}

您知道为什么我的号码不符合我要打印的小数位数吗?请记住,它仅适用于 Android 操作系统。

最佳答案

尝试为工具提示添加格式选项:

tooltip: {
format: {
value: function (value) {
return d3.format('.4f')(value);
}
},
...
// your current options
}

关于javascript - 在 Android 数字上运行的 Java web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48004184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com