Skip to content

Commit 203f35d

Browse files
committed
Add tips for writing selection tests
1 parent d3ff96b commit 203f35d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,32 @@ which shows the baseline image, the generated image, the diff and the json mocks
177177

178178
To view the results of a run on CircleCI, download the `build/test_images/` and `build/test_images_diff/` artifacts into your local repo and then run `npm run start-image_viewer`.
179179

180+
### Writing selection tests
181+
Keep in mind that the selection coordinates are relative to the top-left corner of the plot, including the margins. To produce a reliable selection test,
182+
it may be necessary to to fix the width, height, margins, X axis range and Y axis range of the plot. For example:
183+
184+
```
185+
Plotly.newPlot(gd,
186+
[
187+
{
188+
x: [1, 1, 1, 2, 2, 2, 3, 3, 3],
189+
y: [1, 2, 3, 1, 2, 3, 1, 2, 3],
190+
mode: 'markers'
191+
}
192+
],
193+
{
194+
width: 400, height: 400,
195+
margin: {l: 100, r: 100, t: 100, b: 100},
196+
xaxis: {range: [0, 4]},
197+
yaxis: {range: [0, 4]}
198+
}
199+
)
200+
```
201+
202+
This will produce the following plot, and you want to simulate a selection path of (175, 175) to (225, 225):
203+
204+
<img src="https://user-images.githubusercontent.com/31989842/38889542-5303cf9c-427f-11e8-93a2-16ce2e29f521.png">
205+
180206

181207
## Repo organization
182208

0 commit comments

Comments
 (0)