diff --git a/docs/.g2plot-plot-api/bar.md b/docs/.g2plot-plot-api/bar.md index cf211c4b7..22d77360d 100644 --- a/docs/.g2plot-plot-api/bar.md +++ b/docs/.g2plot-plot-api/bar.md @@ -80,6 +80,42 @@ The name of the data field corresponding to the graph in the y direction, usuall Grouping field. It is the same meaning as groupField、colorField in Grouped Bar, and the same as stackField、colorField in Stacked Bar. +To avoid issues related to stacked bars order, make sure each `yField` gets a bar defined for each possible value of `seriesField`, even if `xField` is 0. + +Example: + +```ts +config = { + data: [ + { + x: 0, + y: "bar", + color: "red" + }, + { + x: 40, + y: "bar", + color: "yellow" + }, + { + x: 2, + y: "foo", + color: "red" + }, + { + x: 40, + y: "foo", + color: "yellow" + } + ].reverse(), + isStack: true, + xField: "x", + yField: "y", + seriesField: "color", + color: _ref => _ref.color +}; +``` + #### groupField **optional** *string*