javascript keeps returning NaN% from python var

264 views Asked by At

I have a flask app that I am working on. I'm using a js gauge system and I want the value to be a variable that I scrape off of a web page. I scrape the page just fine and return the values I want but when I give that value to the script it returns NaN%. I can cal the variable in the html section just fine.

JS Snippet

 var g2 = new JustGage({
        id: 'g2',
        value: '{{a0}}',
        min: 0,
        max: 100,
        symbol: '%',
        pointer: true,
        pointerOptions: {
          toplength: -15,
          bottomlength: 10,
          bottomwidth: 12,
          color: '#8e8e93',
          stroke: '#ffffff',
          stroke_width: 3,
          stroke_linecap: 'round'
        },
        gaugeWidthScale: 1,
        counter: true
      });

Flask Part

g_data = ast.literal_eval(soup.get_text())
a0 = g_data['ainputs'][3:8]
a1 = g_data['ainputs'][12:17]
a2 = g_data['ainputs'][21:26]
a3 = g_data['ainputs'][30:35]
a4 = g_data['ainputs'][39:45]

Now I have tried to use float and int on the variable, but neither one returns anything besides NaN%. If I put the variable in the value spot without quotes, none of the gauges display anything.

1

There are 1 answers

0
cmrussell On

Apparently I wasn't passing the variables to the right view. I am sorry. Just using {{a0}} works now.