Skip to content

Commit

Permalink
[v0.5] Remove Deprecated and Replaced API
Browse files Browse the repository at this point in the history
  • Loading branch information
jentfoo committed Jan 27, 2025
1 parent 36b9d8a commit ea7c49a
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 59 deletions.
2 changes: 1 addition & 1 deletion bar_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (B
labelY := top
radians := float64(0)
fontStyle := series.Label.FontStyle
labelBottom := (opt.SeriesLabelPosition == PositionBottom || series.Label.Position == PositionBottom) && !stackedSeries
labelBottom := opt.SeriesLabelPosition == PositionBottom && !stackedSeries
if labelBottom {
labelY = barMaxHeight
radians = -math.Pi / 2 // Rotated label at the bottom
Expand Down
5 changes: 0 additions & 5 deletions chartdraw/drawing/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ func ColorFromRGBA(color string) Color {
return c
}

// Deprecated: ColorFromRGB is deprecated, use ColorFromRGBA to get colors from RGB or RGBA format strings.
func ColorFromRGB(rgb string) (output Color) {
return ColorFromRGBA(rgb)
}

func parseHex(hex string) uint8 {
v, _ := strconv.ParseInt(hex, 16, 16)
return uint8(v)
Expand Down
12 changes: 0 additions & 12 deletions chartdraw/drawing/raster_graphic_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,13 @@ func (rgc *RasterGraphicContext) DrawImage(img image.Image) {
DrawImage(img, rgc.img, rgc.current.Tr, draw.Over, BilinearFilter)
}

// Deprecated: FillString is deprecated, use FillStringAt with (0, 0) for the position.
func (rgc *RasterGraphicContext) FillString(text string) (cursor float64, err error) {
cursor, err = rgc.FillStringAt(text, 0, 0)
return
}

// FillStringAt draws the text at the specified point (x, y).
func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error) {
cursor, err = rgc.CreateStringPath(text, x, y)
rgc.Fill()
return
}

// Deprecated: StrokeString is deprecated, use StrokeStringAt with (0, 0) for the position.
func (rgc *RasterGraphicContext) StrokeString(text string) (cursor float64, err error) {
cursor, err = rgc.StrokeStringAt(text, 0, 0)
return
}

// StrokeStringAt draws the contour of the text at point (x, y).
func (rgc *RasterGraphicContext) StrokeStringAt(text string, x, y float64) (cursor float64, err error) {
cursor, err = rgc.CreateStringPath(text, x, y)
Expand Down
3 changes: 1 addition & 2 deletions examples/web-1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ func indexHandler(w http.ResponseWriter, req *http.Request) {
},
Type: charts.ChartTypeBar,
Label: charts.SeriesLabel{
Show: charts.True(),
Position: charts.PositionBottom,
Show: charts.True(),
},
},
},
Expand Down
3 changes: 0 additions & 3 deletions funnel_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ func (f *funnelChart) render(result *defaultRenderResult, seriesList SeriesList)
if item.Label.ValueFormatter != nil {
textList[index] = item.Label.ValueFormatter(value)
} else {
if item.Label.FormatTemplate == "" {
item.Label.FormatTemplate = item.Label.Formatter
}
textList[index] = labelFormatFunnel(seriesNames, item.Label.FormatTemplate, index, value, percent)
}
}
Expand Down
2 changes: 1 addition & 1 deletion horizontal_bar_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
fontStyle := series.Label.FontStyle
labelX := right
labelY := y + (barHeight >> 1)
labelLeft := (opt.SeriesLabelPosition == PositionLeft || series.Label.Position == PositionLeft) && !stackedSeries
labelLeft := opt.SeriesLabelPosition == PositionLeft && !stackedSeries
if labelLeft {
labelX = 0
}
Expand Down
5 changes: 0 additions & 5 deletions painter.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,6 @@ func (p *Painter) drawSmoothCurve(points []Point, tension float64, dotForSingleP
p.quadCurveTo(points[n-2].X, points[n-2].Y, points[n-1].X, points[n-1].Y)
}

// Deprecated: SetBackground is Deprecated, use FilledRect with zero for the stroke width.
func (p *Painter) SetBackground(width, height int, color Color) {
p.FilledRect(0, 0, width, height, color, color, 0.0)
}

