vegas-viz/Vegas

Cannot normalize a stacked bar

Ying456123 opened this issue · 0 comments

After I added stacked=StackOffset.Normalize configuration, it still doesn't change much. Does anyone have good advice about how to normalize this bar?
Below is my code:

val data = Seq(
      ("te1", 300.0, 17.0),
      ("te2", 50.0, 19.0),
      ("te1", 40.2, 21.3),
      ("te2", 15.0, 21.5)
    )

val df = spark.createDataFrame(data).toDF("col", "data1", "data2")
Vegas().
  withDataFrame(df).
  mark(Bar).
  encodeY("data1", Quant).
  encodeColor("col", Nominal).
  configMark(stacked=StackOffset.Normalize).
  show

The showed image is:
image
It doesn't show the percentage for each data. Thanks a lot.