WebDataRocks 动态枢轴订单
WebDataRocks Pivot Order Dinamclly
所以,我有这个订单
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
有什么方法可以让它们按那个顺序显示,而不是按字母顺序显示?我现在能想到的就是给他们一个数字前缀…
我觉得配置slice的时候用“sort”可以解决属性。您需要在报告 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 id="wdr-component"></div>
可以用对端点的引用替换 JSON 数据。似乎他们在文档中有这样的例子。
所以,我有这个订单
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
有什么方法可以让它们按那个顺序显示,而不是按字母顺序显示?我现在能想到的就是给他们一个数字前缀…
我觉得配置slice的时候用“sort”可以解决属性。您需要在报告 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 id="wdr-component"></div>
可以用对端点的引用替换 JSON 数据。似乎他们在文档中有这样的例子。