def test_get_bytes(self): qc = QuickChart() qc.width = 600 qc.height = 300 qc.config = { "type": "bar", "data": { "labels": ["Hello world", "Test"], "datasets": [{ "label": "Foo", "data": [1, 2] }] } } self.assertTrue(len(qc.get_bytes()) > 8000)
async def graph(ctx): qc = QuickChart() qc.width = 600 qc.height = 300 qc.device_pixel_ratio = 2.0 qc.config = { "type": "bar", "data": { "labels": ["Hello world", "Test"], "datasets": [{ "label": "Foo", "data": [1, 2] }] } } with Image.open(BytesIO(qc.get_bytes())) as chat_sample: output_buffer = BytesIO( ) # By using BytesIO we don't have to save the file in our system. chat_sample.save(output_buffer, "png") output_buffer.seek(0) await ctx.send(file=discord.File(fp=output_buffer, filename="chat_sample.png") ) # Change the file name accordingly.