我有一些包含“嵌套”数据的数据。我需要基于一个数据(总计)呈现数据,然后将工具提示设置为其余(喜欢,提及等)。
这是数据
[{:name=>"United States Military Academy", :data=>["2018-12-17T06:00:00.000Z", {"likes"=>6, "retweets"=>6, "mentions"=>2, "dms"=>4, "sms"=>5, "total"=>23}, "2018-12-20T06:00:00.000Z", {"likes"=>12, "retweets"=>9, "mentions"=>7, "dms"=>5, "sms"=>9, "total"=>42}, "2018-12-24T06:00:00.000Z", {"likes"=>5, "retweets"=>7, "mentions"=>19, "dms"=>5, "sms"=>9, "total"=>45}, "2018-11-29T06:00:00.000Z", {"likes"=>14, "retweets"=>3, "mentions"=>18, "dms"=>3, "sms"=>9, "total"=>47}, "2018-12-08T06:00:00.000Z", {"likes"=>19, "retweets"=>9, "mentions"=>6, "dms"=>11, "sms"=>10, "total"=>55}, "2018-12-14T06:00:00.000Z", {"likes"=>10, "retweets"=>11, "mentions"=>18, "dms"=>11, "sms"=>2, "total"=>52}]}, {:name=>"West Virginia University", :data=>["2018-12-24T06:00:00.000Z", {"likes"=>19, "retweets"=>3, "mentions"=>2, "dms"=>12, "sms"=>7, "total"=>43}, "2018-12-06T06:00:00.000Z", {"likes"=>12, "retweets"=>8, "mentions"=>14, "dms"=>13, "sms"=>4, "total"=>51}, "2018-11-29T06:00:00.000Z", {"likes"=>4, "retweets"=>5, "mentions"=>7, "dms"=>8, "sms"=>7, "total"=>31}, "2018-12-19T06:00:00.000Z", {"likes"=>10, "retweets"=>10, "mentions"=>9, "dms"=>4, "sms"=>2, "total"=>35}, "2018-12-11T06:00:00.000Z", {"likes"=>23, "retweets"=>16, "mentions"=>8, "dms"=>27, "sms"=>13, "total"=>87}]}, {:name=>"StackedSports", :data=>["2018-11-28T06:00:00.000Z", {"likes"=>4, "retweets"=>8, "mentions"=>13, "dms"=>8, "sms"=>10, "total"=>43}, "2018-11-30T06:00:00.000Z", {"likes"=>17, "retweets"=>10, "mentions"=>9, "dms"=>5, "sms"=>1, "total"=>42}, "2018-12-13T06:00:00.000Z", {"likes"=>12, "retweets"=>14, "mentions"=>17, "dms"=>5, "sms"=>2, "total"=>50}]}, {:name=>"Stacked Sports", :data=>["2018-12-22T06:00:00.000Z", {"likes"=>1, "retweets"=>2, "mentions"=>19, "dms"=>13, "sms"=>5, "total"=>40}, "2018-11-30T06:00:00.000Z", {"likes"=>12, "retweets"=>9, "mentions"=>15, "dms"=>12, "sms"=>4, "total"=>52}, "2018-12-07T06:00:00.000Z", {"likes"=>17, "retweets"=>18, "mentions"=>16, "dms"=>14, "sms"=>5, "total"=>70}, "2018-12-02T06:00:00.000Z", {"likes"=>5, "retweets"=>10, "mentions"=>1, "dms"=>15, "sms"=>3, "total"=>34}]}, {:name=>"University of Kentucky", :data=>["2018-11-28T06:00:00.000Z", {"likes"=>14, "retweets"=>8, "mentions"=>4, "dms"=>9, "sms"=>3, "total"=>38}, "2018-12-06T06:00:00.000Z", {"likes"=>10, "retweets"=>11, "mentions"=>5, "dms"=>12, "sms"=>2, "total"=>40}, "2018-12-23T06:00:00.000Z", {"likes"=>11, "retweets"=>17, "mentions"=>11, "dms"=>9, "sms"=>10, "total"=>58}, "2018-12-02T06:00:00.000Z", {"likes"=>12, "retweets"=>2, "mentions"=>7, "dms"=>4, "sms"=>4, "total"=>29}, "2018-12-12T06:00:00.000Z", {"likes"=>18, "retweets"=>19, "mentions"=>20, "dms"=>15, "sms"=>3, "total"=>75}]}]
下面是我们的截图示例: https://screencast.com/t/dZd84zRm2
这是我尝试使用的代码:
<%= line_chart( athlete_report_program_engagement_path(athlete_id: @athlete.id), discrete: true, messages: {empty: "No data"}, download: true, id: 'athlete-program-engagement-chart', options: { tooltips: { label: 'Likes: y.likes<br>RTs: y.retweets<br>Mentions: y.mentions' } } ) %>