You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

61 lines
1.5 KiB

  1. // Load Highcharts
  2. const Highcharts = global.Highcharts = require('highcharts');
  3. // Alternatively, this is how to load Highstock. Highmaps is similar.
  4. // var Highcharts = require('highcharts/highstock');
  5. // Load the exporting module, and initialize it.
  6. require('highcharts/modules/exporting')(Highcharts);
  7. // Load Highcharts Maps as a module
  8. require('highcharts/modules/map')(Highcharts);
  9. require('highcharts/modules/accessibility')(Highcharts);
  10. // Generate the chart
  11. // Set global options
  12. Highcharts.setOptions({
  13. chart: {
  14. // Turn on if you want to style the carts per css
  15. styledMode: true,
  16. },
  17. tooltip:{pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>'},
  18. responsive: {
  19. rules: [{
  20. condition: {
  21. maxWidth: 999
  22. },
  23. //Rotate the axis labels in mobile
  24. chartOptions: {
  25. xAxis: {
  26. labels: {
  27. rotation: 90
  28. }
  29. }
  30. }
  31. }]
  32. },
  33. plotOptions: {
  34. pie: {
  35. allowPointSelect: true,
  36. cursor: 'pointer',
  37. dataLabels: {
  38. enabled: true
  39. },
  40. showInLegend: true
  41. }
  42. },
  43. });
  44. $.each($('.highchart-container'), function(index) {
  45. const container = $(this);
  46. const options = container.data('options');
  47. const newId = container.attr('id')+'-'+index;
  48. container.attr('id', newId);
  49. if (container.data('height')) {
  50. container.height(container.data('height'));
  51. }
  52. options.chart.renderTo = newId;
  53. new Highcharts.chart(options);
  54. });