| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 2 | |
| 3 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{ |
| 4 | Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, |
| 5 | layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::{Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#, Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}, |
| 6 | }; |
| 7 | |
| 8 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 9 | apprust-analyzer cargo bottom 0.14.9 app/::{Apprust-analyzer cargo bottom 0.14.9 app/App#, AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#}, |
| 10 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 11 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 12 | componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::time_seriesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/::{AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#, ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#, GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#, LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#}, |
| 13 | drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label()., |
| 14 | }, |
| 15 | componentsrust-analyzer cargo bottom 0.14.9 components/::time_seriesrust-analyzer cargo bottom 0.14.9 components/time_series/::GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#, |
| 16 | }; |
| 17 | |
| 18 | impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# { |
| 19 | pub fn draw_temperature_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/impl#[Painter]draw_temperature_graph().( |
| 20 | &self, f: &mut Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#<'_>, app_state: &mut Apprust-analyzer cargo bottom 0.14.9 app/App#, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64, |
| 21 | ) { |
| 22 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_state) = app_state |
| 23 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 24 | .temp_graph_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#temp_graph_state. |
| 25 | .get_mut_widget_staterust-analyzer cargo bottom 0.14.9 app/states/impl#[TempGraphStates]get_mut_widget_state().(widget_id) |
| 26 | { |
| 27 | let shared_data = app_state.data_storerust-analyzer cargo bottom 0.14.9 app/App#data_store..get_datarust-analyzer cargo bottom 0.14.9 app/data/store/impl#[DataStore]get_data().(); |
| 28 | let points = &(shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature.); |
| 29 | let times = &(shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time.); |
| 30 | |
| 31 | let border_style = self.get_border_stylerust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_border_style().(widget_id, app_state.current_widgetrust-analyzer cargo bottom 0.14.9 app/App#current_widget..widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.); |
| 32 | let hide_x_labels = should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label().( |
| 33 | app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..hide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#hide_time., |
| 34 | app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..autohide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#autohide_time., |
| 35 | widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#graph..state_mutrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]state_mut().().autohide_timer_mutrust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]autohide_timer_mut().(), |
| 36 | draw_loc, |
| 37 | ); |
| 38 | |
| 39 | let y_max = widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#graph..y_maxrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]y_max().(points.valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().(), times); |
| 40 | let (adjusted_y_max, y_labels) = |
| 41 | adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(y_max, widget_state.max_temprust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#max_temp., &app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields.); |
| 42 | let y_bounds = AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#::Maxrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#Max#(adjusted_y_max); |
| 43 | |
| 44 | // Hide the legend if the width is 90% of the total widget width |
| 45 | // or the height is greater than 50% of the total widget height. |
| 46 | let legend_constraints = LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints# { |
| 47 | widthrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#width.: Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Ratiorust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Ratio#(9, 10), |
| 48 | heightrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#height.: Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Ratiorust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Ratio#(1, 2), |
| 49 | }; |
| 50 | |
| 51 | let unit = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type..unitrust-analyzer cargo bottom 0.14.9 app/data/temperature/impl#[TemperatureType]unit().(); |
| 52 | let graph_data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#<'_, f32>> = points |
| 53 | .iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 54 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 55 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(itx, (source, values))| { |
| 56 | // TODO: Maybe align the value later. |
| 57 | let name = match values.lastrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]last().() { |
| 58 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(latest) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{source}: {latest:.0}{unit}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 59 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => source.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 60 | }; |
| 61 | GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`][Default]default().() |
| 62 | .namerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]name().(name) |
| 63 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().( |
| 64 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..temp_graph_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#temp_graph_colour_styles. |
| 65 | [rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().itx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..temp_graph_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#temp_graph_colour_styles..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 66 | ) |
| 67 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 68 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(values) |
| 69 | }) |
| 70 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 71 | |
| 72 | let marker = self.get_markerrust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_marker().(app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_dotrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_dot.); |
| 73 | |
| 74 | let y_labels: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> = y_labels.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 75 | |
| 76 | widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#graph..drawrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]draw().( |
| 77 | f, |
| 78 | draw_loc, |
| 79 | GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx# { |
| 80 | titlerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title.: " Temperature ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 81 | border_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_style., |
| 82 | title_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..widget_title_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#widget_title_style., |
| 83 | graph_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#graph_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..graph_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#graph_style., |
| 84 | general_widget_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#general_widget_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..general_widget_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#general_widget_style., |
| 85 | border_typerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_type.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..border_typerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#border_type., |
| 86 | markerrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#marker., |
| 87 | hide_x_labelsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#hide_x_labels., |
| 88 | is_selectedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_selected.: app_state.current_widgetrust-analyzer cargo bottom 0.14.9 app/App#current_widget..widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().widget_id, |
| 89 | is_expandedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_expanded.: app_state.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded., |
| 90 | legend_positionrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_position.: app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..temperature_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_legend_position., |
| 91 | legend_constraintsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_constraints.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(legend_constraints), |
| 92 | }, |
| 93 | y_bounds, |
| 94 | &y_labels, |
| 95 | ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#::Linearrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#Linear#, |
| 96 | graph_data, |
| 97 | ); |
| 98 | } |
| 99 | |
| 100 | // Update draw loc in widget map. |
| 101 | if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() |
| 102 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(temperature_graph_widget) = app_state.widget_maprust-analyzer cargo bottom 0.14.9 app/App#widget_map..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&widget_id) |
| 103 | { |
| 104 | temperature_graph_widget.top_left_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#top_left_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.)); |
| 105 | temperature_graph_widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = |
| 106 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.)); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /// Returns the required labels. |
| 112 | fn adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().( |
| 113 | max_entry: f64, upper_limit: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<f32>, config: &AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#, |
| 114 | ) -> (f64, [Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; 3]) { |
| 115 | let default_upper: f64 = config |
| 116 | .temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type. |
| 117 | .convert_temp_unit_floatrust-analyzer cargo bottom 0.14.9 app/data/temperature/impl#[TemperatureType]convert_temp_unit_float().(100.0) |
| 118 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 119 | let unit = config.temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type..unitrust-analyzer cargo bottom 0.14.9 app/data/temperature/impl#[TemperatureType]unit().(); |
| 120 | |
| 121 | let max_entry = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit) = upper_limit { |
| 122 | limit as f64 |
| 123 | } else if max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().default_upper { |
| 124 | default_upper |
| 125 | } else { |
| 126 | max_entry |
| 127 | }; |
| 128 | |
| 129 | let halfway_label = (max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().2.0).ceilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]ceil().() as u32; |
| 130 | let max_entry_label = max_entry.ceilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]ceil().() as u32; |
| 131 | |
| 132 | let labels = [ |
| 133 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("0{unit}"), |
| 134 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{halfway_label}{unit}"), |
| 135 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{max_entry_label}{unit}"), |
| 136 | ]; |
| 137 | |
| 138 | (max_entry, labels) |
| 139 | } |
| 140 | |
| 141 | #[cfg(test)] |
| 142 | mod testsrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/ { |
| 143 | use superrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/::*; |
| 144 | use craterust-analyzer cargo bottom 0.14.9 crate/::apprust-analyzer cargo bottom 0.14.9 app/::datarust-analyzer cargo bottom 0.14.9 app/data/::TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#; |
| 145 | |
| 146 | fn configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(temperature_type: TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#) -> AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields# { |
| 147 | AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields# { |
| 148 | temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type., |
| 149 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 app/impl#[AppConfigFields][Default]default().() |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 154 | fn floors_to_default_upper_when_belowrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/floors_to_default_upper_when_below().() { |
| 155 | let cfg = configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Celsiusrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Celsius#); |
| 156 | let (max, labels) = adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(40.0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &cfg); |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(max, 100.0); |
| 158 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(labels, ["0°C", "50°C", "100°C"]); |
| 159 | } |
| 160 | |
| 161 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 162 | fn keeps_actual_max_when_above_defaultrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/keeps_actual_max_when_above_default().() { |
| 163 | let cfg = configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Celsiusrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Celsius#); |
| 164 | let (max, labels) = adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(120.0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &cfg); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(max, 120.0); |
| 166 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(labels, ["0°C", "60°C", "120°C"]); |
| 167 | } |
| 168 | |
| 169 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 170 | fn upper_limit_overrides_actual_maxrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/upper_limit_overrides_actual_max().() { |
| 171 | let cfg = configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Celsiusrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Celsius#); |
| 172 | let (max, labels) = adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(150.0, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(80.0), &cfg); |
| 173 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(max, 80.0); |
| 174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(labels, ["0°C", "40°C", "80°C"]); |
| 175 | } |
| 176 | |
| 177 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 178 | fn fahrenheit_default_is_212rust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/fahrenheit_default_is_212().() { |
| 179 | let cfg = configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Fahrenheitrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Fahrenheit#); |
| 180 | let (max, labels) = adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(100.0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &cfg); |
| 181 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(max, 212.0); |
| 182 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(labels, ["0°F", "106°F", "212°F"]); |
| 183 | } |
| 184 | |
| 185 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 186 | fn kelvin_default_is_373rust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/kelvin_default_is_373().() { |
| 187 | let cfg = configrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/tests/config().(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Kelvinrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Kelvin#); |
| 188 | let (max, labels) = adjust_temp_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/adjust_temp_data_point().(100.0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &cfg); |
| 189 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!((max -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). 373.15).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). 1e-3); |
| 190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(labels, ["0K", "187K", "374K"]); |
| 191 | } |
| 192 | } |