-
Notifications
You must be signed in to change notification settings - Fork 8
Version Migration Guide
Mike Jensen edited this page Aug 20, 2025
·
7 revisions
This guide details how to update between go-analyze/charts versions. To upgrade, follow the steps for each version sequentially, starting from your current version. Older versions are at the bottom.
These are API changes expected in v0.6.0, if these are an issue or you have an opinion on these please open an Issue to discuss.
-
Defaultconstants inchartdrawpackage currently marked for deprecation removed -
Fontremoved from chart configuration structs:BarChartOption,FunnelChartOption,HeatMapOption,HorizontalBarChartOption,LineChartOption,PieChartOption,RadarChartOption,ScatterChartOption- Set the font on specific elements (like Series.Label or Title) -
YAxisOption.Formatterremoved in favor ofValueFormatterfunction.
- Minimum Go version is now
1.18to support generics. - Chart-specific
SeriesListtypes have been introduced (PR #45) to provide a clearer API and better documentation for each chart's capabilities. While this is a significant change, most users leveraging helper functions likeNewSeriesListLinewill see minimal impact. The most common change is the renaming of theDatafield toValues(orValueforPieandFunnelcharts). If you construct series manually, the types now map as follows:-
ChartOption-GenericSeriesList -
LineChartOption-LineSeriesList -
BarChartOption-BarSeriesList -
HorizontalBarChartOption-HorizontalBarSeriesList -
FunnelChartOption-FunnelSeriesList -
PieChartOption-PieSeriesList -
RadarChartOption-RadarSeriesList
-
Removed Deprecated APIs:
-
LineChartOption.SymbolShowreplaced withLineChartOption.Symbol(now accepting multiple symbol types) -
XAxisOption.TextRotationreplaced withXAxisOption.LabelRotation -
YAxisOption.AxisColorhas been removed, now configurable through the Theme usingWithYAxisColororWithYAxisSeriesColor(if you want the axis and text to match a specific series color) -
LegendOption.Iconreplaced withLegendOption.Symbol(now accepting more symbols) -
LegendOption.Datareplaced withLegendOption.SeriesNames -
XAxisOption.Datareplaced withXAxisOption.Labels -
YAxisOption.Datareplaced withYAxisOption.Labels -
XAxisDataOptionFuncreplaced withXAxisLabelsOptionFunc -
YAxisDataOptionFuncreplaced withYAxisLabelsOptionFunc -
Series.Label.Formatterreplaced withSeries.Label.FormatTemplate -
Series.Label.Positionreplaced withSeriesLabelPositionon the chart Options struct (only bar and horizontal bar use this field) -
SeriesList.GetMinMaxremoved, use the betterSeries.Summary()function. -
Painter.MarkLinereplaced withPainter.HorizontalMarkLine -
drawing.ColorFromRGBreplaced withcharts.ColorFromRGBA(supporting both formats now) -
drawingpackage had several functions expected to be unused externally that were removed
Other API Changes:
- Helper functions
True(),False(),BoolPointer(bool), andFloatPointer(float64)have been replaced bycharts.Ptr. -
LineChartOption.FillAreais now a*bool, set withcharts.Ptr(true). -
HorizontalBarChart.YAxisis now a single struct instead of a slice, as only one y-axis is supported (see PR #40).
Config Changes:
-
LegendOptions.Verticalis now a*boolinstead of aboolfor consistency and to allow for more flexible defaults. -
LineChartOption.StrokeWidthrenamed toLineStrokeWidthfor consistency. - Removed
OutputFormatOptionFunc. UseSVGOutputOptionFunc()orPNGOutputOptionFunc()instead. -
WidthOptionFuncandHeightOptionFuncwere replaced withDimensionsOptionFunc. Similarly,SetDefaultWidthandSetDefaultHeightwere replaced withSetDefaultChartDimensions.
Series Changes:
-
SeriesListconstruction is now more consistent, using type-specific functions (NewSeriesList<Type>). This removesNewSeriesListDataFromValuesandNewSeriesFromValuesfrom the public API. Instead of passing a chart type, call the specific function for that type. For easier option struct construction, consider using helpers likeNew<Type>ChartOptionWithData. - The
SeriesDatastruct has been removed.Seriesvalues are now referenced directly via afloat64slice.
Painter Changes:
- All
New<Type>Painterfunctions are now private except forNewPainter, as they are intended for internal use. -
NewPainterno longer returns an error (error case is impossible). - The
Renderertype and itsNewconstructor functions are now private. To render a chart, invoke the method directly on aPainterinstance:-
NewBarChart→Painter.BarChart -
NewHorizontalBarChart→Painter.HorizontalBarChart -
NewFunnelChart→Painter.FunnelChart -
NewLineChart→Painter.LineChart -
NewPieChart→Painter.PieChart -
NewRadarChart→Painter.RadarChart -
NewTableChart→Painter.TableChart
-
- The
PainterAPI has been streamlined to focus on post-render modifications (e.g., drawing arrows, text, shapes).ArrowTopandArrowBottomwere renamed toArrowUpandArrowDown.Paintermethods no longer return aPainterinstance unless the action applies only to the returned instance. -
Painterstyling (fill color, stroke width, etc.) is no longer stateful. Style attributes are now passed as arguments to the relevant functions.
Many public functions and structs were made private in PR #27. If you relied on any of this functionality, please open an issue.
- Removed
NewLegendOption,NewXAxisOption, andNewYAxisOptions. Instantiate these configuration structs directly. - The
Orientstring configuration was replaced with aVerticalboolean. - Legend and Title
TopandLeftconfigurations were moved into theOffsetfield (which takes anOffsetStrstruct). - Where
PositionLeft,PositionCenter, orRightwere used, you can now useOffsetLeft,OffsetCenter, orOffsetRightto set theOffsetfield.
-
Font,FontSize, andFontColorconfigurations have been moved into aFontStylestruct.
-
Typewas renamed toOutputFormatto better describe the rendered chart format. - Heavier theme use - color specifications that were already possible to derive from the theme have been removed, instead the theme centralizes the styling.
-
TrueFlag()andFalseFlag()were renamed toTrue()andFalse(). -
NewFloatPoint(float64)was renamed toFloatPointer. - Fields named
*Optionsor*Optionhave dropped that suffix. E.g.,YAxisOptions→YAxis.
-
FirstAxiswas renamed toDataStartIndex. -
StrokeColorandSplitLineColorwere removed in favor of theme-based colors. UseWithAxisColor(Color)to customize the axis color in a theme. - The y-axis
Colorfield was renamed toAxisColor. Modifying the theme withWithAxisColor(Color)is the preferred approach.
- Line chart
Opacitywas renamed toFillOpacity. - For Grid and Table charts,
ColumnandRowwere pluralized toColumnsandRows. - For Table charts,
Paddingwas renamed toCellPadding.
- The theme implementation is now color-only, making the
ColorPaletteimmutable. Fonts and font sizes must be configured separately from the theme. - Theme
ColorPaletteandFontare now set directly instead of by name. -
FontFamilyhas been removed (except for ECharts JSON imports). Set the font directly usingGetFont(Family).