Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for tooltipOpts in series data #37

Open
maplemuse opened this issue Aug 1, 2013 · 1 comment
Open

Support for tooltipOpts in series data #37

maplemuse opened this issue Aug 1, 2013 · 1 comment

Comments

@maplemuse
Copy link
Contributor

I would like to customize the tooltip content on a per-series basis:

var dataOpts = [{
  data: [...],
  label: 'Foo'
},{
  data: [...],
  tooltipOpts: {
    content: 'Bar: %y'
  }
}];
var plotOpts = {
  ...
  legend: {
    show: true
  },
  grid: { hoverable: true },
  tooltip: true,
  tooltipOpts: {
    content: '%y'
  }
}

$.plot($('#plot'), dataOpts, plotOpts);

Basically, I have some series that I want included in the legend, while I have other series that I want to specially format the tooltip content, without the series appearing in the legend.

In the plothover eventhandler, the item has the series data, so it should be possible to change

tipText = that.stringFormat(that.tooltipOptions.content, item);

to some variation of

if (item.series.tooltipOpts !== undefined && item.series.tooltipOpts.content !== undefined){
    tipText = that.stringFormat(item.series.tooltipOpts.content, item);
} else {
    tipText = that.stringFormat(that.tooltipOptions.content, item);
}
@krzysu
Copy link
Owner

krzysu commented Aug 5, 2013

Hi,
that looks like a good idea, but currently I don't have any time to work on flot.tooltip. But you can always develop it by yourself and send pull request if you want. Any contributions are more than welcomed. Have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants