Advertisement
Guest User

Untitled

a guest
Feb 6th, 2013
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <title>test</title>
  4. <script type="text/javascript" src="highchart/jquery-1.9.0.min.js"></script>
  5. <script type="text/javascript" src="highchart/highcharts.js"></script>
  6. <script type="text/javascript" src="highchart/highcharts-more.js"></script>
  7. <script type="text/javascript" src="livedata.php"></script>
  8. <script type="text/javascript">
  9. $(function () {
  10.     var langWindDir = new Array("N", "NNE", "NE", "ENE","E", "ESE", "SE", "SSE","S", "SSW", "SW", "WSW","W", "WNW", "NW", "NNW");
  11.     function windDirLang ($winddir)
  12.     {
  13.         /* return langWindDir[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];*/
  14.         return langWindDir[Math.floor(((parseInt($winddir) + 11.25) / 22.5))];
  15.     }
  16.     var chart = new Highcharts.Chart({
  17.         chart: {
  18.             renderTo: 'container',
  19.             type: 'gauge',
  20.             plotBackgroundColor: null,
  21.             plotBackgroundImage: null,
  22.             plotBorderWidth: 0,
  23.             plotShadow: false
  24.         },
  25.         title: {
  26.             text: 'Wind Direction'
  27.         },
  28.         credits: {
  29.                 enabled: false
  30.         },
  31.         pane: {
  32.             /* startAngle: -180, */
  33.             /* endAngle: 180, */
  34.             background: [{
  35.                 backgroundColor: {
  36.                     linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
  37.                     stops: [
  38.                         [0, '#FFF'],
  39.                         [1, '#333']
  40.                     ]
  41.                 },
  42.                 borderWidth: 0,
  43.                 outerRadius: '109%'
  44.             }, {
  45.                 backgroundColor: {
  46.                     linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
  47.                     stops: [
  48.                         [0, '#333'],
  49.                         [1, '#FFF']
  50.                     ]
  51.                 },
  52.                 borderWidth: 1,
  53.                 outerRadius: '107%'
  54.             }, {
  55.                 // default background
  56.             }, {
  57.                 backgroundColor: '#DDD',
  58.                 borderWidth: 0,
  59.                 outerRadius: '105%',
  60.                 innerRadius: '103%'
  61.             }]
  62.         },
  63.         // the value axis
  64.         yAxis: {
  65.             min: 0,
  66.             max: 360,
  67.            
  68.             /* minorTickInterval: 'auto',
  69.             minorTickWidth: 1,
  70.             minorTickLength: 10,
  71.             minorTickPosition: 'inside',
  72.             minorTickColor: '#666', */
  73.    
  74.             tickPixelInterval: 30,
  75.             tickWidth: 2,
  76.             tickPosition: 'inside',
  77.             tickLength: 3,
  78.             tickColor: '#666',
  79.             labels: {
  80.                 step: 2,
  81.                 rotation: 'auto',
  82.                 formatter:
  83.                 function() {
  84.                     return windDirLang(this.value);
  85.                 },
  86.             },
  87.             /* title: {
  88.                 text: 'km/h'
  89.             }, */
  90.             /* plotBands: [{
  91.                 from: 0,
  92.                 to: 60,
  93.                 color: '#55BF3B' // green
  94.             }, {
  95.                 from: 60,
  96.                 to: 80,
  97.                 color: '#DDDF0D' // yellow
  98.             }, {
  99.                 from: 80,
  100.                 to: 180,
  101.                 color: '#DF5353' // red
  102.             }] */      
  103.         },
  104.         series: [{
  105.             name: 'Dir',
  106.             data: [0],
  107.             tooltip: {
  108.                 /* valueSuffix: ' km/h' */
  109.                 enabled: false
  110.             }
  111.         }]
  112.     },
  113.     function (chart) {
  114.         setInterval(function() {
  115.         $(function() {
  116.         $.getJSON('livedata.php', function(data) {
  117.             $.each(data, function(key,val) {
  118.             if (key == 'WindDir')
  119.             {
  120.                 var point = chart.series[0].points[0];
  121.                 point.update(val);
  122.             }
  123.             });
  124.         });
  125.         })
  126.     },2000)
  127.     })
  128. });
  129. </script>
  130. </head>
  131. <body>
  132. <div id="container" style="width: 250px; height: 250px; margin: 0 auto"></div>
  133. </body>
  134. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement