Can I link to another URL using chart diagrams?

I have an application for rails 4 and I use chartkick. I am currently using pie charts, and I am wondering if there is a way so that every section of my pie chart can go to an endpoint or URL or something really.

How will someone handle this? Will this be done in an ERB file or controller? And how will this be done?

+4
source share
1 answer

I spent a lot of time trying to figure it out myself. Unfortunately, there seems to be no easy option to “add a link here and go.”

Chartkick , Google Highcharts. , 'click' /. , , JQuery/JS, - , , .

HighCharts : http://api.highcharts.com/highcharts#plotOptions.pie.events.click

, , JS/Jquery ( Coffescript http://js2.coffee) http://birdchan.com/home/2012/09/07/highcharts-pie-charts-can-have-url-links/

, , , , , :

data: [
            {name: 'Not Tested', color: '#FFA850', y: 87, url: 'http://my_site1.com'},
            {name: 'Fail', color: '#FF2929', y: 2, url: 'http://my_site2.com'},
            {name: 'Pass', color: '#31FF4F', y: 32, url: 'http://my_site3.com'}
        ]

- :

$.ajax {
url: "/place/resources/resource_id/top_members.json"
success: (data) ->
  draw_some_pie_chart(data)
}

GON gem, Coffeescript/JS.

, / . , ,

0

Source: https://habr.com/ru/post/1533622/


All Articles