File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " react-chart-editor" ,
33 "description" : " plotly.js chart editor react component UI" ,
4- "version" : " 0.22.0 " ,
4+ "version" : " 0.22.1 " ,
55 "author" : " Plotly, Inc." ,
66 "bugs" : {
77 "url" : " https://github.com/plotly/react-chart-editor/issues"
1919 "prop-types" : " ^15.5.10" ,
2020 "raf" : " ^3.4.0" ,
2121 "react-color" : " ^2.13.8" ,
22- "react-colorscales" : " 0.5.8 " ,
22+ "react-colorscales" : " 0.5.9 " ,
2323 "react-dropzone" : " ^4.2.9" ,
2424 "react-plotly.js" : " ^2.2.0" ,
2525 "react-rangeslider" : " ^2.2.0" ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class Colorscale extends Component {
1010 this . onUpdate = this . onUpdate . bind ( this ) ;
1111 }
1212
13- onUpdate ( colorscale ) {
13+ onUpdate ( colorscale , colorscaleType ) {
1414 if ( Array . isArray ( colorscale ) ) {
1515 this . props . updatePlot (
1616 colorscale . map ( ( c , i ) => {
@@ -19,7 +19,8 @@ class Colorscale extends Component {
1919 step = 0 ;
2020 }
2121 return [ step , c ] ;
22- } )
22+ } ) ,
23+ colorscaleType
2324 ) ;
2425 }
2526 }
Original file line number Diff line number Diff line change @@ -100,13 +100,33 @@ class UnconnectedMarkerColor extends Component {
100100 ) ;
101101 }
102102
103- setColors ( colorscale ) {
103+ setColors ( colorscale , colorscaleType ) {
104104 const numberOfTraces = this . context . traceIndexes . length ;
105105 const colors = colorscale . map ( c => c [ 1 ] ) ;
106106
107- let adjustedColors = getColorscale ( colors , numberOfTraces ) ;
108- if ( adjustedColors . every ( c => c === adjustedColors [ 0 ] ) ) {
109- adjustedColors = colors ;
107+ let adjustedColors = colors ;
108+
109+ if ( colorscaleType !== 'categorical' ) {
110+ adjustedColors = getColorscale (
111+ colors ,
112+ numberOfTraces ,
113+ null ,
114+ null ,
115+ colorscaleType
116+ ) ;
117+ }
118+
119+ if (
120+ adjustedColors . every ( c => c === adjustedColors [ 0 ] ) ||
121+ colorscaleType === 'categorical'
122+ ) {
123+ const repetitions = Math . ceil ( numberOfTraces / colors . length ) ;
124+ const newArray = new Array ( repetitions ) . fill ( colors ) ;
125+ adjustedColors = newArray
126+ . reduce ( ( a , b ) => {
127+ return a . concat ( b ) ;
128+ } , [ ] )
129+ . slice ( 0 , numberOfTraces ) ;
110130 }
111131
112132 const updates = adjustedColors . map ( color => ( {
You can’t perform that action at this time.
0 commit comments