def METHOD_NAME(data, title: str, format: str) -> Union[str, bytes]:
    if format == "json":
        jsonData = {}
        for d in data:
            jsonData[d[0].strftime("%Y-%m-%dT%H:%M:%SZ")] = int(d[1])
        return json.dumps({"title": title, "data": jsonData})
    elif format == "csv":
        output = io.StringIO()
        writer = csv.writer(output)
        h = ["timestamp", "value"]
        writer.writerow(h)
        for d in data:
            writer.writerow([d[0].strftime("%Y-%m-%dT%H:%M:%SZ"), int(d[1])])
        return output.getvalue()
    else:
        dates = [q[0] for q in data]
        opens = [q[1] for q in data]
        fig = matplotlib.pyplot.figure()
        ax = fig.add_subplot(111)
        ax.plot_date(dates, opens, "-", color="r")
        ax.set_title(title)
        # format the ticks
        ax.relim()
        if len(opens) > 1:
            ytop = float(max(opens)) * 1.05 + 1
        else:
            ytop = None
        ax.set_ylim(bottom=0, top=ytop)
        ax.autoscale_view()
        # format the coords message box
        ax.fmt_ydata = lambda x: "$%1.2f" % x
        ax.grid(True)
        locator = matplotlib.dates.AutoDateLocator()
        formatter = matplotlib.dates.AutoDateFormatter(locator)
        formatter.scaled[30.0] = "%Y-%m"
        formatter.scaled[1.0] = "%Y-%m-%d"
        ax.xaxis.set_major_locator(locator)
        ax.xaxis.set_major_formatter(formatter)
        fig.autofmt_xdate()
        buf = io.BytesIO()
        fig.savefig(buf, format=format)
        matplotlib.pyplot.close(fig)
        return buf.getvalue()