Skip to content

Commit 554f660

Browse files
jqnatividadclaude
andcommitted
fix(indicator): use common::Ticks for GaugeAxis to allow disabling ticks
gauge.axis.ticks accepts "outside", "inside", or "" (disabled). TicksDirection only covers inside/outside, so "no ticks" was inexpressible. Switch to common::Ticks (Outside/Inside/None -> "outside"/"inside"/"") and add a test that Ticks::None serializes to "". Addresses roborev review job 3599 (the tickmode finding in that review was a false positive: the v3.7.0 schema lists gauge.axis.tickmode as ["auto","linear","array"], so TickMode::Auto is valid). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ef4cbca commit 554f660

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

plotly/src/traces/indicator.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use plotly_derive::FieldSetter;
66
use serde::Serialize;
77

88
use crate::color::Color;
9-
use crate::layout::{ArrayShow, TicksDirection};
9+
use crate::layout::ArrayShow;
1010
use crate::private::{NumOrString, NumOrStringCollection};
1111
use crate::{
12-
common::{Domain, ExponentFormat, Font, Line, PlotType, TickFormatStop, TickMode},
12+
common::{Domain, ExponentFormat, Font, Line, PlotType, TickFormatStop, TickMode, Ticks},
1313
Trace,
1414
};
1515

@@ -185,8 +185,9 @@ pub struct GaugeAxis {
185185
/// [`TickMode::Array`]).
186186
#[serde(rename = "ticktext")]
187187
tick_text: Option<Vec<String>>,
188-
/// Determines whether ticks are drawn inside or outside the axis line.
189-
ticks: Option<TicksDirection>,
188+
/// Determines whether ticks are drawn inside or outside the axis line
189+
/// ([`Ticks::None`] disables them).
190+
ticks: Option<Ticks>,
190191
/// Sets the tick length (in px).
191192
#[serde(rename = "ticklen")]
192193
tick_length: Option<usize>,
@@ -587,7 +588,7 @@ mod tests {
587588
"mid".to_string(),
588589
"high".to_string(),
589590
])
590-
.ticks(TicksDirection::Outside)
591+
.ticks(Ticks::Outside)
591592
.tick_length(8)
592593
.tick_width(2)
593594
.tick_color("gray")
@@ -651,6 +652,13 @@ mod tests {
651652
assert!(v["tickformatstops"].is_array());
652653
}
653654

655+
#[test]
656+
fn serialize_gauge_axis_ticks_none() {
657+
// The gauge-axis schema allows "" to disable tick marks.
658+
let axis = GaugeAxis::new().ticks(Ticks::None);
659+
assert_eq!(to_value(axis).unwrap()["ticks"], json!(""));
660+
}
661+
654662
#[test]
655663
fn serialize_indicator_legend_and_uirevision() {
656664
let trace = Indicator::new(1.0)

0 commit comments

Comments
 (0)