Skip to content

Commit

Permalink
Remove custom builtin color, install "viridis" npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
6nv committed Mar 6, 2024
1 parent 5d0df83 commit cbbe379
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 67 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
},
"dependencies": {
"smath": "1.1.1",
"viridis": "0.0.2",
"@emotion/css": "11.10.6",
"@grafana/data": "10.0.3",
"@grafana/runtime": "10.0.3",
Expand Down
63 changes: 0 additions & 63 deletions src/color.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/psychart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from 'color';
import { Color, Gradient } from 'viridis';
import { PsyState } from 'psystate';
import { SMath } from 'smath';
import { PsyOptions, Datum, Layout, Point, Region, StyleOptions, GradientName, RegionName, DataOptions } from './types';
Expand Down Expand Up @@ -369,7 +369,7 @@ export class Psychart {
}
});
}
this.drawRegion(data, Color.gradient(normalized, Psychart.gradients.Blue), region.tooltip);
this.drawRegion(data, new Gradient(Psychart.gradients.Blue).getColor(normalized), region.tooltip);
regionIndex++;
});
}
Expand Down Expand Up @@ -578,7 +578,7 @@ export class Psychart {
location = currentState.toXY();
// Compute the current color to plot
const normalized = this.getGradientX(time, startTime, endTime),
color = Color.gradient(normalized, Psychart.gradients[options.gradient as GradientName] ?? Psychart.gradients.Viridis);
color = new Gradient(Psychart.gradients[options.gradient as GradientName] ?? Psychart.gradients.Viridis).getColor(normalized);
// Determine whether to connect the states with a line
if (!!this.lastState[id]) {
this.g.trends.appendChild(this.createLine([this.lastState[id], currentState], color, +options.line));
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from 'color';
import { Color } from 'viridis';

export type Measurement = 'dbwb' | 'dbrh' | 'dbdp';
export type RegionName = 'Summer (sitting)' | 'Summer (walking)' | 'Summer (light work)' | 'Winter (sitting)' | 'Winter (walking)' | 'Winter (light work)' | 'Data Center A4' | 'Data Center A3' | 'Data Center A2' | 'Data Center A1' | 'Data Center Recommended (low pollutants)' | 'Data Center Recommended (high pollutants)';
Expand Down

0 comments on commit cbbe379

Please sign in to comment.