MCPcopy Index your code
hub / github.com/bqplot/bqplot / adjustOffset

Method adjustOffset

js/src/Bars.ts:99–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97 }
98
99 private adjustOffset(): void {
100 // In the case of a linear scale, and when plotting ordinal data,
101 // the value have to be negatively offset by half of the width of
102 // the bars, because ordinal scales give the values corresponding
103 // to the start of the bin but linear scale gives the actual value.
104 if (!isOrdinalScale(this.domScale)) {
105 if (this.align === 'center') {
106 this.domOffset = -(this.stackedScale.bandwidth() / 2).toFixed(2);
107 } else if (this.align === 'left') {
108 this.domOffset = -this.stackedScale.bandwidth().toFixed(2);
109 } else {
110 this.domOffset = 0;
111 }
112 } else {
113 if (this.align === 'center') {
114 this.domOffset = 0;
115 } else if (this.align === 'left') {
116 this.domOffset = -(this.stackedScale.bandwidth() / 2);
117 } else {
118 this.domOffset = this.stackedScale.bandwidth() / 2;
119 }
120 }
121 }
122
123 create_listeners(): void {
124 super.create_listeners.apply(this);

Callers 1

updateInternalScalesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected