Spaces:
Running on CPU Upgrade

ziem-io commited on
Commit
be26fa3
·
1 Parent(s): aee939f

Fix: Wheel

Browse files
Files changed (1) hide show
  1. app.py +53 -28
app.py CHANGED
@@ -134,7 +134,7 @@ def predict(review: str):
134
  #html_out = f"<b>{html.escape(review)}</b>"
135
 
136
  html_out = '''
137
- <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
138
 
139
  <defs>
140
  <path id="textPathU-68cfc5fd8ae1e" d="M 250, 250 m 0, 220 a -220,-220 0 1,1 0,-440 a -220,-220 0 1,1 0,440" style="stroke: red; fill: none;" />
@@ -204,7 +204,7 @@ def predict(review: str):
204
  </textPath>
205
  </text>
206
 
207
- <polyline class="graph" points style="fill: rgb(220, 155, 39)"></polyline>
208
 
209
  <circle class="point" style="stroke: black; fill: white;" cx="250" cy="250" r="3.5" />
210
  <circle class="point" style="stroke: black; fill: white;" cx="250" cy="250" r="3.5" />
@@ -217,43 +217,68 @@ def predict(review: str):
217
 
218
  </svg>
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  <script>
221
- const setPoints = function (vals) {
222
 
223
- const elemsPoint = document.querySelectorAll('.point');
224
- const elemGraph = document.querySelector('.graph');
225
 
226
- const points = [];
227
 
228
- elemsPoint.forEach(function(elemPoint, i) {
229
- // steps offset convert to bogenmass
230
- const angle = (360 / config.segments * i + config.offsetAngle - 90) * (Math.PI * 2 / 360);
231
 
232
- const val = vals[i];
233
 
234
- const c = {
235
- x: Math.cos(angle) * (val * config.inputRatio + config.innerRadius) + config.offsetCenter,
236
- y: Math.sin(angle) * (val * config.inputRatio + config.innerRadius) + config.offsetCenter
237
- }
238
 
239
- points.push(`${c.x},${c.y}`);
240
 
241
- elemGraph.setAttribute('points', points.join(' '));
242
 
243
- elemPoint.setAttribute('cx', `${c.x}`);
244
- elemPoint.setAttribute('cy', `${c.y}`);
245
- });
246
- }
247
 
248
- const config = {
249
- segments: 8,
250
- offsetAngle: 0,
251
- innerRadius: 40,
252
- offsetCenter: 250,
253
- inputRatio: 16
254
- };
255
 
256
- setPoints([0, 1, 1.5, 0, 2, 0, 3.4, 2])
257
  </script>
258
  '''
259
 
 
134
  #html_out = f"<b>{html.escape(review)}</b>"
135
 
136
  html_out = '''
137
+ <svg id="wheel" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
138
 
139
  <defs>
140
  <path id="textPathU-68cfc5fd8ae1e" d="M 250, 250 m 0, 220 a -220,-220 0 1,1 0,-440 a -220,-220 0 1,1 0,440" style="stroke: red; fill: none;" />
 
204
  </textPath>
205
  </text>
206
 
207
+ <polyline class="graph" points></polyline>
208
 
209
  <circle class="point" style="stroke: black; fill: white;" cx="250" cy="250" r="3.5" />
210
  <circle class="point" style="stroke: black; fill: white;" cx="250" cy="250" r="3.5" />
 
217
 
218
  </svg>
219
 
220
+ <style>
221
+ svg#wheel > .circle,
222
+ svg#wheel > .line {
223
+ stroke: rgb(180, 180, 180) !important;
224
+ }
225
+ svg#wheel > .point {
226
+ stroke: rgb(120, 120, 120) !important;
227
+ fill: rgb(255, 255, 255) !important;
228
+ }
229
+ svg#wheel > .graph {
230
+ fill: rgb(250, 208, 72);
231
+ fill-opacity: 0.9;
232
+ }
233
+ svg#wheel > text {
234
+ font-family: 'Roboto Condensed', sans-serif;
235
+ font-style: normal;
236
+ font-weight: 400;
237
+ font-size: 18px;
238
+ // text-transform: uppercase;
239
+ &.scale {
240
+ fill: rgb(180, 180, 180);
241
+ }
242
+ }
243
+ </style>
244
+
245
  <script>
246
+ const setPoints = function (vals) {
247
 
248
+ const elemsPoint = document.querySelectorAll('.point');
249
+ const elemGraph = document.querySelector('.graph');
250
 
251
+ const points = [];
252
 
253
+ elemsPoint.forEach(function(elemPoint, i) {
254
+ // steps offset convert to bogenmass
255
+ const angle = (360 / config.segments * i + config.offsetAngle - 90) * (Math.PI * 2 / 360);
256
 
257
+ const val = vals[i];
258
 
259
+ const c = {
260
+ x: Math.cos(angle) * (val * config.inputRatio + config.innerRadius) + config.offsetCenter,
261
+ y: Math.sin(angle) * (val * config.inputRatio + config.innerRadius) + config.offsetCenter
262
+ }
263
 
264
+ points.push(`${c.x},${c.y}`);
265
 
266
+ elemGraph.setAttribute('points', points.join(' '));
267
 
268
+ elemPoint.setAttribute('cx', `${c.x}`);
269
+ elemPoint.setAttribute('cy', `${c.y}`);
270
+ });
271
+ }
272
 
273
+ const config = {
274
+ segments: 8,
275
+ offsetAngle: 0,
276
+ innerRadius: 40,
277
+ offsetCenter: 250,
278
+ inputRatio: 16
279
+ };
280
 
281
+ setPoints([0, 1, 1.5, 0, 2, 0, 3.4, 2])
282
  </script>
283
  '''
284