-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate styling/visuals/css_variables.py to bokehjs
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
bokehjs/test/baselines/linux/Examples__should_support_CSSVariables.blf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Plot bbox=[0, 0, 600, 600] | ||
CartesianFrame bbox=[41, 27, 529, 551] | ||
LinearAxis bbox=[41, 578, 529, 22] | ||
LinearAxis bbox=[0, 27, 41, 551] | ||
Title bbox=[41, 0, 529, 27] | ||
ToolbarPanel bbox=[570, 27, 30, 551] |
Binary file added
BIN
+84.7 KB
bokehjs/test/baselines/linux/Examples__should_support_CSSVariables.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {display} from "../_util" | ||
|
||
import {figure} from "@bokehjs/api/plotting" | ||
import {Spectral11} from "@bokehjs/api/palettes" | ||
import {f} from "@bokehjs/api/expr" | ||
import {Random} from "@bokehjs/core/util/random" | ||
|
||
describe("Examples", () => { | ||
it("should support CSSVariables", async () => { | ||
const random = new Random(1) | ||
|
||
const N = 500 | ||
const x = f`${random.floats(N)}*${100}` | ||
const y = f`${random.floats(N)}*${100}` | ||
const radii = f`${random.floats(N)}*${1.5}` | ||
const colors = random.choices(N, Spectral11) | ||
|
||
const p = figure({active_scroll: "wheel_zoom", lod_threshold: null, title: "Plot styling with CSS variables"}) | ||
p.circle(x, y, radii, {fill_color: colors, fill_alpha: 0.6, line_color: null}) | ||
|
||
p.stylesheets.push(` | ||
:host { | ||
/* plot background */ | ||
--bk-background-fill-color: azure; | ||
/* common axis line dash */ | ||
--bk-axis-line-dash: dotted; | ||
/* common axis tick colors */ | ||
--tick-color: red; | ||
--bk-major-tick-line-color: var(--tick-color); | ||
--bk-minor-tick-line-color: var(--tick-color); | ||
} | ||
`) | ||
|
||
for (const axis of p.xaxes) { | ||
axis.stylesheets.push(` | ||
:host { | ||
/* x-axis background color */ | ||
--bk-background-fill-color: yellow; | ||
/* x-axis major label styling */ | ||
--bk-major-label-text-font-style: bold; | ||
} | ||
`) | ||
} | ||
|
||
for (const axis of p.yaxes) { | ||
axis.stylesheets.push(` | ||
:host { | ||
/* y-axis background color */ | ||
--bk-background-fill-color: pink; | ||
/* y-axis major label styling */ | ||
--bk-major-label-text-font-size: 1.25em; | ||
} | ||
`) | ||
} | ||
|
||
await display(p) | ||
}) | ||
}) |