Zing Chart Stacked Graph

时间:2015-11-17 17:11:24

标签: html json token zingchart

我正在使用Zing Chart Stacked Bar Graph。我正在从Oracle数据库加载数据以填充图表。我有两个堆栈:打开和关闭。我想在堆栈顶部将已打开文档的数量显示为打开:已关闭(例如5:303)。我能够在单个堆栈的顶部打印数字(5在封闭栏顶部,303在打开栏的顶部)但我想在最顶部显示它们,因为如果有1打开且0关闭,数字相互重叠,无法读取。所以,我一直在查看Zing Charts提供的所有JSON令牌,而且我还没有找到一种方法来获取每个数字(值)并将它们显示在一起。

1 个答案:

答案 0 :(得分:5)

您可以通过绘图和节点索引访问节点值。例如,(%node-value)(0)(4)将为您提供第一个图上第5个节点的值。

由于堆叠条形图在技术上是2个图,因此您可以在第二个(打开)图中使用以下标记:

"text":"%node-value:(%node-value)(0)"

下面是一个实时示例 - 运行代码段以查看图表。

var myConfig = {
"graphset":[
    {
        "legend":{
            "margin-top":50,
            "background-color":"#FFFFFF",
            "border-color":"#CCCCCC",
            "shadow":false,
            "margin-right":10,
            "alpha":1
        },
        "border-color":"#cccccc",
        "series":[
            {
                "text":"Closed",
                "shadow-color":"#cccccc",
                "shadow-blur-y":1,
                "line-color":"#008000",
                "background-color":"#008000",
                "type":"bar",
                "values":[0,0,1,1,3,3,3,3,4,4],
                "shadow-alpha":1,
                "marker":{
                    "background-color-2":"#008000",
                    "background-color":"#008000"
                },
                "shadow":true,
                "background-color-2":"#008000",
                "shadow-distance":2,
                "shadow-blur-x":2
            },
            {
                "text":"Open",
                "shadow-color":"#cccccc",
                "shadow-blur-y":1,
                "line-color":"Orange",
                "background-color":"Orange",
                "type":"bar",
                "values":[3,6,8,8,83,94,96,102,297,303],
                "shadow-alpha":1,
                "marker":{
                    "background-color-2":"Orange",
                    "background-color":"Orange"
                },
                "shadow":true,
                "background-color-2":"Orange",
                "shadow-distance":2,
                "shadow-blur-x":2,
                "value-box":{
                    "font-size":14,
                    "font-color":"black",
                    "bold":true,
                    "font-family":"Consolas",
                    "placement":"top",
                    "type":"all",
                    "text":"%node-value:(%node-value)(0)"
                }
            }
        ],
        "scale-y":{
            "line-gap-size":0,
            "tick":{
                "line-gap-size":0,
                "line-color":"#cccccc",
                "line-width":1,
                "size":10
            },
            "line-color":"#cccccc",
            "bold":true,
            "item":{
                "font-size":12,
                "bold":true,
                "font-family":"Consolas",
                "color":"#333333"
            },
            "label":{
                "font-size":16,
                "margin-left":10,
                "text":"Count",
                "color":"#333333"
            },
            "line-width":2,
            "font-family":"Consolas",
            "color":"#333333"
        },
        "plotarea":{
            "margin-top":50,
            "margin-left":70,
            "margin-right":100,
            "margin-bottom":80
        },
        "scale-x":{
            "line-gap-size":0,
            "tick":{
                "line-gap-size":0,
                "line-color":"#999999",
                "line-width":1,
                "size":20
            },
            "font-size":8,
            "line-color":"#cccccc",
            "bold":true,
            "guide":{
                "line-width":1
            },
            "item":{
                "font-size":12,
                "bold":true,
                "font-family":"Consolas",
                "color":"#333333"
            },
            "label":{
                "padding-top":100,
                "font-size":16,
                "text":"Month",
                "color":"#333333"
            },
            "line-width":1,
            "font-family":"Consolas",
            "color":"#333333",
            "values":["Feb 2015","Mar 2015","Apr 2015","May 2015","Jun 2015","Jul 2015","Aug 2015","Sep 2015","Oct 2015","Nov 2015"]
        },
        "background-color":"WhiteSmoke",
        "border-width":1,
        "stacked":true,
        "lens":{
            "visible":true,
            "height":60,
            "width":60
        },
        "plot":{
            
        },
        "type":"bar",
        "title":{
            "background-color":"white",
            "border-color":"#cccccc",
            "border-width":1,
            "font-size":18,
            "bold":true,
            "text":"L2PRO-TRAVs (Updated: 17 Nov 2015, 13:08)",
            "font-family":"Consolas",
            "color":"#333333"
        }
    }
]
};
 
zingchart.render({ 
	id : 'myChart', 
	data : myConfig, 
	height: 400, 
	width: 600 
});
<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
<div id="myChart"></div>