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