Skip to content

Commit 95193fb

Browse files
committed
Fix circle in PNG and move ValueFormatter to the chart configuration
1 parent d4db463 commit 95193fb

File tree

11 files changed

+119
-94
lines changed

11 files changed

+119
-94
lines changed

bar_chart.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ type BarChartOption struct {
4141
BarWidth int
4242
// RoundedBarCaps set to `true` to produce a bar graph where the bars have rounded tops.
4343
RoundedBarCaps *bool
44+
// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
45+
ValueFormatter ValueFormatter
4446
}
4547

4648
func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (Box, error) {
4749
p := b.p
4850
opt := b.opt
4951
seriesPainter := result.seriesPainter
5052

51-
xRange := newRange(b.p, seriesPainter.Width(), len(opt.XAxis.Data), 0.0, 0.0, 0.0, 0.0)
53+
xRange := newRange(b.p, opt.ValueFormatter,
54+
seriesPainter.Width(), len(opt.XAxis.Data), 0.0, 0.0, 0.0, 0.0)
5255
x0, x1 := xRange.GetRange(0)
5356
width := int(x1 - x0)
5457
// margin between each block
@@ -191,13 +194,14 @@ func (b *barChart) Render() (Box, error) {
191194
opt.Theme = getPreferredTheme(p.theme)
192195
}
193196
renderResult, err := defaultRender(p, defaultRenderOption{
194-
theme: opt.Theme,
195-
padding: opt.Padding,
196-
seriesList: opt.SeriesList,
197-
xAxis: opt.XAxis,
198-
yAxis: opt.YAxis,
199-
title: opt.Title,
200-
legend: opt.Legend,
197+
theme: opt.Theme,
198+
padding: opt.Padding,
199+
seriesList: opt.SeriesList,
200+
xAxis: opt.XAxis,
201+
yAxis: opt.YAxis,
202+
title: opt.Title,
203+
legend: opt.Legend,
204+
valueFormatter: opt.ValueFormatter,
201205
})
202206
if err != nil {
203207
return BoxZero, err

bar_chart_test.go

Lines changed: 12 additions & 0 deletions
Large diffs are not rendered by default.

charts.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ type defaultRenderOption struct {
8484
legend LegendOption
8585
// backgroundIsFilled is true if the background is filled.
8686
backgroundIsFilled bool
87-
// axisReversed is true if the x y axis is reversed.
87+
// axisReversed is true if the x y-axis is reversed.
8888
axisReversed bool
89+
// valueFormatter to format numeric values into labels.
90+
valueFormatter ValueFormatter
8991
}
9092

9193
type defaultRenderResult struct {
@@ -228,13 +230,8 @@ func defaultRender(p *Painter, opt defaultRenderOption) (*defaultRenderResult, e
228230
yAxisOption.LabelCount = labelCount
229231
}
230232
labelCount = chartdraw.MaxInt(labelCount+yAxisOption.LabelCountAdjustment, 2)
231-
r := axisRange{
232-
p: p,
233-
divideCount: labelCount,
234-
min: min,
235-
max: max,
236-
size: rangeHeight,
237-
}
233+
r := newRange(p, opt.valueFormatter,
234+
rangeHeight, labelCount, min, max, 0, 0)
238235
result.axisRanges[index] = r
239236

240237
if yAxisOption.Theme == nil {
@@ -317,9 +314,6 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
317314
})
318315
}
319316
p := opt.parent
320-
if opt.ValueFormatter != nil {
321-
p.valueFormatter = opt.ValueFormatter
322-
}
323317
if !opt.Box.IsZero() {
324318
p = p.Child(PainterBoxOption(opt.Box))
325319
}
@@ -349,14 +343,15 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
349343

350344
axisReversed := len(horizontalBarSeriesList) != 0
351345
renderOpt := defaultRenderOption{
352-
theme: opt.Theme,
353-
padding: opt.Padding,
354-
seriesList: opt.SeriesList,
355-
xAxis: opt.XAxis,
356-
yAxis: opt.YAxis,
357-
title: opt.Title,
358-
legend: opt.Legend,
359-
axisReversed: axisReversed,
346+
theme: opt.Theme,
347+
padding: opt.Padding,
348+
seriesList: opt.SeriesList,
349+
xAxis: opt.XAxis,
350+
yAxis: opt.YAxis,
351+
title: opt.Title,
352+
legend: opt.Legend,
353+
axisReversed: axisReversed,
354+
valueFormatter: opt.ValueFormatter,
360355
// the background color has been set
361356
backgroundIsFilled: true,
362357
}

horizontal_bar_chart.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ type HorizontalBarChartOption struct {
3232
Legend LegendOption
3333
// BarHeight specifies the height of each horizontal bar.
3434
BarHeight int
35+
// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
36+
ValueFormatter ValueFormatter
3537
}
3638

3739
// newHorizontalBarChart returns a horizontal bar chart renderer
@@ -73,7 +75,8 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
7375
theme := opt.Theme
7476

7577
min, max := seriesList.GetMinMax(0)
76-
xRange := newRange(p, seriesPainter.Width(), len(seriesList[0].Data), min, max, 1.0, 1.0)
78+
xRange := newRange(p, opt.ValueFormatter,
79+
seriesPainter.Width(), len(seriesList[0].Data), min, max, 1.0, 1.0)
7780
seriesNames := seriesList.Names()
7881

7982
var rendererList []renderer
@@ -150,14 +153,15 @@ func (h *horizontalBarChart) Render() (Box, error) {
150153
}
151154

152155
renderResult, err := defaultRender(p, defaultRenderOption{
153-
theme: opt.Theme,
154-
padding: opt.Padding,
155-
seriesList: opt.SeriesList,
156-
xAxis: opt.XAxis,
157-
yAxis: opt.YAxis,
158-
title: opt.Title,
159-
legend: opt.Legend,
160-
axisReversed: true,
156+
theme: opt.Theme,
157+
padding: opt.Padding,
158+
seriesList: opt.SeriesList,
159+
xAxis: opt.XAxis,
160+
yAxis: opt.YAxis,
161+
title: opt.Title,
162+
legend: opt.Legend,
163+
valueFormatter: opt.ValueFormatter,
164+
axisReversed: true,
161165
})
162166
if err != nil {
163167
return BoxZero, err

horizontal_bar_chart_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ func TestHorizontalBarChart(t *testing.T) {
8989
},
9090
result: "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 600 400\"><path d=\"M 0 0\nL 600 0\nL 600 400\nL 0 400\nL 0 0\" style=\"stroke:none;fill:white\"/><path d=\"M 224 19\nL 254 19\" style=\"stroke-width:3;stroke:rgb(84,112,198);fill:none\"/><circle cx=\"239\" cy=\"19\" r=\"5\" style=\"stroke-width:3;stroke:rgb(84,112,198);fill:rgb(84,112,198)\"/><text x=\"256\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">2011</text><path d=\"M 311 19\nL 341 19\" style=\"stroke-width:3;stroke:rgb(145,204,117);fill:none\"/><circle cx=\"326\" cy=\"19\" r=\"5\" style=\"stroke-width:3;stroke:rgb(145,204,117);fill:rgb(145,204,117)\"/><text x=\"343\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">2012</text><text x=\"10\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">World Population</text><path d=\"M 83 45\nL 88 45\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 97\nL 88 97\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 150\nL 88 150\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 202\nL 88 202\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 255\nL 88 255\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 307\nL 88 307\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 360\nL 88 360\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 88 45\nL 88 360\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><text x=\"37\" y=\"78\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">World</text><text x=\"38\" y=\"130\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">China</text><text x=\"44\" y=\"183\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">India</text><text x=\"48\" y=\"235\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">USA</text><text x=\"10\" y=\"288\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">Indonesia</text><text x=\"39\" y=\"340\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">Brazil</text><text x=\"87\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">0</text><text x=\"187\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">144k</text><text x=\"287\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">288k</text><text x=\"388\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">432k</text><text x=\"488\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">576k</text><text x=\"555\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">720k</text><path d=\"M 188 45\nL 188 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 288 45\nL 288 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 389 45\nL 389 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 489 45\nL 489 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 590 45\nL 590 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 88 317\nL 100 317\nL 100 330\nL 88 330\nL 88 317\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 265\nL 103 265\nL 103 278\nL 88 278\nL 88 265\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 212\nL 107 212\nL 107 225\nL 88 225\nL 88 212\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 160\nL 158 160\nL 158 173\nL 88 173\nL 88 160\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 107\nL 176 107\nL 176 120\nL 88 120\nL 88 107\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 55\nL 509 55\nL 509 68\nL 88 68\nL 88 55\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 335\nL 100 335\nL 100 348\nL 88 348\nL 88 335\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 283\nL 103 283\nL 103 296\nL 88 296\nL 88 283\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 230\nL 108 230\nL 108 243\nL 88 243\nL 88 230\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 178\nL 169 178\nL 169 191\nL 88 191\nL 88 178\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 125\nL 177 125\nL 177 138\nL 88 138\nL 88 125\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 73\nL 544 73\nL 544 86\nL 88 86\nL 88 73\" style=\"stroke:none;fill:rgb(145,204,117)\"/><text x=\"105\" y=\"327\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">18203</text><text x=\"108\" y=\"275\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">23489</text><text x=\"112\" y=\"222\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">29034</text><text x=\"163\" y=\"170\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">104970</text><text x=\"181\" y=\"117\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">131744</text><text x=\"514\" y=\"65\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">630230</text><text x=\"105\" y=\"345\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">19325</text><text x=\"108\" y=\"293\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">23438</text><text x=\"113\" y=\"240\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">31000</text><text x=\"174\" y=\"188\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">121594</text><text x=\"182\" y=\"135\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">134141</text><text x=\"549\" y=\"83\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">681807</text></svg>",
9191
},
92+
{
93+
name: "value_formatter",
94+
defaultTheme: true,
95+
makeOptions: func() HorizontalBarChartOption {
96+
opt := makeBasicHorizontalBarChartOption()
97+
series := opt.SeriesList
98+
for i := range series {
99+
series[i].Label.Show = True()
100+
}
101+
opt.ValueFormatter = func(f float64) string {
102+
return "f"
103+
}
104+
return opt
105+
},
106+
result: "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 600 400\"><path d=\"M 0 0\nL 600 0\nL 600 400\nL 0 400\nL 0 0\" style=\"stroke:none;fill:white\"/><path d=\"M 224 19\nL 254 19\" style=\"stroke-width:3;stroke:rgb(84,112,198);fill:none\"/><circle cx=\"239\" cy=\"19\" r=\"5\" style=\"stroke-width:3;stroke:rgb(84,112,198);fill:rgb(84,112,198)\"/><text x=\"256\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">2011</text><path d=\"M 311 19\nL 341 19\" style=\"stroke-width:3;stroke:rgb(145,204,117);fill:none\"/><circle cx=\"326\" cy=\"19\" r=\"5\" style=\"stroke-width:3;stroke:rgb(145,204,117);fill:rgb(145,204,117)\"/><text x=\"343\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">2012</text><text x=\"10\" y=\"25\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">World Population</text><path d=\"M 83 45\nL 88 45\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 97\nL 88 97\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 150\nL 88 150\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 202\nL 88 202\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 255\nL 88 255\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 307\nL 88 307\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 83 360\nL 88 360\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><path d=\"M 88 45\nL 88 360\" style=\"stroke-width:1;stroke:rgb(110,112,121);fill:none\"/><text x=\"37\" y=\"78\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">World</text><text x=\"38\" y=\"130\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">China</text><text x=\"44\" y=\"183\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">India</text><text x=\"48\" y=\"235\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">USA</text><text x=\"10\" y=\"288\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">Indonesia</text><text x=\"39\" y=\"340\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">Brazil</text><text x=\"87\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><text x=\"187\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><text x=\"287\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><text x=\"388\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><text x=\"488\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><text x=\"584\" y=\"385\" style=\"stroke:none;fill:rgb(70,70,70);font-size:15.3px;font-family:'Roboto Medium',sans-serif\">f</text><path d=\"M 188 45\nL 188 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 288 45\nL 288 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 389 45\nL 389 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 489 45\nL 489 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 590 45\nL 590 360\" style=\"stroke-width:1;stroke:rgb(224,230,242);fill:none\"/><path d=\"M 88 317\nL 100 317\nL 100 330\nL 88 330\nL 88 317\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 265\nL 103 265\nL 103 278\nL 88 278\nL 88 265\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 212\nL 107 212\nL 107 225\nL 88 225\nL 88 212\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 160\nL 158 160\nL 158 173\nL 88 173\nL 88 160\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 107\nL 176 107\nL 176 120\nL 88 120\nL 88 107\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 55\nL 509 55\nL 509 68\nL 88 68\nL 88 55\" style=\"stroke:none;fill:rgb(84,112,198)\"/><path d=\"M 88 335\nL 100 335\nL 100 348\nL 88 348\nL 88 335\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 283\nL 103 283\nL 103 296\nL 88 296\nL 88 283\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 230\nL 108 230\nL 108 243\nL 88 243\nL 88 230\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 178\nL 169 178\nL 169 191\nL 88 191\nL 88 178\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 125\nL 177 125\nL 177 138\nL 88 138\nL 88 125\" style=\"stroke:none;fill:rgb(145,204,117)\"/><path d=\"M 88 73\nL 544 73\nL 544 86\nL 88 86\nL 88 73\" style=\"stroke:none;fill:rgb(145,204,117)\"/><text x=\"105\" y=\"327\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">18203</text><text x=\"108\" y=\"275\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">23489</text><text x=\"112\" y=\"222\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">29034</text><text x=\"163\" y=\"170\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">104970</text><text x=\"181\" y=\"117\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">131744</text><text x=\"514\" y=\"65\" style=\"stroke:none;fill:rgb(238,238,238);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">630230</text><text x=\"105\" y=\"345\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">19325</text><text x=\"108\" y=\"293\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">23438</text><text x=\"113\" y=\"240\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">31000</text><text x=\"174\" y=\"188\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">121594</text><text x=\"182\" y=\"135\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">134141</text><text x=\"549\" y=\"83\" style=\"stroke:none;fill:rgb(70,70,70);font-size:12.8px;font-family:'Roboto Medium',sans-serif\">681807</text></svg>",
107+
},
92108
}
93109

94110
for i, tt := range tests {

line_chart.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ type LineChartOption struct {
5050
FillArea bool
5151
// FillOpacity is the opacity (alpha) of the area fill.
5252
FillOpacity uint8
53+
// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
54+
ValueFormatter ValueFormatter
5355
// backgroundIsFilled is set to true if the background is filled.
5456
backgroundIsFilled bool
5557
}
@@ -223,6 +225,7 @@ func (l *lineChart) Render() (Box, error) {
223225
yAxis: opt.YAxis,
224226
title: opt.Title,
225227
legend: opt.Legend,
228+
valueFormatter: opt.ValueFormatter,
226229
backgroundIsFilled: opt.backgroundIsFilled,
227230
})
228231
if err != nil {

0 commit comments

Comments
 (0)