vegas-viz / Vegas

The missing MatPlotLib for Scala + Spark
MIT License
730 stars 99 forks source link

Cannot normalize a stacked bar #172

Open Ying456123 opened 4 years ago

Ying456123 commented 4 years ago

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.