chart.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. (function() {
  5. 'use strict';
  6. var Hana = {};
  7. Hana.initChart = function(div, options) {
  8. if (options.xAxis == undefined) {
  9. options.xAxis = {
  10. title: { text: "Number of elements" },
  11. minTickInterval: 1
  12. };
  13. }
  14. if (options.yAxis == undefined) {
  15. options.yAxis = {
  16. title: { text: "Time (s)" },
  17. floor: 0
  18. };
  19. }
  20. if (options.subtitle == undefined) {
  21. options.subtitle = { text: "(smaller is better)" };
  22. }
  23. if (options.chart == undefined) {
  24. options.chart = { zoomType: 'xy' };
  25. }
  26. options.plotOptions = options.plotOptions || {};
  27. options.plotOptions.series = options.plotOptions.series || {};
  28. options.plotOptions.series.marker = options.plotOptions.series.marker || { enabled: false };
  29. if (options.title.x == undefined) {
  30. options.title.x = -20; // center
  31. }
  32. if (options.series.stickyTracking == undefined) {
  33. options.series.stickyTracking = false;
  34. }
  35. // Fix the colors so that a series has the same color on all the charts.
  36. // Based on the colors at http://api.highcharts.com/highcharts#colors.
  37. var colorMap = {
  38. 'hana::tuple': '#f45b5b'
  39. , 'hana::basic_tuple': '#434348'
  40. , 'mpl::vector': '#90ed7d'
  41. , 'std::array': '#8085e9'
  42. , 'fusion::vector': '#f7a35c'
  43. , 'std::vector: ': '#f15c80'
  44. , 'std::tuple': '#e4d354'
  45. , 'hana::set': '#2b908f'
  46. , 'hana::map': '#7cb5ec'
  47. , 'fusion::list': '#91e8e1'
  48. };
  49. options.series.forEach(function(series) {
  50. if (colorMap[series.name])
  51. series.color = colorMap[series.name];
  52. });
  53. options.tooltip = options.tooltip || {};
  54. options.tooltip.valueSuffix = options.tooltip.valueSuffix || 's';
  55. if (options.legend == undefined) {
  56. options.legend = {
  57. layout: 'vertical',
  58. align: 'right',
  59. verticalAlign: 'middle',
  60. borderWidth: 0
  61. };
  62. }
  63. div.highcharts(options);
  64. };
  65. window.Hana = Hana;
  66. })();