@@ -7,35 +7,24 @@ import type {
77 TableSubscription ,
88 TableData ,
99} from '@deephaven/jsapi-types' ;
10- import {
11- ChartModel ,
12- ChartUtils ,
13- ChartTheme ,
14- defaultChartTheme ,
15- } from '@deephaven/chart' ;
10+ import { ChartModel , ChartUtils } from '@deephaven/chart' ;
1611import Log from '@deephaven/log' ;
1712import {
1813 PlotlyChartWidgetData ,
19- applyColorwayToData ,
2014 getDataMappings ,
2115 getWidgetData ,
16+ removeColorsFromData ,
2217} from './PlotlyExpressChartUtils.js' ;
2318
2419const log = Log . module ( '@deephaven/js-plugin-plotly-express.ChartModel' ) ;
2520
2621export class PlotlyExpressChartModel extends ChartModel {
27- constructor (
28- dh : DhType ,
29- widget : Widget ,
30- refetch : ( ) => Promise < Widget > ,
31- theme : ChartTheme = defaultChartTheme ( )
32- ) {
22+ constructor ( dh : DhType , widget : Widget , refetch : ( ) => Promise < Widget > ) {
3323 super ( dh ) ;
3424
3525 this . widget = widget ;
3626 this . refetch = refetch ;
3727 this . chartUtils = new ChartUtils ( dh ) ;
38- this . theme = theme ;
3928
4029 this . handleFigureUpdated = this . handleFigureUpdated . bind ( this ) ;
4130 this . handleWidgetUpdated = this . handleWidgetUpdated . bind ( this ) ;
@@ -89,14 +78,10 @@ export class PlotlyExpressChartModel extends ChartModel {
8978 */
9079 tableDataMap : Map < number , { [ key : string ] : unknown [ ] } > = new Map ( ) ;
9180
92- theme : ChartTheme ;
93-
9481 plotlyData : Data [ ] = [ ] ;
9582
9683 layout : Partial < Layout > = { } ;
9784
98- plotlyLayout : Partial < Layout > = { } ;
99-
10085 isPaused = false ;
10186
10287 hasPendingUpdate = false ;
@@ -197,22 +182,11 @@ export class PlotlyExpressChartModel extends ChartModel {
197182
198183 updateLayout ( data : PlotlyChartWidgetData ) {
199184 const { figure } = data ;
200- const { plotly, deephaven } = figure ;
185+ const { plotly } = figure ;
201186 const { layout : plotlyLayout = { } } = plotly ;
202187
203- const template = { layout : this . chartUtils . makeDefaultLayout ( this . theme ) } ;
204-
205- // For now we will only use the plotly theme colorway since most plotly themes are light mode
206- if ( deephaven . is_user_set_template ) {
207- template . layout . colorway =
208- plotlyLayout . template ?. layout ?. colorway ?? template . layout . colorway ;
209- }
210-
211- this . plotlyLayout = plotlyLayout ;
212-
213188 this . layout = {
214189 ...plotlyLayout ,
215- template,
216190 } ;
217191 }
218192
@@ -225,17 +199,19 @@ export class PlotlyExpressChartModel extends ChartModel {
225199 new_references : newReferences ,
226200 removed_references : removedReferences ,
227201 } = data ;
228- const { plotly } = figure ;
202+ const { plotly, deephaven } = figure ;
203+ const { layout : plotlyLayout = { } } = plotly ;
229204 this . tableColumnReplacementMap = getDataMappings ( data ) ;
230205
231206 this . plotlyData = plotly . data ;
232207 this . updateLayout ( data ) ;
233208
234- applyColorwayToData (
235- this . layout ?. template ?. layout ?. colorway ?? [ ] ,
236- this . plotlyLayout ?. template ?. layout ?. colorway ?? [ ] ,
237- this . plotlyData
238- ) ;
209+ if ( ! deephaven . is_user_set_template ) {
210+ removeColorsFromData (
211+ plotlyLayout ?. template ?. layout ?. colorway ?? [ ] ,
212+ this . plotlyData
213+ ) ;
214+ }
239215
240216 newReferences . forEach ( async ( id , i ) => {
241217 this . tableDataMap . set ( id , { } ) ; // Plot may render while tables are being fetched. Set this to avoid a render error
0 commit comments