Update app.py
Browse files
app.py
CHANGED
@@ -70,19 +70,60 @@ if text:
|
|
70 |
#st.markdown("<br>", unsafe_allow_html=True)
|
71 |
st.success(result)
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# description = '<table style="border: collapse; padding-top: 1px;"><tr><div style="height: 62px;"></div></tr><tr><p style="border-width: medium; border-color: #aa5e70; border-radius: 10px;padding-top: 1px;padding-left: 20px;background:#20212a;font-family:Courier New; color: white;font-size: 36px; font-weight: boldest;">'+result+'</p></tr><table>'
|
87 |
# st.markdown(description, unsafe_allow_html=True)
|
88 |
|
|
|
70 |
#st.markdown("<br>", unsafe_allow_html=True)
|
71 |
st.success(result)
|
72 |
|
73 |
+
st.markdown(''' <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
74 |
+
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.2.js"></script>
|
75 |
+
<div style="width: 500px; height: 500px">
|
76 |
+
<canvas id="myChart"></canvas>
|
77 |
+
</div>
|
78 |
+
<script type="text/javascript">
|
79 |
+
var data = {
|
80 |
+
datasets: [{
|
81 |
+
data: [.88, .1, .02, .01, .002],
|
82 |
+
backgroundColor: [
|
83 |
+
"#F7464A",
|
84 |
+
"#46BFBD",
|
85 |
+
"#FDB45C",
|
86 |
+
"#555555",
|
87 |
+
"#CCCCCC"
|
88 |
+
]
|
89 |
+
}],
|
90 |
+
labels: [
|
91 |
+
"Red",
|
92 |
+
"Green",
|
93 |
+
"Yellow",
|
94 |
+
"WHAT",
|
95 |
+
"YOOOO"
|
96 |
+
]
|
97 |
+
};
|
98 |
+
|
99 |
+
$(document).ready(
|
100 |
+
function() {
|
101 |
+
var canvas = document.getElementById("myChart");
|
102 |
+
var ctx = canvas.getContext("2d");
|
103 |
+
var myNewChart = new Chart(ctx, {
|
104 |
+
type: 'pie',
|
105 |
+
data: data
|
106 |
+
});
|
107 |
+
|
108 |
+
canvas.onclick = function(evt) {
|
109 |
+
var activePoints = myNewChart.getElementsAtEvent(evt);
|
110 |
+
if (activePoints[0]) {
|
111 |
+
var chartData = activePoints[0]['_chart'].config.data;
|
112 |
+
var idx = activePoints[0]['_index'];
|
113 |
+
|
114 |
+
var label = chartData.labels[idx];
|
115 |
+
var value = chartData.datasets[0].data[idx];
|
116 |
+
|
117 |
+
var url = "http://example.com/?label=" + label + "&value=" + value;
|
118 |
+
console.log(url);
|
119 |
+
alert(url);
|
120 |
+
}
|
121 |
+
};
|
122 |
+
}
|
123 |
+
);
|
124 |
+
|
125 |
+
</script>
|
126 |
+
''')
|
127 |
# description = '<table style="border: collapse; padding-top: 1px;"><tr><div style="height: 62px;"></div></tr><tr><p style="border-width: medium; border-color: #aa5e70; border-radius: 10px;padding-top: 1px;padding-left: 20px;background:#20212a;font-family:Courier New; color: white;font-size: 36px; font-weight: boldest;">'+result+'</p></tr><table>'
|
128 |
# st.markdown(description, unsafe_allow_html=True)
|
129 |
|