Search
 
SCRIPT & CODE EXAMPLE
 

HTML

How to add link on bar for google bar chart

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

<script>
    google.charts.load('current', {
        packages: ['corechart', 'bar']
    });
    google.charts.setOnLoadCallback(drawBasic);

    function drawBasic() {

        var data = google.visualization.arrayToDataTable([
            ['City', '2010 Population', { role: 'link' }],
            ['New York City, NY', 8175000, 'yout link'],
            ['Los Angeles, CA', 3792000, 'yout link'],
            ['Chicago, IL', 2695000, 'yout link'],
            ['Houston, TX', 2099000, 'yout link'],
            ['Philadelphia, PA', 1526000, 'yout link']
        ]);

        var options = {
            title: 'Population of Largest U.S. Cities',
            chartArea: {
                width: '50%'
            },
            hAxis: {
                title: 'Total Population',
                minValue: 0
            },
            vAxis: {
                title: 'City'
            }
        };

        var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
        
        google.visualization.events.addListener(chart, 'select', function (e) {
            var selection = chart.getSelection();
                if (selection.length) {
                    var row = selection[0].row;
                    let link = data.getValue(row, 2);
                    window.open(link,'_blank');
                }
        });

        chart.draw(data, options);
    }
</script>
Comment

PREVIOUS NEXT
Code Example
Html :: the row #3 could not be found, please file an issue in the tracker with the html code 
Html :: does redux has a unidirectional data flow? 
Html :: how to keep audio in the web html 
Html :: tailwindcss letterspacing 
Html :: lalalala 
Html :: 7th science book 
Html :: laravel afficher fichier 
Html :: java.rmi.connectexception: connection refused to host: 127.0.0.1 
Html :: display pdf in html fastapi 
Html :: view uava code in html 
Html :: how sat drop down list in bootstrap 4 like a row and column 
Html :: links mail 
Html :: bootstrap flex box 
Html :: html overflow with span 
Html :: Apit teks Selamat Datang di Progate dengan tag <h1. 
Html :: open a website within a website 
Html :: typo3 fluid form input text 
Html :: javascript on enter search 
Html :: html input avoid pre spacing 
Html :: functioning search engine code 
Html :: span value html 
Html :: apache2 index.html location 
Html :: run 2 function on input vue 
Html :: how to display gif when button clicked html css 
Html :: encode plus sign in url 
Html :: website making sites 
Html :: remove html between 2 tags javas 
Css :: css textarea background color transparent 
Css :: css get rid of button outline on click 
Css :: how to hide the bullet list css 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =