diff --git a/_posts/reference_pages/2016-06-03-plotly_js_function_ref.html b/_posts/reference_pages/2016-06-03-plotly_js_function_ref.html index f1bb36c44937..802303948742 100644 --- a/_posts/reference_pages/2016-06-03-plotly_js_function_ref.html +++ b/_posts/reference_pages/2016-06-03-plotly_js_function_ref.html @@ -361,6 +361,77 @@
Plotly.makeTemplate
copies the style information from a figure. It does this by returning a template
object which can be passed to the layout.template
attribute of another figure.
+
+var figure = {
+ data: [{
+ type: 'bar',
+ marker: {color: 'red'},
+ y: [2, 1, 3, 2],
+ }],
+ layout:{
+ title: 'Quarterly Earnings'
+ }
+};
+
+var template = Plotly.makeTemplate(figure);
+
+newData = [{
+ type:'bar',
+ y:[3,2,5,8]
+}]
+layoutWithTemplate = {template:template}
+
+Plotly.newPlot(graphDiv,newData,layoutTemplate)
+
+
+
+Plotly.validateTemplate
allows users to Test for consistency between the given figure and a template,
+either already included in the figure or given separately. Note that not every issue identified here is necessarily
+a problem, it depends on what you're using the template for.
+
+var out = Plotly.validateTemplate(figure, template);
+console.log(out[0].msg)
+// "The template has 1 traces of type bar but there are none in the data."
+
Plotly.react
and is faster than redrawing the whole plot with Plotly.newPlot
.