Javascript为每个图形设置主题

Javascript为每个图形设置主题,javascript,highcharts,Javascript,Highcharts,我在一个页面中有几个图形,它们都加载在同一页面中 我想为每个图形设置不同的主题,但问题是,首先设置的主题会覆盖下一个图形的所有主题。是否有任何方法可以在本地为每个图形设置HighChart的主题 /** * Sand-Signika theme for Highcharts JS * @author Torstein Honsi */ // Load the fonts Highcharts.createElement('link', { href: 'http://fonts.g

我在一个页面中有几个图形,它们都加载在同一页面中

我想为每个图形设置不同的主题,但问题是,首先设置的主题会覆盖下一个图形的所有主题。是否有任何方法可以在本地为每个图形设置
HighChart
的主题

/**
 * Sand-Signika theme for Highcharts JS
 * @author Torstein Honsi
 */

// Load the fonts
Highcharts.createElement('link', {
   href: 'http://fonts.googleapis.com/css?family=Signika:400,700',
   rel: 'stylesheet',
   type: 'text/css'
}, null, document.getElementsByTagName('head')[0]);

// Add the background image to the container
Highcharts.wrap(Highcharts.Chart.prototype, 'getContainer', function (proceed) {
   proceed.call(this);
   this.container.style.background = 'url(http://www.highcharts.com/samples/graphics/sand.png)';
});


Highcharts.theme = {
   colors: ["#f45b5b", "#8085e9", "#8d4654", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
      "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
   chart: {
      backgroundColor: null,
      style: {
         fontFamily: "Signika, serif"
      }
   },
   title: {
      style: {
         color: 'black',
         fontSize: '16px',
         fontWeight: 'bold'
      }
   },
   subtitle: {
      style: {
         color: 'black'
      }
   },
   tooltip: {
      borderWidth: 0
   },
   legend: {
      itemStyle: {
         fontWeight: 'bold',
         fontSize: '13px'
      }
   },
   xAxis: {
      labels: {
         style: {
            color: '#6e6e70'
         }
      }
   },
   yAxis: {
      labels: {
         style: {
            color: '#6e6e70'
         }
      }
   },
   plotOptions: {
      series: {
         shadow: true
      },
      candlestick: {
         lineColor: '#404048'
      },
      map: {
         shadow: false
      }
   },

   // Highstock specific
   navigator: {
      xAxis: {
         gridLineColor: '#D0D0D8'
      }
   },
   rangeSelector: {
      buttonTheme: {
         fill: 'white',
         stroke: '#C0C0C8',
         'stroke-width': 1,
         states: {
            select: {
               fill: '#D0D0D8'
            }
         }
      }
   },
   scrollbar: {
      trackBorderColor: '#C0C0C8'
   },

   // General
   background2: '#E0E0E8'

};

// Apply the theme
Highcharts.setOptions(Highcharts.theme);

您可以使用图表选项发送主题设置,而不是像中那样全局设置。有关守则如下:

var theme1 = {
    // Theme settings
}

var options = {
    // Chart options
}

$('#container').highcharts(Highcharts.merge(options, theme1));

归功于

您可以发送带有图表选项的主题设置,而不是像中那样全局设置它们。有关守则如下:

var theme1 = {
    // Theme settings
}

var options = {
    // Chart options
}

$('#container').highcharts(Highcharts.merge(options, theme1));
归功于