Highchart drilldown问题

时间:2016-01-26 16:58:46

标签: php jquery highcharts

我厌倦了向下钻两次并且在我向下钻的时候更换字幕。

plotOptions: {
         column: {
            cursor: 'pointer',
            point: {
               events: {
                  click: function(e) {

                     var drilldown = this.drilldown;
                     //var drilldownC = this.drilldown.categories;

                     if (drilldown) { // 1st drill down

                              this.series.chart.setTitle({
                              text: drilldown.name
                              });

                              chartC.setTitle(null, {
                              text: 'BBBBBBB'
                              });


                            ----------

                              if (drilldown) {

                              this.series.chart.setTitle({
                              text: drilldown.name
                              });

                              chartC.setTitle(null, {
                              text: 'CCCCCCCC'
                              });

                              }   

                          ----------

                     } else { 

                        chartC.setTitle({
                             text: name
                         });
                        chartC.setTitle(null, {
                          text: 'AAAAAA'
                        });

                     }

                  }
               }
            },
            dataLabels: {
               enabled: true,
               formatter: function() {
                  return this.y;
               }
            }               
         }
      },

我厌倦了这样做,但它不起作用:

                               ----------

                                  if (drilldown) {

                                  this.series.chart.setTitle({
                              text: drilldown.name
                              });

                              chartC.setTitle(null, {
                              text: 'BBBBBBB'
                              });

                                  }   

                              ----------

我所做的只是添加:

<div id="navbar">
    <div class="links">
        <table>
        <tr>
            <td class="link1"></td><a href="Index.html">Calvin and Hobbes</a></td>
            <td class="link2"><a href="Index.html">Garfield</a></td>
        </tr>
        <tr class="hoverbar">
            <td class="link1hover"></td>
            <td class="link2hover"></td>
        </tr>
        </table>
    </div>
</div>

如果有人有解决方案,请告诉我。所有我需要做的就是查看&#34; drilldown&#34;存在?

2 个答案:

答案 0 :(得分:0)

为什么要使用point.click个事件,而不是chart.drilldownchart.drillip个事件?像这样:http://jsfiddle.net/eqrnj220/

代码:

    chart: {
        type: 'column',
        events: {
          drilldown: function (e) {
            this.setTitle({
                text: e.point.name
            });
          },
          drillup: function (e) {
            this.setTitle({
                text: "Animals" 
            });
          }
        }
    },

答案 1 :(得分:0)

我通过在数据系列中添加“Level”来解决问题,并保留条件以检查我所处的级别并更改字幕。

if(drilldown.level == 1)
{
     chartC.setTitle(null, {
           text: 'Bla Bla Bla Bla Bla Bla Bla'
     });
}