Format output for json response.

def to_json(df, x, y):
        """Format output for json response."""
        values = []
        for i, row in df.iterrows():
            values.append({
                "x": row[x],
                "y": row[y]
                })

        if df.empty:
            return {"result": [{"x": 0, "y": 0}], "date": False}

        return {"result": values, "date": False}