mirror of https://github.com/masayuki0812/c3.git
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.
60 lines
1.5 KiB
60 lines
1.5 KiB
import { |
|
CLASS, |
|
isValue, |
|
isFunction, |
|
isString, |
|
isUndefined, |
|
isDefined, |
|
ceil10, |
|
asHalfPixel, |
|
diffDomain, |
|
isEmpty, |
|
notEmpty, |
|
getOption, |
|
hasValue, |
|
sanitise, |
|
getPathBox, |
|
ChartInternal |
|
} from '../chartinternal.js'; |
|
|
|
const tooltip = function () {}; |
|
|
|
tooltip.show = function (args) { |
|
let $$ = this.internal, index, mouse; |
|
|
|
// determine mouse position on the chart |
|
if (args.mouse) { |
|
mouse = args.mouse; |
|
} |
|
|
|
// determine focus data |
|
if (args.data) { |
|
if ($$.isMultipleX()) { |
|
// if multiple xs, target point will be determined by mouse |
|
mouse = [$$.x(args.data.x), $$.getYScale(args.data.id)(args.data.value)]; |
|
index = null; |
|
} else { |
|
// TODO: when tooltip_grouped = false |
|
index = isValue(args.data.index) ? args.data.index : $$.getIndexByX(args.data.x); |
|
} |
|
} else if (typeof args.x !== 'undefined') { |
|
index = $$.getIndexByX(args.x); |
|
} else if (typeof args.index !== 'undefined') { |
|
index = args.index; |
|
} |
|
|
|
// emulate mouse events to show |
|
$$.dispatchEvent('mouseover', index, mouse); |
|
$$.dispatchEvent('mousemove', index, mouse); |
|
|
|
$$.config.tooltip_onshow.call($$, args.data); |
|
}; |
|
|
|
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); |
|
}; |
|
|
|
export { tooltip };
|
|
|