Newer
Older
ondotori / index.html
<html>
<head>
    <meta charset="utf-8">
    <style type="text/css">
    </style>
    <script src="./amcharts/amcharts.js"></script>
    <script src="./amcharts/serial.js"></script>
    <script src="mergeddata.json"></script>
</head>
<body>
    <div id="tempdiv" style="width: 100%; height:50%"></div>
    <div id="humiddiv" style="width: 100%; height:50%"></div>
    <script>
    var tempchart= AmCharts.makeChart("tempdiv", {
		    "type": "serial",
		    "dataProvider": data,
		    "categoryField": "datetime",
		    "chartScrollbar": {
		      "autoGridCount": true,
		      "graph": "tempscale",
		      "selectedGraphLineAlpha": 1,
		      "selectedGraphFillAlpha": 0,
		      "selectedBackgroundColor": "#c0d0e0",
		      "graphLineAlpha": 1,
		      "graphFillAlpha": 0,
		      "scrollbarHeight": 30
		    },
		    "categoryAxis": {
		      "parseDates": true,
		      "minPeriod": "mm",
              "labelsEnabled": false,
		    },
            "listeners": [{
                "event": "zoomed",
                "method": syncZoom
	    }, {
		"event": "init",
		"method": 
		function() {
		    today = new Date();
		    tempchart.zoomToDates(new Date(today.getTime() - 7*24*3600*1000), today);
		}
    	    }
			],
		    "chartCursor": {
              "listeners": [{
                  "event": "changed",
                  "method": syncCursors
              }, {
                  "event": "onHideCursor",
                  "method": hideCursors
              }],
              "oneBalloonOnly": true,
		      "cursorPosition": "mouse",
		      "valueLineEnabled": true,
		      "categoryBalloonEnabled": false,
		      "valueBalloonFormat": "%d"
		    },
		    "mouseWheelZoomEnabled": true,
		    "legend": {
			    "valueText": "[[value]]℃",
			    "position": "left"
		    },
		    /*
    # group : I->ist, R->HSJ-R, L->HSJ-L, O->outside, H->kousaku, F->field-Lab
    {   title => 'out', dir   => '8', # sensor no.  group => 'O', },
    {   title => 'out2', dir   => '20', group => 'O', },
    {   title => 'win', dir   => '15', group => 'O', },
    {   title => 'ent', dir   => '1', group => 'H', },
    {   title => '3D', dir   => '6', group => 'H', },
    {   title => 'fun', dir   => '7', group => 'H', },
    {   title => 'RF', dir   => '5', group => 'R', },
    {   title => 'RC', dir   => '10', group => 'R', },
    {   title => 'RB', dir   => '4', group => 'R', },
    {   title => 'LF', dir   => '3', group => 'L', },
    {   title => 'LC', dir   => '9', group => 'L', },
    {   title => 'LB', dir   => '2', group => 'L', },
    {   title => 'GRL', dir   => '14', group => 'I', },
    {   title => 'ML1', dir   => '13', group => 'I', },
    {   title => 'ML2', dir   => '12', group => 'I', },
    {   title => 'F1', dir   => '18', group => 'F', },
    {   title => 'F2', dir   => '17', group => 'F', },
    {   title => 'F3', dir   => '16', group => 'F', },
    {   title => 'ist', dir   => '11', group => 'I', },
    {   title => 'SRV', dir   => '19', group => 'I', }, */
		    "graphs": [
		    {"type":"line", "valueField": "temp-1", "title": "01 ent H",
			    "balloonText": "<b>01: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-2", "title": "02 LB L",
			    "balloonText": "<b>02: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-4", "title": "04 RB R",
			    "balloonText": "<b>04: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-11", "title": "11 ist準備",
			    "balloonText": "<b>11: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-12", "title": "12 ML2",
			    "balloonText": "<b>12: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-13", "title": "13 ML1",
			    "balloonText": "<b>13: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-14", "title": "14 GRL",
			    "balloonText": "<b>14: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-19", "title": "19 srv I",
			    "balloonText": "<b>19: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-16", "title": "16 領域3 F",
			    "balloonText": "<b>16: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-17", "title": "17 領域2 F",
			    "balloonText": "<b>17: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-18", "title": "18 領域1 F",
			    "balloonText": "<b>18: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-15", "title": "15 win O",
			    "balloonText": "<b>15: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-8", "title": "08 out",
			    "balloonText": "<b>08 out: [[value]]℃</b>", },
		    {"type":"line", "valueField": "temp-20",
			    "balloonText": "<b>20 out: [[value]]℃</b>",
			    "title": "20 out", "id": "tempscale" },
		    ]
	    });

    var humidchart = AmCharts.makeChart("humiddiv", {
		    "type": "serial",
		    "dataProvider": data,
		    "categoryField": "datetime",
            "valueAxis": {
	        "maximum": "99",
                "ignoreAxisWidth": true
            },
            "listeners": [{
                "event": "zoomed",
                "method": syncZoom
	    }, {
		"event": "init",
		"method": 
		function() {
		    today = new Date();
		    humidchart.zoomToDates(new Date(today.getTime() - 7*24*3600*1000), today);
		}
    	    }
            ],
		    "chartCursor": {
              "oneBalloonOnly": true,
		      "cursorPosition": "mouse",
		      "valueLineEnabled": true,
		      "categoryBalloonDateFormat": "MMM DD, YYYY JJ:NN",
              "listeners": [{
                  "event": "changed",
                  "method": syncCursors
              }, {
                  "event": "onHideCursor",
                  "method": hideCursors
              }]
		    },
		    "categoryAxis": {
		      "parseDates": true,
		      "minPeriod": "mm",
		      "labelRotation": 25
		    },
		    "mouseWheelZoomEnabled": true,
		    "legend": {
			    "valueText": "[[value]]%",
			    "position": "left"
		    },
		    "graphs": [
		      {"type":"line", "valueField": "humid-1", "title": "01 ent H",
			    "balloonText": "<b>01: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-2", "title": "02 LB L",
			    "balloonText": "<b>02: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-4", "title": "04 RB R",
			    "balloonText": "<b>04: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-11", "title": "11 ist",
			    "balloonText": "<b>11: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-12", "title": "12 ML2",
			    "balloonText": "<b>12: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-13", "title": "13 ML1",
			    "balloonText": "<b>13: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-14", "title": "14 GRL",
			    "balloonText": "<b>14: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-19", "title": "19 srv I",
			    "balloonText": "<b>19: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-16", "title": "16 領域3 F",
			    "balloonText": "<b>16: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-17", "title": "17 領域2 F",
			    "balloonText": "<b>17: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-18", "title": "18 領域1 F",
			    "balloonText": "<b>18: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-15", "title": "15 win O",
			    "balloonText": "<b>15: [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-8", "title": "08 out",
			    "balloonText": "<b>08 out : [[value]]%</b>"},
		      {"type":"line", "valueField": "humid-20",
			    "balloonText": "<b>20 out: [[value]]%</b>",
			      "title": "20 out", "id": "humidscale"
		       },
		    ]
	    });

    function syncCursors(e) {
        if(tempchart !== e.chart) {
          tempchart.chartCursor.syncWithCursor(e.chart.chartCursor);
        } else {
          humidchart.chartCursor.syncWithCursor(e.chart.chartCursor);
        }
    }

    function hideCursors(e) {
        if(tempchart !== e.chart) {
            tempchart.chartCursor.hideCursor();
            tempchart.chartCursor.clearSelection();
        } else {
            humidchart.chartCursor.hideCursor();
            humidchart.chartCursor.clearSelection();
        }
    }

    function syncZoom(e) {
        if (e.chart.ignoreZoom) {
		e.chart.ignoreZoom = false;
		return;
        }
        if(tempchart !== e.chart) {
            tempchart.ignoreZoom = true;
            tempchart.zoomToDates(e.startDate, e.endDate);
        } else {
            humidchart.ignoreZoom = true;
            humidchart.zoomToDates(e.startDate, e.endDate);
        }
    }
    </script>
</body>
</html>