Skip to content

Commit 7463e10

Browse files
authored
Merge pull request #700 from plotly/plotlyjs-null-vs-undefined
Add docs and a codepen explaining null vs. undefined in restyle
2 parents a3e8fa6 + 100d12c commit 7463e10

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

_posts/reference_pages/2016-06-03-plotly_js_function_ref.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ <h4 id="plotly-restyle"><a href="#plotly-restyle">Plotly.restyle</a></h4>
156156
<p data-height="528" data-theme-id="15263" data-slug-hash="LpMBOy" data-default-tab="result" data-user="plotly" class='codepen' data-preview="true">See the Pen <a href='http://codepen.io/plotly/pen/LpMBOy/'>Plotly.restyle Attribute strings </a> by plotly (<a href='http://codepen.io/plotly'>@plotly</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
157157
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
158158

159+
Finally, you may wish to selectively reset or ignore certain properties when restyling. This may be useful when specifying multiple properties for multiple traces so that you can carefully target what is and is not affected. In general `null` resets a property to the default while `undefined` applies no change to the current state.
160+
161+
<pre><code class="language-javascript hljs" data-lang="javascript">
162+
// Set the first trace's line to red, the second to the default, and ignore the third
163+
Plotly.restyle(graphDiv, {
164+
'line.color': ['red', null, undefined]
165+
}, [0, 1, 2])
166+
</code></pre>
167+
168+
<p data-height="528" data-theme-id="15263" data-slug-hash="XMWRqj" data-default-tab="result" data-user="plotly" class='codepen' data-preview="true">See the Pen <a href='http://codepen.io/plotly/pen/XMWRqj/'>null vs. undefined in Plotly.restyle</a> by plotly (<a href='http://codepen.io/plotly'>@plotly</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
169+
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
170+
159171
<h4 id="plotly-relayout"><a href="#plotly-relayout">Plotly.relayout</a></h4>
160172

161173
A more efficient means of updating just the layout in a graphDiv. The call signature and arguments for relayout are similar (but simpler) to restyle. Because there are no indices to deal with, arrays need not be wrapped. Also, no argument specifying applicable trace indices is passed in.

0 commit comments

Comments
 (0)