如果从jqplot条形图中的条形图中单击ine,如何获取系列名称和刻度名称

时间:2017-02-13 05:56:16

标签: javascript jquery

我有一个jqplot条形图,当我点击条形图时,我想要获得一个警报声明,其中包含刻度标签名称和系列名称。我试图获取但我失败了。请帮助我.. < / p>

以下代码在点击栏时显示或不存在。我想要一个刻度标签名称也像a,present。

enter code here
   <!DOCTYPE html>
      <head>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

       <script type="text/javascript" src="te/jquery.jqplot.js"></script>
             <script type="text/javascript" src="te/plugins/jqplot.barRenderer.js"></script>
      <script type="text/javascript" src="te/plugins/jqplot.json2.js"></script>
        <link rel="stylesheet" type="text/css" href="te/jquery.jqplot.css" />
            <script language="javascript" type="text/javascript" src="te/plugins/jqplot.categoryAxisRenderer.js"></script>
           <script type="text/javascript" src="te/plugins/jqplot.json2.js"></script>
       <script type="text/javascript" src="te/plugins/jqplot.canvasTextRenderer.js"></script>
         <script type="text/javascript" src="te/plugins/jqplot.canvasAxisLabelRenderer.js"></script>
           <script type="text/javascript" src="te/plugins/jqplot.canvasAxisTickRenderer.js"></script>
          <script type="text/javascript" src="te/plugins/jqplot.pointLabels.js"></script>
          <script type="text/javascript" src="te/plugins/jqplot.cursor.js"></script>
              <script type="text/javascript" src="te/plugins/jqplot.highlighter.js"></script>
            <script type="text/javascript" src="te/plugins/jqplot.dateAxisRenderer.js"></script>

             <script>




            $(document).ready(function(){
    var s1 = [2, 6, 7, 10];
    var s2 = [7, 5, 3, 2];
    var ticks = ['a', 'b', 'c', 'd'];

    plot2 = $.jqplot('chart2', [s1, s2], {
        seriesDefaults: {
            renderer:$.jqplot.BarRenderer,
            pointLabels: { show: true }
        },
       legend: {
            show: true,
            location: 'e',
             //marginTop : "1620px",

            placement: 'outside'
        }  ,
         series:[{label:'Present'}, {label:'Absent'}  ],
   axes: {
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,
                ticks: ticks
            }
        },


    });

$('#chart2').bind('jqplotClick', function(ev, seriesIndex, pointIndex, data,plot) {


alert('Plot Label: '+plot2.series[data.seriesIndex].label);
      });

           });

        </script>

       </head>
              <body>
            <div id="chart2" style="height:400px;width:95%; "></div>
           <p id='info2'></p>
           </body>
                </html>

0 个答案:

没有答案