I am trying to display a Python Plotly graph in an html text in power apps. The data for the graph is grabbed via an api and stored in a collection as a json object.
I am not sure of the feasibility of this task, so I wanted to try it with a very simple Plotly graph. Here is the code I have that works outside of the Power Apps environment:
"<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Plotly Chart Example</title>
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
</head>
<body>
<div id='plot' style='width: 100%; height: 100%;'></div> <!-- Plot div -->
<script>
// Example data from Plotly documentation
var data = [{
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
type: 'bar'
}];
// Plotly layout
var layout = {
title: 'Bar Chart Example',
xaxis: {
title: 'Animals'
},
yaxis: {
title: 'Count'
}
};
// Create the plot
Plotly.newPlot('plot', data, layout);
</script>
</body>
</html>"
When I put this into Power Apps html text element. I do not get any errors. However, the graph does not get displayed. I have found a way to get a matplotlib graph shown when I encode it as a base64 string but that doesn’t seem to work for Plotly. Does anyone know if it is possible to display a plotly graph (even a static one) in Power Apps? If so, I would love some help as to how do to so!