Set label for tooltip in flock based on x-axis value

I have a line graph using a fleet. I want the tooltip to show the x-axis and y-axis values.

I'm trying to:

content: "Orders <b>%y</b> for <span>%x</span>",

But it shows "Orders 100 for 0" for the first point, "Orders 100 for 1" for the second, etc.

If I use:

content: "Orders <b>%y</b> for <span>"+chartData.axis[0][1]+"</span>",

This then correctly shows the x-axis value for the first point.

But this does not work:

content: "Orders <b>%y</b> for <span>"+chartData.axis[%x][1]+"</span>",

This gives me:

Uncaught SyntaxError: Unexpected token % 

How can I refer to the% x value inside chartData.axis?

+4
source share
1 answer

function content ( , , , question).

 tooltip: true,
   tooltipOpts: {
       content: function(label, xval, yval, flotItem){
           return "Orders <b>"+yval+"</b> for <span>"+chartData.axis[xval][2]+"</span>"
       },
       shifts: {
         x: -30,
         y: -50
       }
  }

.

+10

Source: https://habr.com/ru/post/1523711/


All Articles