code: def to_json(df, x, y, timeseries=False):
          
          values = {k: [] for k in y}
          for i, row in df.iterrows():
              for yy in y:
                  values[yy].append({
                      "x": row[x],
                      "y": row[yy]
                      })
          return {"result":  [values[k] for k in y], "date": timeseries}
docs: Format output for json response.