0

I'm new to charts and I have an app that is supposed to show each user's personality traits on the users' profile page based on Watson. Each trait is valued between 0.01 to 1.00 (perfect), for example:

user_id | username | password_digest | openness | idealism | environmentalist | achievement
1       | John     | some string     | 0.123    | 0.234    | 0.150            | 0.871

In my user view show.html.slim, I have:

= bar_chart user

enter image description here

How should I write bar_chart so that:

  • It will only include the trait columns, and not include the created_at, updated_at, and password digest
  • Set the range of the bar from 0 to 1 or 0% to 100%, based on the values of each trait
Jun Dalisay
  • 1,165
  • 2
  • 12
  • 26

1 Answers1

0

I used this for the answer

Users controller:

@data = [
      ['Openness', @user.openness],
      ['Idealism', @user.idealism],
      etc..
    ]

Users show view:

= column_chart @data
= bar_chart @data
= pie_chart @data
Jun Dalisay
  • 1,165
  • 2
  • 12
  • 26