getting legend of clicked element in a line graph

瀏覽次數:25 次
跳到第一則未讀訊息

je...@propertypreswizard.com

未讀,
2016年1月23日 下午1:26:192016/1/23
收件者:Flot graphs
I have a flot line graph and I really need to be able to get the legend of a point when it's clicked on. For example, I have a time series graph that I'm displaying and when the user clicks on a point I need to be able to get the value of the month they clicked on (ie 'Apr 2015'). I'm using a plotclick handler but in the item object I don't see a way to get to the information I need. Here's the options I'm using:

var options = {
    xaxis: {
        mode: "time",
        timeformat: xTimeFormat
    },
    yaxis: {

    },
    series: {
        lines: {
            show: true
        }
    },
    grid: {
         hoverable: true,
             clickable: true
         },
     tooltip: true,
     tooltipOpts: {
         xDateFormat: "%b %Y",
         content: "<b>%x</b><br />%y"
     }
 };
 $.plot($("#" + rowID + " .flotGraph"), series, options);

And the plotclick function:

$("#placeholder").on('plotclick', function(event, pos, item){
    console.log(item);
});
回覆所有人
回覆作者
轉寄
0 則新訊息