ZingCharts horizontal stacked histogram X-Axis tags clipped

I created a simple horizontal bar chart. Labels on the X axis are trimmed as shown in the snippet below. I need to show the full label "X Axis Row A". I tried changing the width of the chart, but that does not help. Thank!

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ZingChart</title>
</head>
<body>
<div id="chartDiv"></div>
<script src='http://cdn.zingchart.com/zingchart.min.js'></script>
<script>
var chartData={
    "type":"hbar",
    "stacked":true,
    "stack-type":"normal", // Also accepts "100%"
    "title":{
        "text":"X-Axis Row Label Cut Off Example"
    },
    "scale-x":{
        "values":["X Axis Row B","X Axis Row A"],
    },
    "scale-y":{
        "format":"%v%",
    },
    "series":[{
        "background-color":"rgb(248,51,45)",
        "text":"Negative",
        "values":[-11,-22]
    },{
        "background-color":"rgb(120,152,55)",
        "text":"Positive",
        "values":[35,45]
    }]
};
window.onload=function(){
    var x = zingchart.render({
        id:'chartDiv',
        height:200,
        width:600,
        data:chartData
    });
}
</script>

</body>
</html>
Run code
+4
source share
2 answers

So, I finally figured it out. If you use the "plotarea" key, you can specify the fields. For instance:

"plotarea":{
    "margin":"40px 20px 50px 100px"
}

Updated example below:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ZingChart</title>
</head>
<body>
<div id="chartDiv"></div>
<script src='http://cdn.zingchart.com/zingchart.min.js'></script>
<script>
var chartData={
    "type":"hbar",
    "stacked":true,
    "stack-type":"normal", // Also accepts "100%"
    "title":{
        "text":"Add Margin Example"
    },
    "plotarea": {
        "margin":"40px 20px 50px 100px"
    },
    "scale-x":{
        "values":["X Axis Row B","X Axis Row A"],
    },
    "scale-y":{
        "format":"%v%",
    },
    "series":[{
        "background-color":"rgb(248,51,45)",
        "text":"Negative",
        "values":[-11,-22]
    },{
        "background-color":"rgb(120,152,55)",
        "text":"Positive",
        "values":[35,45]
    }]
};
window.onload=function(){
    var x = zingchart.render({
        id:'chartDiv',
        height:200,
        width:600,
        data:chartData
    });
}
</script>

</body>
</html>
Run code
+4
source

. "margin": "dynamic" "plotarea". , , . http://www.zingchart.com/docs/json-attributes-syntax/graph-objects/plotarea/

ZingChart, , .

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ZingChart</title>
</head>
<body>
<div id="chartDiv"></div>
<script src='http://cdn.zingchart.com/zingchart.min.js'></script>
<script>
var chartData={
    "type":"hbar",
    "stacked":true,
    "stack-type":"normal", // Also accepts "100%"
    "title":{
        "text":"Add Margin Example",
        "adjust-layout":1
    },
    "plotarea": {
        "margin":"dynamic"
    },
    "scale-x":{
        "values":["X Axis Row B","X Axis Row A"],
    },
    "scale-y":{
        "format":"%v%",
    },
    "series":[{
        "background-color":"rgb(248,51,45)",
        "text":"Negative",
        "values":[-11,-22]
    },{
        "background-color":"rgb(120,152,55)",
        "text":"Positive",
        "values":[35,45]
    }]
};
window.onload=function(){
    var x = zingchart.render({
        id:'chartDiv',
        height:200,
        width:600,
        data:chartData
    });
}
</script>

</body>
</html>
+2

All Articles