Skip to content

Commit

Permalink
Merge branch 'bokeh:branch-3.6' into branch-3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman305 authored Sep 16, 2024
2 parents 7c8eb8c + f1824dc commit 17ec08b
Show file tree
Hide file tree
Showing 97 changed files with 2,913 additions and 1,562 deletions.
26 changes: 26 additions & 0 deletions bokehjs/src/less/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
.tool-icon-mask(var(--bokeh-icon-copy));
}

.bk-tool-icon-open {
.tool-icon-mask(var(--bokeh-icon-open));
}

.bk-tool-icon-replace-mode {
.tool-icon(--bokeh-icon-replace-mode, "ReplaceMode");
}
Expand Down Expand Up @@ -110,6 +114,22 @@
.tool-icon-mask(var(--bokeh-icon-y-pan));
}

.bk-tool-icon-pan-left {
.tool-icon-mask(var(--bokeh-icon-pan-left));
}

.bk-tool-icon-pan-right {
.tool-icon-mask(var(--bokeh-icon-pan-right));
}

.bk-tool-icon-pan-up {
.tool-icon-mask(var(--bokeh-icon-pan-up));
}

.bk-tool-icon-pan-down {
.tool-icon-mask(var(--bokeh-icon-pan-down));
}

.bk-tool-icon-range {
.tool-icon(--bokeh-icon-range, "Range");
}
Expand Down Expand Up @@ -232,6 +252,7 @@

--bokeh-icon-save: data-uri("icons/save.svg");
--bokeh-icon-copy: data-uri("icons/copy.svg");
--bokeh-icon-open: data-uri("icons/open.svg");

--bokeh-icon-tap-select: data-uri("icons/tap.svg");
--bokeh-icon-lasso-select: data-uri("icons/lasso-select.svg");
Expand All @@ -240,6 +261,11 @@
--bokeh-icon-x-pan: data-uri("icons/x-pan.svg");
--bokeh-icon-y-pan: data-uri("icons/y-pan.svg");

--bokeh-icon-pan-left: data-uri("icons/pan_left.svg");
--bokeh-icon-pan-right: data-uri("icons/pan_right.svg");
--bokeh-icon-pan-up: data-uri("icons/pan_up.svg");
--bokeh-icon-pan-down: data-uri("icons/pan_down.svg");

--bokeh-icon-box-select: data-uri("icons/box-select.svg");
--bokeh-icon-x-box-select: data-uri("icons/x-box-select.svg");
--bokeh-icon-y-box-select: data-uri("icons/y-box-select.svg");
Expand Down
4 changes: 4 additions & 0 deletions bokehjs/src/less/icons/open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bokehjs/src/less/icons/pan_down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bokehjs/src/less/icons/pan_left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bokehjs/src/less/icons/pan_right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bokehjs/src/less/icons/pan_up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions bokehjs/src/less/widgets/palette_select_item.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
gap: 0.5em;
}

.bk-swatch {
width: 100px;
height: auto;
align-self: stretch;
}

