• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingSoft Demo</title>
      <script nonce="undefined" src='http://cdn.zingchart.com/zingchart.min.js'></script>
      <script nonce="undefined">
        zingchart.MODULESDIR = 'http://cdn.zingchart.com/modules/'
      </script>
      <script nonce="undefined" src='http://code.jquery.com/jquery-1.11.3.js'></script>
    
      <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
      <style></style>
    </head>
    
    <body>
      <button onclick="generateRequest(0)">Start Feed</button>
      <div id='myChart'></div>
      <script>
        ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
        var myJson = {};
        var sourceUrls = ['http://beta.json-generator.com/api/json/get/MepQs3G', 'http://beta.json-generator.com/api/json/get/C528ygE'];
    
        function generateRequest(sourceToUse) {
          sourceUrl = sourceUrls[sourceToUse];
          $.getJSON(sourceUrl, function(data) {
            //Empty object to hold our data
            var dataObj = {
              date: [],
              sensorA_1: [],
              sensorA_2: [],
              sensorA_3: [],
              sensorB_1: [],
              sensorB_2: [],
              sensorB_3: []
            };
            for (var n = 0; n < data.length; n++) {
              dataObj.date.push((new Date(data[n]['Time'])).getTime());
              dataObj.date.sort();
              dataObj.sensorA_1.push(data[n]['SensorA']['Value1']);
              dataObj.sensorA_2.push(data[n]['SensorA']['Value2']);
              dataObj.sensorA_3.push(data[n]['SensorA']['Value3']);
              dataObj.sensorB_1.push(data[n]['SensorB']['Value1']);
              dataObj.sensorB_2.push(data[n]['SensorB']['Value2']);
              dataObj.sensorB_3.push(data[n]['SensorB']['Value3']);
            }
            for (var i = 0; i < 6; i++) {
              zingchart.exec('myChart', 'modify', {
                update: false,
                data: {
                  "scale-x": {
                    "values": dataObj.date
                  }
                }
              });
              zingchart.exec('myChart', 'setseriesvalues', {
                update: false,
                graphid: i,
                values: [dataObj[Object.keys(dataObj)[(i + 1)]]]
              });
            }
            zingchart.exec('myChart', 'update');
            if (sourceToUse == 0) {
              window.setTimeout(generateRequest(1), 1000);
            } else {
              window.setTimeout(generateRequest(0), 1000);
            }
    
          });
        }
    
        var myJson = {
          "layout": "2x3",
          "graphset": [{
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor A - 1"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorA_1
              }]
            },
            {
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor A - 2"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorA_2
              }]
            },
            {
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor A - 3"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorA_3
              }]
            },
            {
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor B - 1"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorB_1
              }]
            },
            {
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor B - 2"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorB_2
              }]
            },
            {
              "title": {
                "background-color": "none",
                "color": "black",
                "text": "Sensor B - 3"
              },
              "background-color": "none",
              "plot": {
                "line-width": 1,
                "marker": {
                  "visible": false
                }
              },
              "type": "line",
              "scale-x": {
                //"values":dataObj.date,
                "transform": {
                  "type": "date",
                  "item": {
                    "visible": false
                  }
                }
              },
              "series": [{
                "values": []
                //"values": dataObj.sensorB_3
              }]
            }
          ]
        };
        zingchart.render({
          id: 'myChart',
          data: myJson,
          height: 600,
          width: 1400
        });
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingSoft Demo</title>
      <script src='http://cdn.zingchart.com/zingchart.min.js'></script>
      <script>
        zingchart.MODULESDIR = 'http://cdn.zingchart.com/modules/'
      </script>
      <script src='http://code.jquery.com/jquery-1.11.3.js'></script>
    
      <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    </head>
    
    <body>
      <button onclick="generateRequest(0)">Start Feed</button>
      <div id='myChart'></div>
    </body>
    
    </html>
    
          
    var myJson = {};
    var sourceUrls = ['http://beta.json-generator.com/api/json/get/MepQs3G', 'http://beta.json-generator.com/api/json/get/C528ygE'];
    
    function generateRequest(sourceToUse) {
      sourceUrl = sourceUrls[sourceToUse];
      $.getJSON(sourceUrl, function(data) {
        //Empty object to hold our data
        var dataObj = {
          date: [],
          sensorA_1: [],
          sensorA_2: [],
          sensorA_3: [],
          sensorB_1: [],
          sensorB_2: [],
          sensorB_3: []
        };
        for (var n = 0; n < data.length; n++) {
          dataObj.date.push((new Date(data[n]['Time'])).getTime());
          dataObj.date.sort();
          dataObj.sensorA_1.push(data[n]['SensorA']['Value1']);
          dataObj.sensorA_2.push(data[n]['SensorA']['Value2']);
          dataObj.sensorA_3.push(data[n]['SensorA']['Value3']);
          dataObj.sensorB_1.push(data[n]['SensorB']['Value1']);
          dataObj.sensorB_2.push(data[n]['SensorB']['Value2']);
          dataObj.sensorB_3.push(data[n]['SensorB']['Value3']);
        }
        for (var i = 0; i < 6; i++) {
          zingchart.exec('myChart', 'modify', {
            update: false,
            data: {
              "scale-x": {
                "values": dataObj.date
              }
            }
          });
          zingchart.exec('myChart', 'setseriesvalues', {
            update: false,
            graphid: i,
            values: [dataObj[Object.keys(dataObj)[(i + 1)]]]
          });
        }
        zingchart.exec('myChart', 'update');
        if (sourceToUse == 0) {
          window.setTimeout(generateRequest(1), 1000);
        } else {
          window.setTimeout(generateRequest(0), 1000);
        }
    
      });
    }
    
    var myJson = {
      "layout": "2x3",
      "graphset": [{
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor A - 1"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorA_1
          }]
        },
        {
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor A - 2"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorA_2
          }]
        },
        {
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor A - 3"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorA_3
          }]
        },
        {
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor B - 1"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorB_1
          }]
        },
        {
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor B - 2"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorB_2
          }]
        },
        {
          "title": {
            "background-color": "none",
            "color": "black",
            "text": "Sensor B - 3"
          },
          "background-color": "none",
          "plot": {
            "line-width": 1,
            "marker": {
              "visible": false
            }
          },
          "type": "line",
          "scale-x": {
            //"values":dataObj.date,
            "transform": {
              "type": "date",
              "item": {
                "visible": false
              }
            }
          },
          "series": [{
            "values": []
            //"values": dataObj.sensorB_3
          }]
        }
      ]
    };
    zingchart.render({
      id: 'myChart',
      data: myJson,
      height: 600,
      width: 1400
    });