• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingSoft Demo</title>
    
      <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
      <style></style>
    </head>
    
    <body>
      <div id='myChart'></div>
      <script>
        ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
        var series1 = [7.4, 7.1, 7.0, 6.9, 7.3, 6.5, 7.9];
        var diff1 = [1.1, 2.2, 2.1, 2.0, 2.3, 3.0, 1.1];
        var series2 = [7.4, 7.1, 7.1, 7.4, 6.3, 6.6, 7.1];
        var diff2 = [0.2, 1.7, 2.0, 1.7, 2.5, 1.5, 0.9];
    
        var addDiff = function(num, idx, arr) {
          return (num + this[idx]).toFixed(1);
        };
        var total1 = series1.map(addDiff, diff1);
        var total2 = series2.map(addDiff, diff2);
    
    
        var myConfig = {
          type: "bar",
          "background-color": "white",
          "stacked": 1,
          "plot": {
    
          },
          "scale-x": {
            "line-color": "black",
            "line-width": "1px",
            "tick": {
              "line-width": "0px"
            },
            "values": ["Question #1", "Question #2", "Question #3", "Question #4", "Question #5", "Question #6", "Question #7"],
            "guide": {
              "line-width": "0px"
            },
          },
          "scale-y": {
            "line-width": "0px",
            "guide": {
              "line-width": "1px",
              "line-style": "solid",
              "alpha": 0.1
            },
            "tick": {
              "line-width": "0px"
            }
          },
          series: [{
              values: series1,
              "stack": 1,
              "background-color": "#744e97",
              "value-box": {
                "type": "all",
                "position": "right",
                "offset-y": "20px",
                "text": "%v",
                "font-color": "white"
              }
            },
            {
              values: [1.1, 2.2, 2.1, 2.0, 2.3, 3.0, 1.1],
              "stack": 1,
              "background-color": "none",
              "border-color": "#e03314",
              "border-width": "1px",
              "line-style": "dashed",
              "data-value1": total1, //custom token array
              "value-box": {
                "type": "all",
                "position": "right",
                "text": "%data-value1", //pass the value-box the custom token so it doesn't display the difference
                "font-color": "#000"
              }
            },
            {
              values: series2,
              "stack": 2,
              "background-color": "#d297eb",
              "value-box": {
                "type": "all",
                "position": "right",
                "offset-y": "20px",
                "text": "%v",
                "font-color": "white"
              }
            },
            {
              values: [0.2, 1.7, 2.0, 1.7, 2.5, 1.5, 0.9],
              "stack": 2,
              "background-color": "none",
              "border-color": "#e03314",
              "border-width": "1px",
              "line-style": "dashed",
              "data-value2": total2, //custom token array
              "value-box": {
                "type": "all",
                "position": "right",
                "text": "%data-value2", //pass the value box the custom token so it doesn't display the difference
                "font-color": "#000"
              }
            }
          ]
        };
    
        zingchart.render({
          id: 'myChart',
          data: myConfig,
          height: 400,
          width: 700
        });
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingSoft Demo</title>
    
      <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    </head>
    
    <body>
      <div id='myChart'></div>
    </body>
    
    </html>
    
          
    var series1 = [7.4, 7.1, 7.0, 6.9, 7.3, 6.5, 7.9];
    var diff1 = [1.1, 2.2, 2.1, 2.0, 2.3, 3.0, 1.1];
    var series2 = [7.4, 7.1, 7.1, 7.4, 6.3, 6.6, 7.1];
    var diff2 = [0.2, 1.7, 2.0, 1.7, 2.5, 1.5, 0.9];
    
    var addDiff = function(num, idx, arr) {
      return (num + this[idx]).toFixed(1);
    };
    var total1 = series1.map(addDiff, diff1);
    var total2 = series2.map(addDiff, diff2);
    
    
    var myConfig = {
      type: "bar",
      "background-color": "white",
      "stacked": 1,
      "plot": {
    
      },
      "scale-x": {
        "line-color": "black",
        "line-width": "1px",
        "tick": {
          "line-width": "0px"
        },
        "values": ["Question #1", "Question #2", "Question #3", "Question #4", "Question #5", "Question #6", "Question #7"],
        "guide": {
          "line-width": "0px"
        },
      },
      "scale-y": {
        "line-width": "0px",
        "guide": {
          "line-width": "1px",
          "line-style": "solid",
          "alpha": 0.1
        },
        "tick": {
          "line-width": "0px"
        }
      },
      series: [{
          values: series1,
          "stack": 1,
          "background-color": "#744e97",
          "value-box": {
            "type": "all",
            "position": "right",
            "offset-y": "20px",
            "text": "%v",
            "font-color": "white"
          }
        },
        {
          values: [1.1, 2.2, 2.1, 2.0, 2.3, 3.0, 1.1],
          "stack": 1,
          "background-color": "none",
          "border-color": "#e03314",
          "border-width": "1px",
          "line-style": "dashed",
          "data-value1": total1, //custom token array
          "value-box": {
            "type": "all",
            "position": "right",
            "text": "%data-value1", //pass the value-box the custom token so it doesn't display the difference
            "font-color": "#000"
          }
        },
        {
          values: series2,
          "stack": 2,
          "background-color": "#d297eb",
          "value-box": {
            "type": "all",
            "position": "right",
            "offset-y": "20px",
            "text": "%v",
            "font-color": "white"
          }
        },
        {
          values: [0.2, 1.7, 2.0, 1.7, 2.5, 1.5, 0.9],
          "stack": 2,
          "background-color": "none",
          "border-color": "#e03314",
          "border-width": "1px",
          "line-style": "dashed",
          "data-value2": total2, //custom token array
          "value-box": {
            "type": "all",
            "position": "right",
            "text": "%data-value2", //pass the value box the custom token so it doesn't display the difference
            "font-color": "#000"
          }
        }
      ]
    };
    
    zingchart.render({
      id: 'myChart',
      data: myConfig,
      height: 400,
      width: 700
    });