How to create custom hover tool with value mapping

前端 未结 1 603
既然无缘
既然无缘 2021-01-28 16:49

I am trying to create a custom hover tool using which takes the y-value of the plot and maps the value to different value.

The code I could come up with so far to achiev

相关标签:
1条回答
  • 2021-01-28 17:27

    Here's how I'd do it:

    code = f"return ({json.dumps(mapping)})[Math.floor(special_vars.y)];"
    hover = HoverTool(tooltips=[("x", "$x"), ("y", "$y"), ('mapped_y', '$y{0}')],
                      formatters={'$y': CustomJSHover(code=code)})
    

    If you need a some more complicated code than that of col_mapping, then you'd have to use a ColumnDataSource and just add to it the fully transformed column.

    0 讨论(0)
提交回复
热议问题