MCPcopy
hub / github.com/palantir/plottable / XYPlot

Class XYPlot

src/plots/xyPlot.ts:16–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14import { Plot } from "./plot";
15
16export class XYPlot<X, Y> extends Plot {
17 protected static _X_KEY = "x";
18 protected static _Y_KEY = "y";
19
20 private _autoAdjustXScaleDomain = false;
21 private _autoAdjustYScaleDomain = false;
22 private _adjustYDomainOnChangeFromXCallback: IScaleCallback<Scale<any, any>>;
23 private _adjustXDomainOnChangeFromYCallback: IScaleCallback<Scale<any, any>>;
24
25 private _deferredRendering = false;
26 private _deferredRenderer: DeferredRenderer<X, Y>;
27
28 /**
29 * An XYPlot is a Plot that displays data along two primary directions, X and Y.
30 *
31 * @constructor
32 * @param {Scale} xScale The x scale to use.
33 * @param {Scale} yScale The y scale to use.
34 */
35 constructor() {
36 super();
37 this.addClass("xy-plot");
38
39 this._adjustYDomainOnChangeFromXCallback = (scale) => this._adjustYDomainOnChangeFromX();
40 this._adjustXDomainOnChangeFromYCallback = (scale) => this._adjustXDomainOnChangeFromY();
41
42 this._renderCallback = () => {
43 if (this.deferredRendering()) {
44 const scaleX = this.x() && this.x().scale;
45 const scaleY = this.y() && this.y().scale;
46 this._deferredRenderer.updateDomains(scaleX, scaleY);
47 } else {
48 this.render();
49 }
50 };
51
52 this._deferredRenderer = new DeferredRenderer<X, Y>(() => this.render(), this._applyDeferredRenderingTransform);
53 }
54
55 public render() {
56 if (this.deferredRendering()) {
57 this._deferredRenderer.resetTransforms();
58 }
59 return super.render();
60 }
61
62 /**
63 * Returns the whether or not the rendering is deferred for performance boost.
64 *
65 * @return {boolean} The deferred rendering option
66 */
67 public deferredRendering(): boolean;
68 /**
69 * Sets / unsets the deferred rendering option Activating this option improves
70 * the performance of plot interaction (pan / zoom) by performing lazy
71 * renders, only after the interaction has stopped. Because re-rendering is no
72 * longer performed during the interaction, the zooming might experience a
73 * small resolution degradation, before the lazy re-render is performed.

Callers

nothing calls this directly

Calls 1

attrMethod · 0.80

Tested by

no test coverage detected