added configurable limit for number of elements in a chart