Skip to content

Commit 968b644

Browse files
committed
add js colorway example
1 parent 383873c commit 968b644

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Set Default Trace Colors with colorway
3+
plot_url: https://codepen.io/plotly/embed/jeqNBq/?height=500&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: colorway
6+
order: 1
7+
sitemap: false
8+
arrangement: horizontal
9+
---
10+
11+
var linspace = require('linspace');
12+
const parabolaGen = (a, b) =>
13+
x => x*x*a + b;
14+
15+
var as = linspace(1, 3, 7);
16+
var bs = linspace(2, 14, 7);
17+
var x = linspace(-1, 3, 50);
18+
var data = [];
19+
20+
for (i=0; i< as.length; i++ ){
21+
data.push({
22+
type: "scatter",
23+
mode: "lines",
24+
x: x,
25+
y: x.map(parabolaGen(as[i],bs[i]))
26+
})
27+
}
28+
29+
var layout = {
30+
colorway : ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']
31+
};
32+
33+
Plotly.newPlot('myDiv', data, layout);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Colorway in JavaScript.
3+
name: Colorway
4+
permalink: javascript/colorway/
5+
description: How to use colorway to set default trace colors in Javascript with Plotly.
6+
layout: base
7+
thumbnail: thumbnail/colorway.jpg
8+
language: plotly_js
9+
page_type: example_index
10+
has_thumbnail: true
11+
display_as: style_opt
12+
order: 3
13+
---
14+
15+
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","colorway" | sort: "order" %}
16+
{% include auto_examples.html examples=examples %}

_posts/r/style/2018-10-03-colorway.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ layout: base
77
language: r
88
page_type: example_index
99
has_thumbnail: true
10+
thumbnail: thumbnail/colorway.jpg
1011
display_as: style_opt
1112
order: 5
1213
output:
@@ -37,7 +38,7 @@ library(plotly)
3738
packageVersion('plotly')
3839
```
3940

40-
### Set Default Trace Colors with colorway
41+
### Set Default Trace Colors with `colorway`
4142

4243
```{r, results = 'hide'}
4344
library(plotly)

_posts/r/style/2018-10-03-colorway.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ layout: base
77
language: r
88
page_type: example_index
99
has_thumbnail: true
10+
thumbnail: thumbnail/colorway.jpg
1011
display_as: style_opt
1112
order: 5
1213
output:
@@ -38,7 +39,7 @@ packageVersion('plotly')
3839
## [1] '4.8.0'
3940
```
4041

41-
### Set Default Trace Colors with colorway
42+
### Set Default Trace Colors with `colorway`
4243

4344

4445
```r

0 commit comments

Comments
 (0)