.bk-item {
--active-tool-highlight: #26aae1;

Expand Down
13 changes: 13 additions & 0 deletions bokehjs/src/lib/api/glyph_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MathMLGlyph as MathML,
MultiLine,
MultiPolygons,
Ngon,
Patch,
Patches,
Quad,
Expand Down Expand Up @@ -167,6 +168,7 @@ export type MarkerArgs = GlyphArgs<Marker.Props> & AuxLine & AuxFi
export type MathMLArgs = GlyphArgs<MathML.Props> & AuxText
export type MultiLineArgs = GlyphArgs<MultiLine.Props> & AuxLine
export type MultiPolygonsArgs = GlyphArgs<MultiPolygons.Props> & AuxLine & AuxFill & AuxHatch
export type NgonArgs = GlyphArgs<Ngon.Props> & AuxLine & AuxFill & AuxHatch
export type PatchArgs = GlyphArgs<Patch.Props> & AuxLine & AuxFill & AuxHatch
export type PatchesArgs = GlyphArgs<Patches.Props> & AuxLine & AuxFill & AuxHatch
export type QuadArgs = GlyphArgs<Quad.Props> & AuxLine & AuxFill & AuxHatch
Expand Down Expand Up @@ -436,6 +438,17 @@ export abstract class GlyphAPI {
return this._glyph(MultiPolygons, "multi_polygons", ["xs", "ys"], args)
}

ngon(): GlyphRenderer<Ngon>
ngon(args: Partial<NgonArgs>): GlyphRenderer<Ngon>
ngon(
x: NgonArgs["x"],
y: NgonArgs["y"],
radius: NgonArgs["radius"],
args?: Partial<NgonArgs>): GlyphRenderer<Ngon>
ngon(...args: unknown[]): GlyphRenderer<Ngon> {
return this._glyph(Ngon, "ngon", ["x", "y", "radius"], args)
}

patch(): GlyphRenderer<Patch>
patch(args: Partial<PatchArgs>): GlyphRenderer<Patch>
patch(
Expand Down
6 changes: 6 additions & 0 deletions bokehjs/src/lib/core/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export type OutputBackend = typeof OutputBackend["__type__"]
export const PaddingUnits = Enum("percent", "absolute")
export type PaddingUnits = typeof PaddingUnits["__type__"]

export const PanDirection = Enum(
"left", "right", "up", "down",
"west", "east", "north", "south",
)
export type PanDirection = typeof PanDirection["__type__"]

export const Place = Enum("above", "below", "left", "right", "center")
export type Place = typeof Place["__type__"]

Expand Down
37 changes: 37 additions & 0 deletions bokehjs/src/lib/core/hittest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,40 @@ export function check_2_segments_intersect(
return {hit: (a > 0 && a < 1) && (b > 0 && b < 1), x, y}
}
}

// Given two polygons, is any vertex of one inside the other
export function vertex_overlap(x0: Arrayable<number>, y0: Arrayable<number>, x1: Arrayable<number>, y1: Arrayable<number>): boolean {
// need to check "both directions" to handle total inclusion cases
for (let i = 0; i < x0.length; i++) {
if (point_in_poly(x0[i], y0[i], x1, y1)) {
return true
}
}
for (let i = 0; i < x1.length; i++) {
if (point_in_poly(x1[i], y1[i], x0, y0)) {
return true
}
}
return false
}

// Given two polygons, do any pair of edges intersect
export function edge_intersection(x0: Arrayable<number>, y0: Arrayable<number>, x1: Arrayable<number>, y1: Arrayable<number>): boolean {
for (let i = 0; i < x0.length-1; i++) {
for (let j = 0; j < x1.length-1; j++) {
if (check_2_segments_intersect(x0[i], y0[i], x0[i+1], y0[i+1], x1[j], y1[j], x1[j+1], y1[j+1]).hit) {
return true
}
}
// consider x1, y1 "closing" segment
if (check_2_segments_intersect(x0[i], y0[i], x0[i+1], y0[i+1], x1[x1.length-1], y1[x1.length-1], x1[0], y1[0]).hit) {
return true
}
}
// consider x0, y0, "closing" segment
if (check_2_segments_intersect(x0[x0.length-1], y0[x0.length-1], x0[0], y0[0], x1[x1.length-1], y1[x1.length-1], x1[0], y1[0]).hit) {
return true
}

return false
}
4 changes: 3 additions & 1 deletion bokehjs/src/lib/core/ui_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@ export class UIEventBus {
} else {
let result = false
for (const tool of this._tools.keys()) {
result ||= emit(tool)
// don't conflate these lines because of short circuiting nature of ||= operator
const emitted = emit(tool)
result ||= emitted
}
return result
}
Expand Down
11 changes: 8 additions & 3 deletions bokehjs/src/lib/core/util/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ function hex(v: uint8): string {
}

export function rgba2css([r, g, b, a]: RGBA): string {
return `rgba(${r}, ${g}, ${b}, ${a/255})`
const alpha = a == 255 ? "" : ` / ${a/255}`
return `rgb(${r} ${g} ${b}${alpha})`
}

export function color2css(color: Color | null, alpha?: number): string {
const [r, g, b, a] = color2rgba(color, alpha)
return rgba2css([r, g, b, a])
if (isString(color) && (alpha == null || alpha == 1.0)) {
return color // passthrough to persist color in its original form
} else {
const [r, g, b, a] = color2rgba(color, alpha)
return rgba2css([r, g, b, a])
}
}

export function color2hex(color: Color | null, alpha?: number): string {
Expand Down
4 changes: 2 additions & 2 deletions bokehjs/src/lib/core/util/eq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Comparator {
}

eq(a: any, b: any): boolean {
if (Object.is(a, b)) {
if (a === b || Object.is(a, b)) {
return true
}

Expand Down Expand Up @@ -127,7 +127,7 @@ export class Comparator {
}

numbers(a: number, b: number): boolean {
return Object.is(a, b)
return a === b || Object.is(a, b)
}

arrays(a: ArrayLike<unknown>, b: ArrayLike<unknown>): boolean {
Expand Down
2 changes: 1 addition & 1 deletion bokehjs/src/lib/core/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export namespace View {

export type IterViews<T extends View = View> = Generator<T, void, undefined>

export class View implements ISignalable, Equatable {
export abstract class View implements ISignalable, Equatable {
readonly removed = new Signal0<this>(this, "removed")

readonly model: HasProps
Expand Down
2 changes: 1 addition & 1 deletion bokehjs/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export namespace Model {

export interface Model extends Model.Attrs {}

export class Model extends HasProps {
export abstract class Model extends HasProps {
declare properties: Model.Props

private /*readonly*/ _js_callbacks: Map<string, (() => void)[]>
Expand Down
25 changes: 9 additions & 16 deletions bokehjs/src/lib/models/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ export type TickCoords = {
minor: Coords
}

export class AxisView extends GuideRendererView {
export abstract class AxisView extends GuideRendererView {
declare model: Axis
declare visuals: Axis.Visuals

declare readonly RangeType: Range

layout?: Layoutable

private _panel: SidePanel
Expand Down Expand Up @@ -332,10 +334,9 @@ export class AxisView extends GuideRendererView {

const [sxs, sys] = this.scoords(coords)
const [nx, ny] = this.normals
const [xoff, yoff] = this.offsets

const [nxin, nyin] = [nx * (xoff-tin), ny * (yoff-tin)]
const [nxout, nyout] = [nx * (xoff+tout), ny * (yoff+tout)]
const [nxin, nyin] = [nx * -tin, ny * -tin]
const [nxout, nyout] = [nx * tout, ny * tout]

visuals.set_value(ctx)

Expand All @@ -360,12 +361,11 @@ export class AxisView extends GuideRendererView {
}

const [sxs, sys] = this.scoords(coords)
const [xoff, yoff] = this.offsets

const [nx, ny] = this.normals

const nxd = nx*(xoff + standoff)
const nyd = ny*(yoff + standoff)
const nxd = nx*standoff
const nyd = ny*standoff

const {vertical_align, align} = this.panel.get_label_text_heuristics(orient)
const angle = this.panel.get_label_angle_heuristic(orient)
Expand Down Expand Up @@ -557,12 +557,7 @@ export class AxisView extends GuideRendererView {
}
}

// TODO Remove this.
get offsets(): [number, number] {
return [0, 0]
}

get ranges(): [Range, Range] {
get ranges(): [typeof this["RangeType"], typeof this["RangeType"]] {
const i = this.dimension
const j = 1 - i
const {ranges} = this.coordinates
Expand Down Expand Up @@ -779,7 +774,7 @@ export namespace Axis {

export interface Axis extends Axis.Attrs {}

export class Axis extends GuideRenderer {
export abstract class Axis extends GuideRenderer {
declare properties: Axis.Props
declare __view_type__: AxisView

Expand All @@ -788,8 +783,6 @@ export class Axis extends GuideRenderer {
}

static {
this.prototype.default_view = AxisView

this.mixins<Axis.Mixins>([
["axis_", mixins.Line],
["major_tick_", mixins.Line],
Expand Down
Loading

0 comments on commit 17ec08b

Please sign in to comment.