Advertisement
Guest User

Untitled

a guest
Feb 13th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Highcharts.setOptions({
  2. colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
  3.         "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
  4.     chart: {
  5.         backgroundColor: '#ffffff',
  6.         borderColor: '#353028',
  7.         borderWidth: 1,
  8.         borderRadius: 5,
  9.         plotBackgroundColor: null,
  10.         plotShadow: false,
  11.         plotBorderWidth: 0,
  12.         margin: [50, 30, 60, 40],
  13.         style: {
  14.             zIndex: 1
  15.         }
  16.     },
  17.     title: {
  18.         style: {
  19.             color: '#FFF',
  20.             font: '14px Open Sans, sans-serif',
  21.             textShadow: 'none'
  22.         }
  23.     },
  24.     subtitle: {
  25.         style: {
  26.             color: '#DDD',
  27.             font: '12px Open Sans, sans-serif',
  28.             textShadow: 'none'
  29.         }
  30.     },
  31.     xAxis: {
  32.         gridLineWidth: 0,
  33.         lineColor: '#999',
  34.         tickColor: '#999',
  35.         labels: {
  36.             style: {
  37.                 color: '#999',
  38.                 fontWeight: 'bold'
  39.             }
  40.         },
  41.         title: {
  42.             style: {
  43.                 color: '#AAA',
  44.                 font: 'bold 12px Open Sans, sans-serif'
  45.             }                
  46.         }
  47.     },
  48.     yAxis: {
  49.         alternateGridColor: null,
  50.         minorTickInterval: null,
  51.         gridLineColor: '#eeeeec',
  52.         lineWidth: 0,
  53.         tickWidth: 0,
  54.         labels: {
  55.             style: {
  56.                 color: '#999',
  57.                 fontWeight: 'bold'
  58.             }
  59.         },
  60.         title: {
  61.             text: null            
  62.         }
  63.     },
  64.     legend: {
  65.         //layout: 'vertical',
  66.         borderWidth: 1,
  67.         backgroundColor: '#625E56',
  68.         shadow: false,
  69.         symbolWidth: 16,
  70.         itemStyle: {
  71.             color: '#CCC'
  72.         },
  73.         itemHoverStyle: {
  74.             color: '#FFF'
  75.         },
  76.         itemHiddenStyle: {
  77.             color: '#333'
  78.         }
  79.     },
  80.     credits: {
  81.         enabled: false
  82.     },
  83.     labels: {
  84.         style: {
  85.             color: '#CCC'
  86.         }
  87.     },
  88.     tooltip: {
  89.         backgroundColor: {
  90.             linearGradient: [0, 0, 0, 50],
  91.             stops: [
  92.                 [0, 'rgba(66, 60, 50, .9)'],
  93.                 [1, 'rgba(29, 27, 21, .8)']
  94.             ]
  95.         },
  96.         borderWidth: 0,
  97.         style: {
  98.             color: '#FFF',
  99.             font: '12px Open Sans, sans-serif'
  100.         }
  101.     },
  102.    
  103.    
  104.     plotOptions: {
  105.         line: {
  106.             dataLabels: {
  107.                 color: '#CCC'
  108.             },
  109.             marker: {
  110.                 lineColor: '#333'
  111.             }
  112.         },
  113.         spline: {
  114.             marker: {
  115.                 lineColor: '#333'
  116.             }
  117.         },
  118.         scatter: {
  119.             marker: {
  120.                 lineColor: '#333'
  121.             }
  122.         }
  123.     },
  124.    
  125.     toolbar: {
  126.         itemStyle: {
  127.             color: '#CCC'
  128.         }
  129.     }
  130. });
  131.  
  132. function toDateSeries(arr) {
  133.   ret = new Array();
  134.   for (i in arr) {
  135.     f = arr[i][0];
  136.     f = Date.UTC( f.substring(0,4), f.substring(5,7)-1, f.substring(8,10) );
  137.     ret.push([f, arr[i][1]]);
  138.   }
  139.   return ret;
  140. }
  141.  
  142. function values_per_indicator_chart(json, container) {
  143.   var chart;
  144.   for (i=0;i<json.sources.length;i++) {
  145.     data = json.sources[i].data;
  146.     for (j=0;j<data.length;j++) {
  147.       f = json.sources[i].data[j][0];
  148.       json.sources[i].data[j][0] = Date.UTC( f.substring(0,4), f.substring(5,7)-1, f.substring(8,10) );
  149.     }
  150.   }
  151.  
  152.   chart = new Highcharts.Chart({
  153.     chart: {
  154.       zoomType: 'x',
  155.       renderTo: container,
  156.       defaultSeriesType: 'spline'
  157.     },
  158.     title: {
  159.       text: ''
  160.     },
  161.     legend: {
  162.       enabled: true // json.sources.length>1
  163.     },
  164.     exporting: {
  165.       enabled: false
  166.     },
  167.     tooltip: {
  168.       formatter: function() {
  169.         return this.series.name + '<br>' + Highcharts.dateFormat('%e. %b', this.x) + ': <b>' + this.y + '</b>';
  170.       }
  171.     },
  172.     xAxis: {
  173.       type: 'datetime',
  174.       dateTimeLabelFormats: {
  175.         month: '%e. %b',
  176.         year: '%b'
  177.       }
  178.     },
  179.     yAxis: {
  180.       title: {
  181.         text: ''
  182.       },
  183.       plotBands: [{
  184.         from: json.data_min,
  185.         to: json.data_max,
  186.         color: 'rgba(68, 170, 213, 0.1)',
  187.         label: {
  188.           text: 'Zona de validez',
  189.           style: {
  190.             color: '#606060'
  191.           }
  192.         }
  193.       }]
  194.     },
  195.     plotOptions: {
  196.       spline: {
  197.         lineWidth: 4,
  198.         states: {
  199.           hover: {
  200.             lineWidth: 5
  201.           }
  202.         },
  203.         marker: {
  204.           enabled: true
  205.         }
  206.       }
  207.     },
  208.     series: json.sources
  209.   });
  210.   chart.redraw();
  211. }
  212.  
  213. function values_per_indicator_manager(indicator, container) {
  214.   var ajaxURL = '/charts/values/per/indicator/' + indicator;
  215.   $.ajax({
  216.     type: "GET",
  217.     url: ajaxURL,
  218.     success: function(json) { values_per_indicator_chart(json, container); },
  219.     error: function(xhr, status, error) {
  220.       alert("Error");
  221.     }
  222.   });
  223.  
  224.   return false;
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement