added logic to generate the JSON for line graphs