Browse Source

pod fix

pull/37/head
glitch4347 11 months ago
parent
commit
283f0995e8
  1. 4
      react/ChartwerkLinePod.tsx
  2. 4
      src/components/segments.ts
  3. 2
      src/models/segment.ts

4
react/ChartwerkLinePod.tsx

@ -47,9 +47,11 @@ export function ChartwerkLinePod(props: ChartwerkLinePodProps) {
setPod(newPod); setPod(newPod);
newPod.render(); newPod.render();
} else { } else {
// TODO: actually it's wrong logic with updates
// because it creates new pod anyway
pod.updateData(props.series, props.options); pod.updateData(props.series, props.options);
} }
}, [chart, pod, props.id, props.options, props.markersConf, props.segments]); }, [chart, props.id, props.options, props.markersConf, props.segments]);
// TODO: it's a hack to render the LinePod right after the div appears in DOM // TODO: it's a hack to render the LinePod right after the div appears in DOM
setTimeout(() => { setTimeout(() => {

4
src/components/segments.ts

@ -24,9 +24,9 @@ export class Segments {
protected renderSerie(serie: SegmentSerie) { protected renderSerie(serie: SegmentSerie) {
serie.data.forEach((d) => { serie.data.forEach((d) => {
// @ts-ignore // @ts-ignore
const startPositionX = pod.state.xScale(d[0]) as number; const startPositionX = this._state.xScale(d[0]) as number;
// @ts-ignore // @ts-ignore
const endPositionX = pod.state.xScale(d[1]) as number; const endPositionX = this._state.xScale(d[1]) as number;
const width = endPositionX - startPositionX // Math.max(endPositionX - startPositionX, MIMIMUM_SEGMENT_WIDTH); const width = endPositionX - startPositionX // Math.max(endPositionX - startPositionX, MIMIMUM_SEGMENT_WIDTH);
this._d3Holder.append('rect') this._d3Holder.append('rect')

2
src/models/segment.ts

@ -1,4 +1,4 @@
export type SegmentSerie = { export type SegmentSerie = {
color: string; color: string;
data: [number, number, any][] // [from, to, payload] payload is any data for tooltip data: [number, number, any?][] // [from, to, payload?] payload is any data for tooltip
} }
Loading…
Cancel
Save