Commits

Peter Ward committed ea79205

More chart options.

Comments (0)

Files changed (3)

     },
     "graphs": {
         "cpu": [{
-            "graph-type": "line",
+            "graph": {
+                "type": "line",
+                "min": 0,
+                "max": 100
+            },
             "type": "cpu-summary",
             "files": {
                 "idle": "cpu-<num>/cpu-idle.rrd",
         }],
 
         "load": [{
-            "graph-type": "line",
+            "graph": {
+                "type": "line",
+                "min": 0
+            },
             "type": "load",
             "files": {"file": "load/load.rrd"}
         }],
 
         "cpu/<num>": [{
-            "graph-type": "stacked",
+            "graph": {
+                "type": "areaspline",
+                "min": 0,
+                "max": 100,
+                "stacking": "normal"
+            },
             "type": "cpu",
             "files": {
                 "idle": "cpu-<num>/cpu-idle.rrd",

static/js/charts.js

     global: {useUTC: false}
 });
 
-function add_chart(id, title, url, series, n) {
+function add_chart(id, args, url, series, n) {
+    var defaults = {
+        'title': '',
+        'type': 'spline',
+        'stacking': null,
+        'min': null,
+        'max': null
+    };
+
+    var args = $.extend({}, defaults, args || {});
+
+    var plotOptions = {};
+    plotOptions[args.type] = {
+        stacking: args.stacking
+    };
+
     var chart = new Highcharts.Chart({
         chart: {
             renderTo: id,
-            defaultSeriesType: 'spline'
+            type: args.type
         },
-        title: {text: title},
+        colors: [
+            '#729fcf',
+            '#cc0000',
+            '#73d216',
+            '#edd400',
+            '#75507b',
+            '#c17d11',
+            '#f57900'
+        ],
+        title: {text: args.title},
         xAxis: {
             type: 'datetime',
             tickPixelInterval: 150
         },
-        yAxis: {title: ''},
+        yAxis: {
+            title: '',
+            min: args.min,
+            max: args.max
+        },
         tooltip: {
             formatter: function() {
                     return '<b>'+ this.series.name +'</b><br/>'+
                     Highcharts.numberFormat(this.y, 2);
             }
         },
+        plotOptions: plotOptions,
         legend: {enabled: true},
         series: series
     });

templates/view.html

 {% endfor %}
 
 <script type="text/javascript">
-{% for chart in charts %}
+{% for spec, resolution in charts %}
+    var args = {{ spec.graph |tojson |safe }};
     add_chart(
         "chart-{{ loop.index0 }}",
-        "{{ chart.type }}",
+        args,
         "{{
             url_for('get_data',
                 hostname=current_hostname,