【问题标题】:background color change in jquery highchartsjquery highcharts中的背景颜色变化
【发布时间】:2025-11-28 22:10:01
【问题描述】:

想知道如何更改 jquery highcharts 的背景颜色。我在 highcharts 网站 (http://www.highcharts.com/demo/spline-irregular-time/gray) 上尝试了代码,但无法正常工作。这是我的 highcharts 代码。任何帮助将不胜感激。谢谢。

<script type="text/javascript">
            var chart;
$(document).ready(function() {
   chart = new Highcharts.Chart({
      chart: {
         renderTo: 'stats_vmonth',
         type: 'spline'
      },
            title: {
         text: 'Visitor Stats'
      },
      subtitle: {
         text: 'This Month (<?php echo $thismonth;?>)'   
      },
      xAxis: {
         type: 'datetime',
         dateTimeLabelFormats: { // don't display the dummy year
            month: '%e. %b',
            year: '%b'
         }
      },
      yAxis: {
         title: {
            text: 'Visitors'
         },
         min: 0
      },
      tooltip: {
         formatter: function() {
                   return '<b>'+ Highcharts.dateFormat('%e, %b', this.x) +'</b><br/>'+
               this.y +' Visitors';
         }
      },
      series: [{
         name: 'This Year Visitor Stats',
         // Define the data points. All series have a dummy year
         // of 1970/71 in order to be compared on the same x axis. Note
         // that in JavaScript, months start at 0 for January, 1 for February etc.
         data: [
        <?php while($morow = mysql_fetch_array($moresult)){?>
            [Date.UTC(<?php echo $year;?>, <?php echo $month-1;?>, <?php echo $morow['day'];?>),  <?php echo $morow['COUNT(url)'];?>   ],
        <?php }?>

         ]
      }]
   });


});
        </script>

【问题讨论】:

    标签: jquery highcharts


    【解决方案1】:

    尝试主题选项

    Highcharts.theme = {
      chart: {
          backgroundColor: {
             linearGradient: [0, 0, 500, 500],
             stops: [
                [0, 'rgb(255, 255, 255)'],
                [1, 'rgb(240, 240, 255)']
             ]
          }
    }
    

    【讨论】:

    • 感谢这项工作,我也尝试直接更改 highcharts js 文件,它也可以正常工作。
    最近更新 更多