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

Method getPlottingData

js/src/HeatMap.ts:150–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148 }
149
150 private getPlottingData() {
151 const xData: Array<number> = Array.from(this.model.mark_data.x).map(
152 this.scales.x.scale
153 );
154 const yData: Array<number> = Array.from(this.model.mark_data.y).map(
155 this.scales.y.scale
156 );
157
158 const xReverse = this.scales.x.model.get('reverse');
159 const yReverse = this.scales.y.model.get('reverse');
160
161 const padding = this.getPadding(xData, yData);
162
163 const widths = this.computeRectSizes(xData, padding.left, padding.right);
164 const heights = this.computeRectSizes(
165 yData,
166 padding.bottom,
167 padding.top,
168 true
169 );
170
171 const totalWidth = Math.abs(
172 xData[xData.length - 1] - xData[0] + padding.left + padding.right
173 );
174 const totalHeight = Math.abs(
175 yData[0] - yData[yData.length - 1] + padding.top + padding.bottom
176 );
177
178 const x0 = xData[0] - padding.left;
179 const y0 = yData[yData.length - 1] - padding.top;
180
181 const xStartPoints = xData.map((d, i) => {
182 if (i == 0) {
183 return 0;
184 } else {
185 return (d + xData[i - 1]) * 0.5 - x0;
186 }
187 });
188 const yStartPoints = yData.map((d, i) => {
189 if (i == yData.length - 1) {
190 return 0;
191 } else {
192 return (d + yData[i + 1]) * 0.5 - y0;
193 }
194 });
195
196 return {
197 widths,
198 heights,
199 totalWidth,
200 totalHeight,
201 xOrigin: xReverse ? totalWidth : 0,
202 yOrigin: yReverse ? totalHeight : 0,
203 xStartPoints,
204 yStartPoints,
205 x0: xReverse ? x0 - totalWidth : x0,
206 y0: yReverse ? y0 - totalHeight : y0,
207 };

Callers 1

drawMethod · 0.95

Calls 2

getPaddingMethod · 0.95
computeRectSizesMethod · 0.95

Tested by

no test coverage detected