Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

import { c3_chart_fn } from './core';
c3_chart_fn.tooltip = function () {};
c3_chart_fn.tooltip.show = function (args) {
var $$ = this.internal, targets, data, mouse = {};
// determine mouse position on the chart
if (args.mouse) {
mouse = args.mouse;
}
else {
// determine focus data
if (args.data) {
data = args.data;
}
else if (typeof args.x !== 'undefined') {
if (args.id) {
targets = $$.data.targets.filter(function(t){ return t.id === args.id; });
} else {
targets = $$.data.targets;
}
data = $$.filterByX(targets, args.x).slice(0,1)[0];
}
mouse = data ? $$.getMousePosition(data) : null;
}
// emulate mouse events to show
$$.dispatchEvent('mousemove', mouse);
$$.config.tooltip_onshow.call($$, data);
};
c3_chart_fn.tooltip.hide = function () {
// TODO: get target data by checking the state of focus
this.internal.dispatchEvent('mouseout', 0);
this.internal.config.tooltip_onhide.call(this);
};