Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Nov 12, 2024
1 parent 16ef068 commit 3f9a454
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
1 change: 0 additions & 1 deletion dev_docs/tutorials/advanced_settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export class ChartsPlugin implements Plugin<ChartsPluginSetup, ChartsPluginStart
};
}
}

```

### Server side usage
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/vis_types/vislib/public/vislib/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@ class D3MappableObject {
* @param attr {Object|*} Visualization options
*/
export class Data {
constructor(data, uiState, createColorLookupFunction) {
constructor(data, uiState) {
this.uiState = uiState;
this.createColorLookupFunction = createColorLookupFunction;
this.data = this.copyDataObj(data);
this.type = this.getDataType();
this.labels = this._getLabels(this.data);
this.color = this.labels
? createColorLookupFunction(this.labels, uiState.get('vis.colors'))
: undefined;
this._normalizeOrdered();
}

Expand Down Expand Up @@ -385,7 +381,7 @@ export class Data {
const defaultColors = this.uiState.get('vis.defaultColors');
const overwriteColors = this.uiState.get('vis.colors');
const colors = defaultColors ? _.defaults({}, overwriteColors, defaultColors) : overwriteColors;
return this.createColorLookupFunction(this.getLabels(), colors);
return (value) => colors[value];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/vis_types/vislib/public/vislib/lib/vis_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const DEFAULT_VIS_CONFIG = {
};

export class VisConfig {
constructor(visConfigArgs, data, uiState, el, createColorLookupFunction) {
this.data = new Data(data, uiState, createColorLookupFunction);
constructor(visConfigArgs, data, uiState, el) {
this.data = new Data(data, uiState);

const visType = visTypes[visConfigArgs.type];
const typeDefaults = visType(visConfigArgs, this.data);
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/vis_types/vislib/public/vislib/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ export class Vis extends EventEmitter {
initVisConfig(data, uiState) {
this.data = data;
this.uiState = uiState;
this.visConfig = new VisConfig(
this.visConfigArgs,
this.data,
this.uiState,
this.element,
this.charts.legacyColors.createColorLookupFunction.bind(this.charts.legacyColors)
);
this.visConfig = new VisConfig(this.visConfigArgs, this.data, this.uiState, this.element);
}

/**
Expand Down

0 comments on commit 3f9a454

Please sign in to comment.