Display CSV columns as rows in chart

Answered

I’m trying to figure out if it’s possible to display the following CSV structure:

ID,term1,term2,term3
1,10,20,5

I need to plot term1, term2 and term3 on X axis and its value on Y axis. In other words I want to convert CSV columns (term1, term2, term3) into table rows 
What I’m trying to achieve can be easily done with the following CSV, however my goat is to optimize CSV size and reduce number of CSV rows

ID,Term,Value
1,term1,10
2,term2,20
3,term3,5

If it’s not possible with CSV, would it be possible if I use JSON instead, as in:
{“id”: 1, “term1”: 10, “term2”: 20, “term3”: 5}

5 answers

Public
Ian Sadovy Flexmonster April 26, 2018

Hello Konstantin,
 
Thank you for the question.
Are you trying to achieve something like this – http://jsfiddle.net/flexmonster/y0omoqfb/ ?
The key point is to properly specify rows and columns fields.
I used JSON for simplicity, it is also possible with CSV.
 
Please let me know if it works for you.
 
Regards,
Ian
 

Public
Konstantin Pelykh April 26, 2018

Hello Ian,
Thank you for your response. Here’s what I’m trying to achieve.  http://jsfiddle.net/a849rxrw/1/
but using more compact json representation

"data": [
{
"Category": "cat1",
"term1": 10,
"term2": 15
},
{
"Category": "cat2",
"term1": 20,
"term2": 40
}
]
Public
Tanya Gryshko Flexmonster April 27, 2018

Hello, Konstantin,
Thanks for the quick reply.
Here is the same sample showing a possible solution: http://jsfiddle.net/flexmonster/a849rxrw/2/
Does it work for your case?
Regards,
Tanya

Public
Konstantin Pelykh April 27, 2018

Tanya, thank you for the example. It actually look pretty close to what I need. The only problem so far is that X-axis labels display “cat1” and “cat2” instead of terms. Is it possible to force it to display “term1” and “term2” under corresponding columns as in http://jsfiddle.net/a849rxrw/1/

Public
Dmytro Zvazhii Flexmonster April 30, 2018

Hello Konstantin, 
Thank you for your feedback. It is not possible to force charts to display “term1” and “term2” under corresponding columns when using such data configuration. The only possible approach is the following: http://jsfiddle.net/flexmonster/a849rxrw/4/. In case it is not an option please consider using the excessive way of data representation.
Let us know if you have any other questions.
Regards,
Dmytro

Please login or Register to Submit Answer