// drawBackground fills the entire painter area with the given color.
func (p *Painter) drawBackground(color Color) {
p.FilledRect(0, 0, p.Width(), p.Height(), color, color, 0.0)
Expand Down
7 changes: 0 additions & 7 deletions painter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ func TestPainterExternal(t *testing.T) {
},
result: "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 400 300\"><path d=\"M 15 30\nQ25,50 27,55\nQ35,70 37,67\nQ45,60 47,57\nQ55,50 57,60\nQ55,50 65,90\" style=\"stroke-width:1;stroke:black;fill:none\"/></svg>",
},
{
name: "background",
fn: func(p *Painter) {
p.SetBackground(400, 300, ColorWhite)
},
result: "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 400 300\"><path d=\"M 5 10\nL 405 10\nL 405 310\nL 5 310\nL 5 10\" style=\"stroke:none;fill:white\"/></svg>",
},
{
name: "filled_rect",
fn: func(p *Painter) {
Expand Down
3 changes: 0 additions & 3 deletions pie_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ func newSector(cx int, cy int, radius float64, labelRadius float64, value float6
if series.Label.ValueFormatter != nil {
s.label = series.Label.ValueFormatter(s.value)
} else {
if series.Label.FormatTemplate == "" {
series.Label.FormatTemplate = series.Label.Formatter
}
s.label = labelFormatPie([]string{label}, series.Label.FormatTemplate, 0, s.value, s.percent)
}
}
Expand Down
12 changes: 6 additions & 6 deletions pie_chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func TestPieChart(t *testing.T) {
return PieChartOption{
SeriesList: NewSeriesListPie(values, PieSeriesOption{
Label: SeriesLabel{
Show: True(),
Formatter: "{b} ({c} ≅ {d})",
Show: True(),
FormatTemplate: "{b} ({c} ≅ {d})",
},
Radius: "200",
}),
Expand Down Expand Up @@ -150,8 +150,8 @@ func TestPieChart(t *testing.T) {
return PieChartOption{
SeriesList: NewSeriesListPie(values, PieSeriesOption{
Label: SeriesLabel{
Show: True(),
Formatter: "{b} ({c} ≅ {d})",
Show: True(),
FormatTemplate: "{b} ({c} ≅ {d})",
},
Radius: "200",
}),
Expand Down Expand Up @@ -244,8 +244,8 @@ func TestPieChart(t *testing.T) {
return PieChartOption{
SeriesList: NewSeriesListPie(values, PieSeriesOption{
Label: SeriesLabel{
Show: True(),
Formatter: "{b} ({c} ≅ {d})",
Show: True(),
FormatTemplate: "{b} ({c} ≅ {d})",
},
Radius: "150",
}),
Expand Down
11 changes: 0 additions & 11 deletions series.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ func newSeriesListFromValues(values [][]float64, chartType string, label SeriesL
}

type SeriesLabel struct {
// Deprecated: Formatter is deprecated, use FormatTemplate as a direct replacement.
Formatter string
// FormatTemplate is a string template for formatting the data label.
// {b}: the name of a data item.
// {c}: the value of a data item.
Expand All @@ -46,9 +44,6 @@ type SeriesLabel struct {
Show *bool
// Distance to the host graphic element.
Distance int // TODO - do we want to replace with just Offset?
// Deprecated: Position is deprecated, this value was only used on bar and horizontal bar charts. Instead use
// SeriesLabelPosition on those chart options directly.
Position string
// Offset specifies an offset from the position.
Offset OffsetInt
}
Expand Down Expand Up @@ -144,12 +139,6 @@ func (sl SeriesList) getYAxisCount() int {
return 1
}

// Deprecated: GetMinMax is deprecated, instead use Series.Summary(). For example seriesList[0].Summary().
func (sl SeriesList) GetMinMax(yaxisIndex int) (float64, float64) {
min, max, _ := sl.getMinMaxSumMax(yaxisIndex, false)
return min, max
}

// getMinMaxSumMax returns the min, max, and maximum sum of the series for a given y-axis index (either 0 or 1).
// This is a higher performance option for internal use. calcSum provides an optimization to
// only calculate the sumMax if it will be used.
Expand Down
3 changes: 0 additions & 3 deletions series_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ func (o *seriesLabelPainter) Add(value labelValue) {
if label.ValueFormatter != nil {
text = label.ValueFormatter(value.value)
} else {
if label.FormatTemplate == "" {
label.FormatTemplate = label.Formatter
}
text = labelFormatValue(o.seriesNames, label.FormatTemplate, value.index, value.value, -1)
}
labelStyle := FontStyle{
Expand Down

0 comments on commit ea7c49a

Please sign in to comment.