# Smart percentage chart

**URL:** <https://community.forestadmin.com/t/smart-percentage-chart/2359>\
**Category:** Help me!\
**Created:** [April 22, 2021, 12:26pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359 "2021-04-22T12:26:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldaubie](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@ldaubie](https://community.forestadmin.com/u/ldaubie)\
**Post date:** [April 22, 2021, 12:26pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/1 "2021-04-22T12:26:59Z")

</div>

## 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:

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [April 22, 2021, 12:30pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/2 "2021-04-22T12:30:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ldaubie](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@ldaubie](https://community.forestadmin.com/u/ldaubie)\
**Post date:** [April 22, 2021, 12:43pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/3 "2021-04-22T12:43:34Z")

</div>

HELLO @GuillaumeGautreau ,

Thanks 🙂

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [April 22, 2021, 12:48pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/4 "2021-04-22T12:48:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [April 22, 2021, 12:57pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/5 "2021-04-22T12:57:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ldaubie](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@ldaubie](https://community.forestadmin.com/u/ldaubie)\
**Post date:** [April 22, 2021, 2:31pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/6 "2021-04-22T14:31:09Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [April 22, 2021, 2:56pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/7 "2021-04-22T14:56:02Z")

</div>

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](https://docs.forestadmin.com/documentation/reference-guide/charts/create-a-chart#single-value-with-growth-percentage) has been made with MySQL but as long as you respect the format, you can do the same with any other data source.

---

<div class="post-metadata">

**Author:** ![ldaubie](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@ldaubie](https://community.forestadmin.com/u/ldaubie)\
**Post date:** [April 22, 2021, 3:06pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/8 "2021-04-22T15:06:59Z")

</div>

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 :

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

```

i loose the key “previous” in the response :

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

```

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [April 22, 2021, 3:19pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/9 "2021-04-22T15:19:34Z")

</div>

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

```javascript
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

---

<div class="post-metadata">

**Author:** ![ldaubie](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@ldaubie](https://community.forestadmin.com/u/ldaubie)\
**Post date:** [April 22, 2021, 3:20pm UTC](https://community.forestadmin.com/t/smart-percentage-chart/2359/10 "2021-04-22T15:20:56Z")

</div>

It’s working !! Thanks a lot
