Smart percentage chart

Expected behavior

Get informations display in %

Actual behavior

I created route who return percentage as number, but when i go to my dashboard and connect to it, i’ve got “NaN%”
There is an exemple of my endpoint response :
const json = new StatSerializer({
value: 11
}).perform();
res.send(json)

Am I doing something wrong?

Failure Logs

Context

Please provide any relevant information about your setup.

  • Package Version:
  • Express Version:
  • Sequelize Version:
  • Database Dialect: NoSql
  • Database Version: 4.4.4
  • Project Name:

Hello @ldaubie,

Welcome in the community!

Can you copy/paste here the content of the response of your endpoint? You’ll be able to find it using the developer tools of your browser, in the network tab.

Thanks

HELLO @GuillaumeGautreau ,

Thanks :slight_smile:

Of course, this is the content of the response :
{“data”:{“type”:“stats”,“id”:“e8948aa0-a367-11eb-aac7-013a8a0a0ec9”,“attributes”:{“value”:2}}}

Otherwise I wondered if it’s possible to display single value with an associate grow percentage ?
Thanks

Thanks for your reply, I’ll try to reproduce the error on my side.

Ok, we added a regression in a recent development. In the meantime, can you use the single value chart to render your percentage, and validate that it works well?

We are working on a fix.

Ok, thanks for your answers and your time.
Yes is working with single value.
About single value i saw we can render “single value with grow percent” with mysql, could there is a way in nosql ?

Yes, sure, you just have to return an object with both properties value and previous and it will display the growth in percent.

The example from the docs has been made with MySQL but as long as you respect the format, you can do the same with any other data source.

Thanks again for your time…

Yes i told myself the same, but i didn’t find a way to make it working, when i try to return something like this :

const json = new StatSerializer({ value: 2, previous: 1 }}).perform();
res.send(json)

i loose the key “previous” in the response :

{"data":{"type":"stats","id":"be66dfd0-a37b-11eb-983b-7339a8c6983a","attributes":{"value": 2}}

Ok, I found in the code that you need to format the response this way to make it work:

router.post('/percent', (request, response, next) => {
  const json = new StatSerializer({ value: {
     countCurrent: 11, 
     countPrevious: 10
  } }).perform();

  response.send(json)
})

This is not very obvious when we look at the documentation, I’ll request changes on it

It’s working !! Thanks a lot