fixed infinite loop. added chart rest api.

fixed infinite loop if in a chart with multiple lines one line contains no data at all.
added rest api for charts.