Skip to content

Commit 945f4da

Browse files
committed
add back title as string removed example
1 parent fc8760c commit 945f4da

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

_posts/plotly_js/fundamentals/plotly-js-3-changes/2024-10-09-plotly-js-3-changes.md

+30-16
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Plotly.js 3 removes the following features that were deprecated in previous vers
2121

2222
`annotation.ref` has been removed. Use `annotation.xref` and `annotation.yref` instead.
2323

24-
25-
Example using `annotation.ref`:
24+
Here's an example using `annotation.ref`, followed by teh same example rewritte to use `annotation.xref` and `annotation.yref`:
2625

2726
```js
2827
...
@@ -39,8 +38,6 @@ var layout = {
3938
...
4039
```
4140

42-
Example using `annotation.xref` and `annotation.yref`:
43-
4441
```js
4542
...
4643
var layout = {
@@ -65,7 +62,7 @@ The `autotick` attribute has been removed. Use `tickmode: 'auto'` instead of `au
6562

6663
The `bardir` attribute for setting the bar direction on bar charts has been removed. Use `orientation` instead.
6764

68-
Here's an example using `bardir` to make the bars horizontal:
65+
Here's an example using `bardir` to make the bars horizontal, followed by the same example rewritten to use `orientation`:
6966

7067
```js
7168
var data = [{
@@ -89,8 +86,6 @@ var layout = {
8986
Plotly.newPlot('bar-chart', data, layout);
9087
```
9188

92-
And here it is rewritten to use `orientation`:
93-
9489
```js
9590
var data = [{
9691
type: 'bar',
@@ -173,7 +168,7 @@ Plotly.newPlot('myDiv', data);
173168

174169
The `opacity` attribute on error bars has been removed. Use the alpha channel of the `color` attribute instead.
175170

176-
Here's an example that was previously in the Plotly.js docs, and which uses `opacity`.
171+
Here's an example that was previously in the Plotly.js docs, and which uses `opacity`, followed by the same example rewritten to use the alpha channel on a `rgba` color value.
177172

178173
```
179174
error_y: {
@@ -186,7 +181,6 @@ Here's an example that was previously in the Plotly.js docs, and which uses `opa
186181
}
187182
188183
```
189-
And here it is rewritten to use the alpha channel on a `rgba` color value.
190184

191185
```
192186
error_y: {
@@ -207,8 +201,7 @@ Support for using jQuery events has been removed. Use [Plotly.js events](/javasc
207201

208202
`pointcloud` has been removed. Use `scattergl` instead.
209203

210-
Here's an example that was previously in the Plotly.js docs and which uses `pointcloud`:
211-
204+
Here's an example that was previously in the Plotly.js docs and which uses `pointcloud`, followed by the same example rewritten to use `scattergl`:
212205

213206
```js
214207
var myPlot = document.getElementById('myDiv');
@@ -224,8 +217,6 @@ layout = { };
224217
Plotly.newPlot('myDiv', data, layout);
225218
```
226219

227-
And here it is rewritten to use `scattergl`:
228-
229220
```js
230221
var myPlot = document.getElementById('myDiv');
231222

@@ -263,11 +254,36 @@ Plotly.newPlot('myDiv', data, layout);
263254
The `plot3dPixelRatio` option on `config` for setting the pixel ration during WebGL image export has been removed. Use `plotGlPixelRatio` instead.
264255

265256

257+
## `title` Attribute as a String
258+
259+
The `title` attribute can no longer be set as a string. Use `title.text` instead. Here's an example of how to set the title using `title.text`:
260+
261+
```js
262+
var data = [
263+
{
264+
x: [1, 2, 3, 4, 5],
265+
y: [1, 2, 4, 8, 16]
266+
}
267+
];
268+
269+
var layout = {
270+
title: { text: "My chart title" },
271+
xaxis: {
272+
title: {
273+
text: "x-axis title"
274+
}
275+
},
276+
yaxis: { title: { text: "y-axis title" } }
277+
};
278+
279+
Plotly.newPlot("myDiv", data, layout);
280+
```
281+
266282
### `titlefont`,`titleposition`, `titleside`, and `titleoffset` Attributes
267283

268284
The `titlefont`,`titleposition`, `titleside`, and `titleoffset` attributes are removed. Replace them with `title.font`, `title.position`, `title.side`, and `title.offset`.
269285

270-
Here's an example that uses `titlefont`:
286+
Here's an example that uses `titlefont`, followed by the same example rewritten to use `title.font`:
271287

272288
```js
273289
var data = [{
@@ -288,8 +304,6 @@ var layout = {
288304
Plotly.newPlot('chart', data, layout);
289305
```
290306

291-
And here it is rewritten to use `title.font`:
292-
293307
```js
294308
var data = [{
295309
type: 'bar',

0 commit comments

Comments
 (0)