• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright Louis Dionne 2013-2017
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5(function() {
6  'use strict';
7
8  var Hana = {};
9  Hana.initChart = function(div, options) {
10    if (options.xAxis == undefined) {
11      options.xAxis = {
12        title: { text: "Number of elements" },
13        minTickInterval: 1
14      };
15    }
16
17    if (options.yAxis == undefined) {
18      options.yAxis = {
19        title: { text: "Time (s)" },
20        floor: 0
21      };
22    }
23
24    if (options.subtitle == undefined) {
25      options.subtitle = { text: "(smaller is better)" };
26    }
27
28    if (options.chart == undefined) {
29      options.chart = { zoomType: 'xy' };
30    }
31
32    options.plotOptions = options.plotOptions || {};
33    options.plotOptions.series = options.plotOptions.series || {};
34    options.plotOptions.series.marker = options.plotOptions.series.marker || { enabled: false };
35
36    if (options.title.x == undefined) {
37      options.title.x = -20; // center
38    }
39
40    if (options.series.stickyTracking == undefined) {
41      options.series.stickyTracking = false;
42    }
43
44    // Fix the colors so that a series has the same color on all the charts.
45    // Based on the colors at http://api.highcharts.com/highcharts#colors.
46    var colorMap = {
47        'hana::tuple': '#f45b5b'
48      , 'hana::basic_tuple': '#434348'
49      , 'mpl::vector': '#90ed7d'
50      , 'std::array': '#8085e9'
51      , 'fusion::vector': '#f7a35c'
52      , 'std::vector: ': '#f15c80'
53      , 'std::tuple': '#e4d354'
54      , 'hana::set': '#2b908f'
55      , 'hana::map': '#7cb5ec'
56      , 'fusion::list': '#91e8e1'
57    };
58    options.series.forEach(function(series) {
59      if (colorMap[series.name])
60        series.color = colorMap[series.name];
61    });
62
63    options.tooltip = options.tooltip || {};
64    options.tooltip.valueSuffix = options.tooltip.valueSuffix || 's';
65
66    if (options.legend == undefined) {
67      options.legend = {
68        layout: 'vertical',
69        align: 'right',
70        verticalAlign: 'middle',
71        borderWidth: 0
72      };
73    }
74    div.highcharts(options);
75  };
76
77  window.Hana = Hana;
78})();
79