1use std::borrow::Cow;
2
3use crate::key::{Horizontal, Justification, Order, Stacked, Vertical};
4use crate::{Axes, Axis, Color, Display, Grid, LineType, PointType, Terminal};
5
6impl Display<&'static str> for Axis {
7 fn display(&self) -> &'static str {
8 match *self {
9 Axis::BottomX => "x",
10 Axis::LeftY => "y",
11 Axis::RightY => "y2",
12 Axis::TopX => "x2",
13 }
14 }
15}
16
17impl Display<&'static str> for Axes {
18 fn display(&self) -> &'static str {
19 match *self {
20 Axes::BottomXLeftY => "x1y1",
21 Axes::BottomXRightY => "x1y2",
22 Axes::TopXLeftY => "x2y1",
23 Axes::TopXRightY => "x2y2",
24 }
25 }
26}
27
28impl Display<Cow<'static, str>> for Color {
29 fn display(&self) -> Cow<'static, str> {
30 match *self {
31 Color::Black => Cow::from("black"),
32 Color::Blue => Cow::from("blue"),
33 Color::Cyan => Cow::from("cyan"),
34 Color::DarkViolet => Cow::from("dark-violet"),
35 Color::ForestGreen => Cow::from("forest-green"),
36 Color::Gold => Cow::from("gold"),
37 Color::Gray => Cow::from("gray"),
38 Color::Green => Cow::from("green"),
39 Color::Magenta => Cow::from("magenta"),
40 Color::Red => Cow::from("red"),
41 Color::Rgb(r, g, b) => Cow::from(format!("#{:02x}{:02x}{:02x}", r, g, b)),
42 Color::White => Cow::from("white"),
43 Color::Yellow => Cow::from("yellow"),
44 }
45 }
46}
47
48impl Display<&'static str> for Grid {
49 fn display(&self) -> &'static str {
50 match *self {
51 Grid::Major => "",
52 Grid::Minor => "m",
53 }
54 }
55}
56
57impl Display<&'static str> for Horizontal {
58 fn display(&self) -> &'static str {
59 match *self {
60 Horizontal::Center => "center",
61 Horizontal::Left => "left",
62 Horizontal::Right => "right",
63 }
64 }
65}
66
67impl Display<&'static str> for Justification {
68 fn display(&self) -> &'static str {
69 match *self {
70 Justification::Left => "Left",
71 Justification::Right => "Right",
72 }
73 }
74}
75
76impl Display<&'static str> for LineType {
77 fn display(&self) -> &'static str {
78 match *self {
79 LineType::Dash => "2",
80 LineType::Dot => "3",
81 LineType::DotDash => "4",
82 LineType::DotDotDash => "5",
83 LineType::SmallDot => "0",
84 LineType::Solid => "1",
85 }
86 }
87}
88
89impl Display<&'static str> for Order {
90 fn display(&self) -> &'static str {
91 match *self {
92 Order::TextSample => "noreverse",
93 Order::SampleText => "reverse",
94 }
95 }
96}
97
98impl Display<&'static str> for PointType {
99 fn display(&self) -> &'static str {
100 match *self {
101 PointType::Circle => "6",
102 PointType::FilledCircle => "7",
103 PointType::FilledSquare => "5",
104 PointType::FilledTriangle => "9",
105 PointType::Plus => "1",
106 PointType::Square => "4",
107 PointType::Star => "3",
108 PointType::Triangle => "8",
109 PointType::X => "2",
110 }
111 }
112}
113
114impl Display<&'static str> for Stacked {
115 fn display(&self) -> &'static str {
116 match *self {
117 Stacked::Horizontally => "horizontal",
118 Stacked::Vertically => "vertical",
119 }
120 }
121}
122
123impl Display<&'static str> for Terminal {
124 fn display(&self) -> &'static str {
125 match *self {
126 Terminal::Svg => "svg dynamic",
127 }
128 }
129}
130
131impl Display<&'static str> for Vertical {
132 fn display(&self) -> &'static str {
133 match *self {
134 Vertical::Bottom => "bottom",
135 Vertical::Center => "center",
136 Vertical::Top => "top",
137 }
138 }
139}
140