Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up factor range and add factor method #14037

Merged
merged 15 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
remove unnecessary internal properties
  • Loading branch information
bryevdv committed Aug 23, 2024
commit 1bf9b7a4fe6ca4c0e5602a5a7270081456054250
20 changes: 7 additions & 13 deletions bokehjs/src/lib/models/ranges/factor_range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type MappingEntry = {value: number, mapping?: L1Mapping | L2Mapping}
export function map_one_level(
factors: L1Factor[],
padding: number,
offset: number = 0
offset: number = 0,
): MappingSpec {
const mapping: L1Mapping = new Map()

Expand All @@ -68,7 +68,7 @@ export function map_two_levels(
factors: L2Factor[],
outer_pad: number,
factor_pad: number,
offset: number = 0
offset: number = 0,
): MappingSpec {
const mapping: L2Mapping = new Map()

Expand Down Expand Up @@ -98,7 +98,7 @@ export function map_three_levels(
outer_pad: number,
inner_pad: number,
factor_pad: number,
offset: number = 0
offset: number = 0,
): MappingSpec {
const mapping: L3Mapping = new Map()

Expand Down Expand Up @@ -174,16 +174,16 @@ export namespace FactorRange {
range_padding_units: p.Property<PaddingUnits>
start: p.Property<number>
end: p.Property<number>

levels: p.Property<number>
mids: p.Property<[string, string][] | null>
tops: p.Property<string[] | null>
}
}

export interface FactorRange extends FactorRange.Attrs {}

export class FactorRange extends Range {
levels: number
mids: L2Factor[] | null
tops: L1Factor[] | null

declare properties: FactorRange.Props

constructor(attrs?: Partial<FactorRange.Attrs>) {
Expand All @@ -201,12 +201,6 @@ export class FactorRange extends Range {
start: [ Float, p.unset, {readonly: true} ],
end: [ Float, p.unset, {readonly: true} ],
}))

this.internal<FactorRange.Props>(({Int, Str, List, Tuple, Nullable}) => ({
levels: [ Int ], // how many levels of nesting
mids: [ Nullable(List(Tuple(Str, Str))), null ], // mid level factors (if 3 total levels)
tops: [ Nullable(List(Str)), null ], // top level factors (whether 2 or 3 total levels)
}))
}

protected mapping: Mapping
Expand Down
Loading