makeAxis returns a default Axis. The default range is (∞, ∞), and thus any finite value is less than Min and greater than Max.
(o orientation)
| 99 | // The default range is (∞, ∞), and thus any finite |
| 100 | // value is less than Min and greater than Max. |
| 101 | func makeAxis(o orientation) Axis { |
| 102 | |
| 103 | a := Axis{ |
| 104 | Min: math.Inf(+1), |
| 105 | Max: math.Inf(-1), |
| 106 | LineStyle: draw.LineStyle{ |
| 107 | Color: color.Black, |
| 108 | Width: vg.Points(0.5), |
| 109 | }, |
| 110 | Padding: vg.Points(5), |
| 111 | Scale: LinearScale{}, |
| 112 | } |
| 113 | a.Label.TextStyle = text.Style{ |
| 114 | Color: color.Black, |
| 115 | Font: font.From(DefaultFont, 12), |
| 116 | XAlign: draw.XCenter, |
| 117 | YAlign: draw.YBottom, |
| 118 | Handler: DefaultTextHandler, |
| 119 | } |
| 120 | a.Label.Position = draw.PosCenter |
| 121 | |
| 122 | var ( |
| 123 | xalign draw.XAlignment |
| 124 | yalign draw.YAlignment |
| 125 | ) |
| 126 | switch o { |
| 127 | case vertical: |
| 128 | xalign = draw.XRight |
| 129 | yalign = draw.YCenter |
| 130 | case horizontal: |
| 131 | xalign = draw.XCenter |
| 132 | yalign = draw.YTop |
| 133 | } |
| 134 | |
| 135 | a.Tick.Label = text.Style{ |
| 136 | Color: color.Black, |
| 137 | Font: font.From(DefaultFont, 10), |
| 138 | XAlign: xalign, |
| 139 | YAlign: yalign, |
| 140 | Handler: DefaultTextHandler, |
| 141 | } |
| 142 | a.Tick.LineStyle = draw.LineStyle{ |
| 143 | Color: color.Black, |
| 144 | Width: vg.Points(0.5), |
| 145 | } |
| 146 | a.Tick.Length = vg.Points(8) |
| 147 | a.Tick.Marker = DefaultTicks{} |
| 148 | |
| 149 | return a |
| 150 | } |
| 151 | |
| 152 | // sanitizeRange ensures that the range of the |
| 153 | // axis makes sense. |