SetScaleX sets the X scale number of lines, lines color and label font size
(lines int, color *math32.Color)
| 158 | |
| 159 | // SetScaleX sets the X scale number of lines, lines color and label font size |
| 160 | func (ch *Chart) SetScaleX(lines int, color *math32.Color) { |
| 161 | |
| 162 | if ch.scaleX != nil { |
| 163 | ch.ClearScaleX() |
| 164 | } |
| 165 | |
| 166 | // Add scale lines |
| 167 | ch.scaleX = newChartScaleX(ch, lines, color) |
| 168 | ch.Add(ch.scaleX) |
| 169 | |
| 170 | // Add scale labels |
| 171 | // The positions of the labels will be set by 'recalc()' |
| 172 | value := ch.firstX |
| 173 | for i := 0; i < lines; i++ { |
| 174 | l := NewLabel(fmt.Sprintf(ch.formatX, value)) |
| 175 | l.SetColor4(math32.NewColor4("black")) |
| 176 | l.SetFontSize(ch.fontSizeX) |
| 177 | ch.Add(l) |
| 178 | ch.labelsX = append(ch.labelsX, l) |
| 179 | value += ch.stepX |
| 180 | } |
| 181 | ch.recalc() |
| 182 | } |
| 183 | |
| 184 | // ClearScaleX removes the X scale if it was previously set |
| 185 | func (ch *Chart) ClearScaleX() { |
no test coverage detected