NimaKL commited on
Commit
1da85b3
1 Parent(s): 05415ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -54
app.py CHANGED
@@ -70,60 +70,7 @@ if text:
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
 
 
70
  #st.markdown("<br>", unsafe_allow_html=True)
71
  st.success(result)
72
 
73
+ st.components.v1.html(' <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.2.js"></script> <div style="width: 500px; height: 500px"> <canvas id="myChart"></canvas> </div> <script type="text/javascript"> var data = { datasets: [{ data: [.88, .1, .02, .01, .002], backgroundColor: [ "#F7464A", "#46BFBD", "#FDB45C", "#555555", "#CCCCCC" ] }], labels: [ "Red", "Green", "Yellow", "WHAT", "YOOOO" ] }; $(document).ready( function() { var canvas = document.getElementById("myChart"); var ctx = canvas.getContext("2d"); var myNewChart = new Chart(ctx, { type: "pie", data: data }); canvas.onclick = function(evt) { var activePoints = myNewChart.getElementsAtEvent(evt); if (activePoints[0]) { var chartData = activePoints[0]["_chart"].config.data; var idx = activePoints[0]["_index"]; var label = chartData.labels[idx]; var value = chartData.datasets[0].data[idx]; var url = "http://example.com/?label=" + label + "&value=" + value; console.log(url); alert(url); } }; } ); </script>')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # 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>'
75
  # st.markdown(description, unsafe_allow_html=True)
76