2

所以,我有这个订单

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

有什么方法可以让它们按顺序显示,而不是按字母顺序显示?目前我能想到的就是给它们一个数字前缀……</p>

4

1 回答 1

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 id="wdr-component"></div>

可以将 JSON 数据替换为对您的端点的引用。似乎他们在文档中有这样的例子。

于 2021-03-04T10:41:52.657 回答