From 76bff2f9b7b4301eb9f5dc9350bfbf21b0281405 Mon Sep 17 00:00:00 2001 From: Lechevallier Date: Wed, 7 Apr 2021 15:51:50 +0200 Subject: [PATCH] Improve bar documentation for field "seriesField". (#555) * Improve bar documentation for field "seriesField". Explain how to avoid issues with stacked bars order. Example added. * Fix: improve text understanding. Use word "xField" instead of "value" to avoid confusion. --- docs/.g2plot-plot-api/bar.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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*