mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 22:19:48 +03:00
Finish d3tooltip
This commit is contained in:
parent
ac468f16a0
commit
15bf781bbb
|
@ -1,9 +1,4 @@
|
|||
import d3Package, {
|
||||
BaseType,
|
||||
ContainerElement,
|
||||
Primitive,
|
||||
Selection,
|
||||
} from 'd3';
|
||||
import d3Package, { BaseType, ContainerElement, Selection } from 'd3';
|
||||
import { is } from 'ramda';
|
||||
import functor from './utils/functor';
|
||||
|
||||
|
@ -38,11 +33,12 @@ interface Tip<
|
|||
PDatum
|
||||
> {
|
||||
(selection: Selection<GElement, Datum, PElement, PDatum>): void;
|
||||
// TODO Do we need to support functions or `null`?
|
||||
style: (this: this, value: { [key: string]: StyleValue }) => this;
|
||||
text: (
|
||||
this: this,
|
||||
d: string | ((datum: Datum, index?: number, outerIndex?: number) => string)
|
||||
value:
|
||||
| string
|
||||
| ((datum: Datum, index?: number, outerIndex?: number) => string)
|
||||
) => this;
|
||||
}
|
||||
|
||||
|
@ -109,33 +105,21 @@ export function tooltip<
|
|||
|
||||
tip.style = function setStyle(
|
||||
this: typeof tip,
|
||||
d:
|
||||
| string
|
||||
| {
|
||||
[key: string]:
|
||||
| Primitive
|
||||
| ((datum: Datum, index: number, outerIndex: number) => Primitive);
|
||||
}
|
||||
| undefined
|
||||
value: { [key: string]: StyleValue }
|
||||
) {
|
||||
if (is(Object, d)) {
|
||||
styles = {
|
||||
...styles,
|
||||
...(d as {
|
||||
[key: string]:
|
||||
| Primitive
|
||||
| ((datum: Datum, index: number, outerIndex: number) => Primitive);
|
||||
}),
|
||||
};
|
||||
if (is(Object, value)) {
|
||||
styles = { ...styles, ...value };
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
tip.text = function setText(
|
||||
this: typeof tip,
|
||||
d: string | ((datum: Datum, index?: number, outerIndex?: number) => string)
|
||||
value:
|
||||
| string
|
||||
| ((datum: Datum, index?: number, outerIndex?: number) => string)
|
||||
) {
|
||||
text = functor(d);
|
||||
text = functor(value);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user