정말 간단한 요청이 있습니다. 특정 일 (예 : 2 열 : 킬로그램 및 일) 동안 사용자 가중치를 보유하는 테이블이 있습니다. 이제는 시간에 따라 사용자의 체중 감량을 보여주는 선 차트로 표시하려고합니다 (x 축 = 일, y 축 = kg).Rails에서 선형 차트로 데이터 시각화하기
Chartkick을 설치하면 차트가 렌더링되지만 실제로이 값을 선 차트로 가져 오는 방법을 알지 못합니다.
이 목적을 위해 Chartkick이 올바른 선택입니까? 그리고 그렇다면 내 코드는 어떻게 생겼을까요?
weight.rb
class Weight < ActiveRecord::Base
belongs_to :user
validates :day, uniqueness: { scope: :user_id,
message: "You already stored a weight today. Go back and edit if necessary." }
end
user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
after_create :create_profile
has_one :profile, dependent: :destroy
has_many :weights, dependent: :destroy
end
를 작동해야 테이블은 무엇이라고? 그리고 그것을 어떻게 사용자 테이블에 연결하고 있습니까? – Carpela
위의 게시물에서이 정보를 업데이트했습니다. 내 테이블은 "가중치"라고합니다. – Oliver