如果在webdatarocks中将数据配置为时间,则在Excel中正确地以hh:mm:ss格式导出数据。但是,如果我们有一个计算值,它是通过将时间值除以数值(得到平均值)得到的,并且这个计算值被定义为时间,那么在web中,它以正确的格式显示,但以导出的秒表示。下面是来自webdatarocks代码页的示例,我在这里增加了AVG的新价值。它在web上显示为00:20:00,但在excel中导出为1200。
"Duration": {
type: "time"
},
"Movie Name": {
type: "string"
},
"AVG": {
type: "time"
},
"Rating": {
type: "number"
},
"Genre": {
type: "string"
}
},
{
"Movie Name": "Star Wars: The Last Jedi",
"Rating": 7.2,
"Genre": "Fantasy",
"Duration": 9120
},
{
"Movie Name": "Blade Runner 2049",
"Rating": 7.2,
"Genre": "Sci-Fi",
"Duration": 9840
},
{
"Movie Name": "Harry Potter and the Sorcerer's Stone",
"Rating": 7.6,
"Genre": "Adventure",
"Duration": 9120
},
{
"Movie Name": "Incredibles 2",
"Rating": 8.1,
"Genre": "Animation",
"Duration": 7080
},
{
"Movie Name": "Ratatouille",
"Rating": 8.0,
"Genre": "Comedy",
"Duration": 6660
},
{
"Movie Name": "Scott Pilgrim vs. the World",
"Rating": 7.5,
"Genre": "Romance",
"Duration": 6720
}
];
var pivot = new WebDataRocks({
container: "wdr-component",
toolbar: true,
report: {
dataSource: {
data: JSONData
},
"slice": {
"rows": [
{
"uniqueName": "Movie Name"
}
],
"columns": [
{
"uniqueName": "Genre"
},
{
"uniqueName": "Duration"
},
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "Rating",
"aggregation": "sum"
},
{
"uniqueName": "AVG",
"formula": "sum(\"Duration\") / sum(\"Rating\")",
"caption": "Avg"
},
],
"expands": {
"columns": [
{
"tuple": [
"Genre.Adventure"
]
},
{
"tuple": [
"Genre.Animation"
]
},
{
"tuple": [
"Genre.Comedy"
]
},
{
"tuple": [
"Genre.Fantasy"
]
}
]
}
}
}
});发布于 2022-02-10 15:52:54
目前,WebDataRocks没有提供设置导出计算度量值的时间格式的选项。
https://stackoverflow.com/questions/71032745
复制相似问题