I need to produce a table and graph (png image) both at runtime. I know that i can host the image somewhere or store it in blob storage and then add this url to an image tag, but we are already creating a html file and saving this to blob storage. So i dont want to save two separate files to blob stage. Ideally I want to (if it's possible) to add the graph to the html template. Simply adding the output file path to an img tag doesn't work, as it's a static file.
This is code to create the the html file
// Create a new file to write the HTML to
f, err := os.Create("page.html")
if err != nil {
panic(err)
}
defer f.Close()
// Write the template to the file
err = tmpl.Execute(f, playerStatement)
if err != nil {
panic(err)
}
b, err := ioutil.ReadFile("page.html") // b has type []byte
if err != nil {
panic(err)
}
img, err := ps.GenerateGraph(ctx, openingDate, Player.ID)
fileName := fmt.Sprintf("%v.html", *statementId)
// ... upload file to blob storage ...//
this is the code to create the png from GenerateGraph
i, err := os.Create("image.png")
defer i.Close()
err = graph.Render(chart2.PNG, i)
if err != nil {
return nil, err
}