fixed min max calculation.
partly added legend.