How to set x axis value as tooltip in flot charts textual data

前端 未结 2 1029
小鲜肉
小鲜肉 2021-01-16 02:57

I tried with following code in Flot char to draw a chart. Chart is plotting as expected but not tooltip

2条回答
  •  旧时难觅i
    2021-01-16 03:11

    The easiest way to solve your problem is to replace the content string with a callback:

    tooltipOpts : {
            content : getTooltip,
            defaultTheme : false
          },
    

    I defined getTooltip to get your desired output:

    function getTooltip(label, x, y) {
        return "Your sales for " + x + " was $" + y; 
    }
    

    It works, as you can see in the updated jsFiddle, but you may want to consider the advice of captain, in comments, and see what's best in your case.

提交回复
热议问题