@@ -56,12 +56,11 @@ scatter(1:4, [0.01u"km", 0.02u"km", 0.03u"km", 0.04u"km"]; axis=(dim2_conversion
56
56
"""
57
57
struct DQConversion <: M.AbstractDimConversion
58
58
quantity:: M.Observable{Any}
59
- automatic_units:: Bool
60
59
units_in_label:: M.Observable{Bool}
61
60
end
62
61
63
62
function DQConversion (quantity= M. automatic; units_in_label= true )
64
- return DQConversion (quantity, quantity isa M . Automatic, units_in_label)
63
+ return DQConversion (quantity, units_in_label)
65
64
end
66
65
67
66
M. needs_tick_update_observable (conversion:: DQConversion ) = conversion. quantity
@@ -78,19 +77,22 @@ function M.get_ticks(conversion::DQConversion, ticks, scale, formatter, vmin, vm
78
77
end
79
78
80
79
function M. convert_dim_value (conversion:: DQConversion , attr, values, last_values)
81
- if conversion. automatic_units
80
+ if conversion. quantity[] isa M . Automatic
82
81
conversion. quantity[] = oneunit (first (values))
83
82
end
84
83
85
84
unit = conversion. quantity[]
85
+
86
86
if ! isempty (values)
87
87
# try if conversion works, to through error if not!
88
88
# Is there a function for this to check in DynamicQuantities?
89
89
unit_convert (unit, first (values))
90
90
end
91
+
91
92
return unit_convert (conversion. quantity[], values)
92
93
end
93
94
95
+ # Can probably be dropped, but keeping for correspondence with unitful-integration.jl in upstream Makie
94
96
function M. convert_dim_value (conversion:: DQConversion , values)
95
97
return unit_convert (conversion. quantity[], values)
96
98
end
106
108
using DynamicQuantities, Makie, Dates
107
109
const DQConversion = Base. get_extension (DynamicQuantities, :DynamicQuantitiesMakieExt ). DQConversion
108
110
109
- @recipe DQPlot (x, y ) begin
111
+ @recipe DQPlot (x,) begin
110
112
end
111
113
112
114
function Makie. plot! (plot:: DQPlot )
126
128
@testitem " unit switching" begin
127
129
using DynamicQuantities, Makie
128
130
f, ax, pl = scatter ((1 : 10 )u " m" )
129
- @test_throws DynamicQuantities. DimensionError scatter! (ax, (1 : 10 )u " kg" )
130
- @test_throws MethodError scatter! (ax, (1 : 10 ))
131
+ @test_throws Makie . ComputePipeline . ResolveException{T} where {T <: DynamicQuantities.DimensionError } scatter! (ax, (1 : 10 )u " kg" )
132
+ @test_throws Makie . ComputePipeline . ResolveException{ MethodError} scatter! (ax, (1 : 10 ))
131
133
end
132
134
133
135
@testitem " observables cleanup" begin
0 commit comments