WebDataRocksPivotOrderDinamclly
所以,我有这个订单
Green,0,0,0,0,0,0
Black,0,0,0,0,0,0
Red,0,0,0,0,0,0,0
Blue,0,0,0,0,0,0,0
当生成 webdatarocks 显示
Blue,0,0,0,0,0,0,0
Black,0,0,0,0,0,0
Green,0,0,0,0,0,0
Red,0,0,0,0,0,0,0
有什么方法可以让它们按该顺序显示,而不是按字母顺序显示?目前我能想到的就是给他们一个数字前缀......
回答
我认为在配置切片时可以通过“排序”属性来解决。您需要在报告 JSON 对象中预定义它。我在示例中使用了 JSON 数据:
const pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
width: "100%",
height: 300,
report: {
"dataSource": {
"dataSourceType": "json",
"data": [{
"Color": "Green",
"Data1": -1,
"Data2": 0,
"Data3": 0
},
{
"Color": "Black",
"Data1": 0,
"Data2": 0,
"Data3": 0
},
{
"Color": "Red",
"Data1": 0,
"Data2": 0,
"Data3": 0
},
{
"Color": "Blue",
"Data1": 0,
"Data2": 0,
"Data3": 0
}]
},
"slice": {
"rows": [
{
"uniqueName": "Color",
"sort": "unsorted"
},
{
"uniqueName": "Data2"
},
{
"uniqueName": "Data3"
}
],
"columns": [
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "Data1",
"aggregation": "sum"
}
],
"flatOrder": [
"Color",
"Data1",
"Data2",
"Data3"
]
},
"options": {
"grid": {
"type": "flat",
"showGrandTotals": "off"
}
}
}
}
);
<link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet"/>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<div></div>
可以使用对端点的引用替换 JSON 数据。似乎他们在文档中有这样的例子。