From 13ba9d0f6bcb063cc6a288059db47ee08092ad01 Mon Sep 17 00:00:00 2001 From: DArtagnant <105509558+DArtagnant@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:03:26 +0100 Subject: [PATCH 1/2] removes last 'style' occurrences --- plotst/axis.typ | 10 ++++------ plotst/plotting.typ | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plotst/axis.typ b/plotst/axis.typ index 590ebd1..6df58c5 100644 --- a/plotst/axis.typ +++ b/plotst/axis.typ @@ -108,7 +108,7 @@ // returns the expected need of space as a (width, height) array // axis: the axis // style: styling -#let measure_axis(axis, style) = { +#let measure_axis(axis) = { let invert_markings = 1 if axis.location == "right" { invert_markings = -1 @@ -177,7 +177,7 @@ // Places the title //place(dy: -50%, rotate(-90deg, axis.title)) // TODO context { - let a = measure_axis(axis, style).at(0) + let a = measure_axis(axis).at(0) if axis.location == "left" { place(dy: pos.at(1) - length / 2, dx: -length/2 - a, rotate(-90deg, origin: center + top, box(width: length, height:0pt, align(center+top, axis.title)))) } else { @@ -224,10 +224,8 @@ if axis.location == "bottom" { place(dx: pos.at(0), dy: 3pt, align(top + center, box(width: length, height: 0pt, [\ #axis.title]))) } else { - style(style => { - let a = measure_axis(axis, style).at(1) - layout(size => place(dy: -size.height - a, align(top + center, box(width: length, height: 0pt, [#axis.title])))) - }) + let a = measure_axis(axis).at(1) + layout(size => place(dy: -size.height - a, align(top + center, box(width: length, height: 0pt, [#axis.title])))) } // Draws step markings diff --git a/plotst/plotting.typ b/plotst/plotting.typ index 8c78871..5ff4c5d 100644 --- a/plotst/plotting.typ +++ b/plotst/plotting.typ @@ -11,7 +11,7 @@ let offset_bottom = 0pt // Draw coordinate system for axis in plot.axes { - let (w,h) = measure_axis(axis, style) + let (w,h) = measure_axis(axis) if(axis.location == "left") { offset_left += w } From 5ecfa5d1713077564d1858b635b94ff7d47eea70 Mon Sep 17 00:00:00 2001 From: DArtagnant <105509558+DArtagnant@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:56:26 +0000 Subject: [PATCH 2/2] update type(...) instructions to typst 0.13+ --- plotst/axis.typ | 4 ++-- plotst/plotting.typ | 36 ++++++++++++++++++------------------ plotst/util/util.typ | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/plotst/axis.typ b/plotst/axis.typ index 6df58c5..667d58c 100644 --- a/plotst/axis.typ +++ b/plotst/axis.typ @@ -89,9 +89,9 @@ #let format(axis, value) = { let fmt = axis.value_formatter - if type(fmt) == "string" { + if type(fmt) == str { return strfmt(fmt, value) - } else if type(fmt) == "function" { + } else if type(fmt) == function { return fmt(value) } } diff --git a/plotst/plotting.typ b/plotst/plotting.typ index 5ff4c5d..19c6be3 100644 --- a/plotst/plotting.typ +++ b/plotst/plotting.typ @@ -61,7 +61,7 @@ // if you want to make the axes visible (only if plot is set) //------- #let prepare_plot(size, caption, plot_code, plot: (), render_axis: true) = { - let (width, height) = if type(size) == "array" {size} else {(size, size)} + let (width, height) = if type(size) == array {size} else {(size, size)} figure(caption: caption, supplement: "Graph", kind: "plot", { // Graph box set align(left + bottom) @@ -147,10 +147,10 @@ let step_size_y = calc_step_size(100%, y_axis) // Places the data points for (x,y) in plot.data { - if type(x) == "string" { + if type(x) == str { x = x_axis.values.position(c => c == x) } - if type(y) == "string" { + if type(y) == str { y = y_axis.values.position(c => c == y) } if stroke != none or fill != none { // DELETEME deprecation, only keep else @@ -194,10 +194,10 @@ let step_size_y = calc_step_size(100%, y_axis) // Places the data points let data = plot.data.map(((x,y)) => { - if type(x) == "string" { + if type(x) == str { x = x_axis.values.position(c => c == x) } - if type(y) == "string" { + if type(y) == str { y = y_axis.values.position(c => c == y) } ((x - x_axis.min) * step_size_x, -(y - y_axis.min) * step_size_y) @@ -266,8 +266,8 @@ let step_size_x = calc_step_size(100%, x_axis) let step_size_y = calc_step_size(100%, y_axis) - let array_stroke = type(stroke) == "array" - let array_fill = type(fill) == "array" + let array_stroke = type(stroke) == array + let array_fill = type(fill) == array // Get count of values let val_count = 0 for data in plot.data { @@ -376,7 +376,7 @@ let data = plot.data - if not type(data.at(0)) == "array" { + if not type(data.at(0)) == array { let new_data = ((0, data.at(0)),) for value in data { let found = false @@ -490,14 +490,14 @@ let step_size_y = calc_step_size(100%, y_axis) // get correct data let data = transform_data_count(plot.data) - let array_stroke = type(stroke) == "array" - let array_fill = type(fill) == "array" + let array_stroke = type(stroke) == array + let array_fill = type(fill) == array // draw the bars if not rotated { for (idx, data_set) in data.enumerate() { let height = data_set.at(0) * step_size_y let x_data = data_set.at(1) - if type(data_set.at(1)) == "string" { + if type(data_set.at(1)) == str { x_data = x_axis.values.position(c => c == x_data) } let x_pos = x_data * step_size_x - if centered_bars {step_size_x * bar_width / 2} else {0pt} @@ -510,7 +510,7 @@ for (idx, data_set) in data.enumerate() { let width = data_set.at(0) * step_size_x let y_data = data_set.at(1) - if type(data_set.at(1)) == "string" { + if type(data_set.at(1)) == str { y_data = y_axis.values.position(c => c == y_data) } let y_pos = y_data * step_size_y + if centered_bars {step_size_y * bar_width / 2} else {0pt} @@ -549,10 +549,10 @@ let y_axis = plot.axes.at(1) let plot_code() = { let data = plot.data.map(((x,y)) => { - if type(x) == "string" { + if type(x) == str { x = x_axis.values.position(c => c == x) } - if type(y) == "string" { + if type(y) == str { y = y_axis.values.position(c => c == y) } (x,y) @@ -643,10 +643,10 @@ data = if pre_calculated {plot.data} else {data} // let data = transform_data_count(plot.data) - let array_stroke = type(stroke) == "array" - let array_fill = type(fill) == "array" + let array_stroke = type(stroke) == array + let array_fill = type(fill) == array // draw the boxes - data = if type(data.at(0)) == "array" { + data = if type(data.at(0)) == array { data } else { (data,) @@ -654,7 +654,7 @@ for (idx, data_set) in data.enumerate() { let q(i) = (data_set.at(i) - y_axis.min) * step_size_y let x_data = data_set.at(5, default: idx + 1) - if type(x_data) == "string" { + if type(x_data) == str { x_data = x_axis.values.position(c => c == x_data) } let box_width = step_size_x * box_width diff --git a/plotst/util/util.typ b/plotst/util/util.typ index a4562d3..8b5c997 100644 --- a/plotst/util/util.typ +++ b/plotst/util/util.typ @@ -10,7 +10,7 @@ // transforms a data list ((amount, value),..) to a list only containing values #let transform_data_full(data_count) = { - if not type(data_count.at(0)) == "array" { + if not type(data_count.at(0)) == array { return data_count } let new_data = () @@ -24,7 +24,7 @@ // transforms a data list (val1, val2, ...) to a list looking like this ((amount, val1),...) #let transform_data_count(data_full) = { - if type(data_full.at(0)) == "array" { + if type(data_full.at(0)) == array { return data_full } @@ -48,7 +48,7 @@ // converts an integer or 2-long array to a width, height dictionary #let convert_size(size) = { - if type(size) == "int" { return (width: size, height: size) } + if type(size) == int { return (width: size, height: size) } if size.len() == 2 { return (width: size.at(0), height: size.at(1)) } } @@ -74,7 +74,7 @@ // range that supports float parameters #let float_range(min, max, step: 1) = { - if type(min) == "float" or type(max) == "float" or type(step) == "float" { + if type(min) == float or type(max) == float or type(step) == float { let it = () it.push(min) if step < 0 {