How to add links in google chart api









up vote
12
down vote

favorite
2












Can I add links in google chart api?



For example,



enter image description here



How could I add link to "Work" or "Eat" ?



Thanks!










share|improve this question





















  • I don't believe you can insert html code there.
    – AR.
    Jun 1 '11 at 18:09










  • Yes, i tried but can't . Any suggestions?
    – user503853
    Jun 1 '11 at 18:39










  • Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
    – AR.
    Jun 1 '11 at 19:00










  • Duplicate question: stackoverflow.com/questions/12701772/…
    – Mark Butler
    Feb 5 '13 at 3:59














up vote
12
down vote

favorite
2












Can I add links in google chart api?



For example,



enter image description here



How could I add link to "Work" or "Eat" ?



Thanks!










share|improve this question





















  • I don't believe you can insert html code there.
    – AR.
    Jun 1 '11 at 18:09










  • Yes, i tried but can't . Any suggestions?
    – user503853
    Jun 1 '11 at 18:39










  • Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
    – AR.
    Jun 1 '11 at 19:00










  • Duplicate question: stackoverflow.com/questions/12701772/…
    – Mark Butler
    Feb 5 '13 at 3:59












up vote
12
down vote

favorite
2









up vote
12
down vote

favorite
2






2





Can I add links in google chart api?



For example,



enter image description here



How could I add link to "Work" or "Eat" ?



Thanks!










share|improve this question













Can I add links in google chart api?



For example,



enter image description here



How could I add link to "Work" or "Eat" ?



Thanks!







api charts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 1 '11 at 17:59







user503853


















  • I don't believe you can insert html code there.
    – AR.
    Jun 1 '11 at 18:09










  • Yes, i tried but can't . Any suggestions?
    – user503853
    Jun 1 '11 at 18:39










  • Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
    – AR.
    Jun 1 '11 at 19:00










  • Duplicate question: stackoverflow.com/questions/12701772/…
    – Mark Butler
    Feb 5 '13 at 3:59
















  • I don't believe you can insert html code there.
    – AR.
    Jun 1 '11 at 18:09










  • Yes, i tried but can't . Any suggestions?
    – user503853
    Jun 1 '11 at 18:39










  • Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
    – AR.
    Jun 1 '11 at 19:00










  • Duplicate question: stackoverflow.com/questions/12701772/…
    – Mark Butler
    Feb 5 '13 at 3:59















I don't believe you can insert html code there.
– AR.
Jun 1 '11 at 18:09




I don't believe you can insert html code there.
– AR.
Jun 1 '11 at 18:09












Yes, i tried but can't . Any suggestions?
– user503853
Jun 1 '11 at 18:39




Yes, i tried but can't . Any suggestions?
– user503853
Jun 1 '11 at 18:39












Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
– AR.
Jun 1 '11 at 19:00




Don't think it's do-able since there's no tag type element, only string for visualization API. It automatically converts tags to regular text. It is possible to use anchor tags in SVG: w3.org/TR/SVG/images/linking/link01.svg, but I don't think Google API allows it for now. You can ask questions on support forum: groups.google.com/group/google-visualization-api - they are usually good at answering it.
– AR.
Jun 1 '11 at 19:00












Duplicate question: stackoverflow.com/questions/12701772/…
– Mark Butler
Feb 5 '13 at 3:59




Duplicate question: stackoverflow.com/questions/12701772/…
– Mark Butler
Feb 5 '13 at 3:59












4 Answers
4






active

oldest

votes

















up vote
13
down vote



accepted










http://code.google.com/apis/chart/interactive/docs/events.html



<script type="text/javascript"> 
google.load('visualization', '1', 'packages':['corechart']);
google.setOnLoadCallback(drawChart);
function drawChart()

var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'Count');

data.addRows([ ['Value A',5 ],['Value B',61 ],['Value C',53 ],['Value D',22 ] ]);
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, width: 400, height: 280, is3D: true, title: '');

google.visualization.events.addListener(chart, 'select', selectHandler);

function selectHandler(e)
alert(data.getValue(chart.getSelection()[0].row, 0));




</script>





share|improve this answer



























    up vote
    25
    down vote













    Lucky Frank's answer is good, but it just prints an alert box. Here is a more complete answer. I put the links in the DataTable, then I create a DataView so they are not passed to the chart.



    <html>
    <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("visualization", "1", packages:["corechart"]);
    google.setOnLoadCallback(drawChart);
    function drawChart()
    var data = google.visualization.arrayToDataTable([
    ['Task', 'link', 'Hours per Day'],
    ['Work', 'http://www.thefreedictionary.com/work', 11],
    ['Eat', 'http://www.thefreedictionary.com/eat', 2],
    ['Commute', 'http://www.thefreedictionary.com/commute', 2],
    ['Watch TV', 'http://www.thefreedictionary.com/television',2],
    ['Sleep', 'http://www.thefreedictionary.com/sleep', 7]
    ]);

    var view = new google.visualization.DataView(data);
    view.setColumns([0, 2]);

    var options =
    title: 'My Daily Activities'
    ;

    var chart = new google.visualization.PieChart(
    document.getElementById('chart_div'));
    chart.draw(view, options);

    var selectHandler = function(e)
    window.location = data.getValue(chart.getSelection()[0]['row'], 1 );


    // Add our selection handler.
    google.visualization.events.addListener(chart, 'select', selectHandler);

    </script>
    </head>
    <body>
    <div id="chart_div" style="width: 900px; height: 900px;"></div>
    </body>
    </html>


    BTW, the Google Charts API really rocks! Thanks whoever wrote this.






    share|improve this answer




















    • Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
      – Spartacus38
      Feb 5 '14 at 19:06










    • How about developers.google.com/chart/interactive/docs/php_example?
      – Mark Butler
      Feb 5 '14 at 19:11










    • Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
      – Spartacus38
      Feb 5 '14 at 19:14

















    up vote
    0
    down vote













    The simple way of adding link to google barchart;



    var data = google.visualization.arrayToDataTable([
    ['Element', 'Density', role: 'style' , role: 'link' ],
    ['Copper', 8.94, '#b87333', '/your/custom/link' ],
    ['Silver', 10.49, 'silver', '/your/custom/link' ],
    ['Gold', 19.30, 'gold', '/your/custom/link' ],
    ['Platinum', 21.45, 'color: #e5e4e2', '/your/custom/link' ]
    ]);


    and before chart.draw;



     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, 3);
    location.href = link;

    );





    share|improve this answer



























      up vote
      -3
      down vote













      I simply use echo command. You can just replace the text between a comma with a php echo statement. for example you could replace the 11 with a link to sql data:



      ['Work', 'http://www.thefreedictionary.com/work', < ? php echo $row_rs_age_total['Old']], $row_rs_age_total['Old']; ?>],





      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6205621%2fhow-to-add-links-in-google-chart-api%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown
























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        13
        down vote



        accepted










        http://code.google.com/apis/chart/interactive/docs/events.html



        <script type="text/javascript"> 
        google.load('visualization', '1', 'packages':['corechart']);
        google.setOnLoadCallback(drawChart);
        function drawChart()

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('number', 'Count');

        data.addRows([ ['Value A',5 ],['Value B',61 ],['Value C',53 ],['Value D',22 ] ]);
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, width: 400, height: 280, is3D: true, title: '');

        google.visualization.events.addListener(chart, 'select', selectHandler);

        function selectHandler(e)
        alert(data.getValue(chart.getSelection()[0].row, 0));




        </script>





        share|improve this answer
























          up vote
          13
          down vote



          accepted










          http://code.google.com/apis/chart/interactive/docs/events.html



          <script type="text/javascript"> 
          google.load('visualization', '1', 'packages':['corechart']);
          google.setOnLoadCallback(drawChart);
          function drawChart()

          var data = new google.visualization.DataTable();
          data.addColumn('string', 'Name');
          data.addColumn('number', 'Count');

          data.addRows([ ['Value A',5 ],['Value B',61 ],['Value C',53 ],['Value D',22 ] ]);
          var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
          chart.draw(data, width: 400, height: 280, is3D: true, title: '');

          google.visualization.events.addListener(chart, 'select', selectHandler);

          function selectHandler(e)
          alert(data.getValue(chart.getSelection()[0].row, 0));




          </script>





          share|improve this answer






















            up vote
            13
            down vote



            accepted







            up vote
            13
            down vote



            accepted






            http://code.google.com/apis/chart/interactive/docs/events.html



            <script type="text/javascript"> 
            google.load('visualization', '1', 'packages':['corechart']);
            google.setOnLoadCallback(drawChart);
            function drawChart()

            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Name');
            data.addColumn('number', 'Count');

            data.addRows([ ['Value A',5 ],['Value B',61 ],['Value C',53 ],['Value D',22 ] ]);
            var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, width: 400, height: 280, is3D: true, title: '');

            google.visualization.events.addListener(chart, 'select', selectHandler);

            function selectHandler(e)
            alert(data.getValue(chart.getSelection()[0].row, 0));




            </script>





            share|improve this answer












            http://code.google.com/apis/chart/interactive/docs/events.html



            <script type="text/javascript"> 
            google.load('visualization', '1', 'packages':['corechart']);
            google.setOnLoadCallback(drawChart);
            function drawChart()

            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Name');
            data.addColumn('number', 'Count');

            data.addRows([ ['Value A',5 ],['Value B',61 ],['Value C',53 ],['Value D',22 ] ]);
            var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, width: 400, height: 280, is3D: true, title: '');

            google.visualization.events.addListener(chart, 'select', selectHandler);

            function selectHandler(e)
            alert(data.getValue(chart.getSelection()[0].row, 0));




            </script>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 8 '11 at 20:43









            Lucky Frank

            14612




            14612






















                up vote
                25
                down vote













                Lucky Frank's answer is good, but it just prints an alert box. Here is a more complete answer. I put the links in the DataTable, then I create a DataView so they are not passed to the chart.



                <html>
                <head>
                <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                google.load("visualization", "1", packages:["corechart"]);
                google.setOnLoadCallback(drawChart);
                function drawChart()
                var data = google.visualization.arrayToDataTable([
                ['Task', 'link', 'Hours per Day'],
                ['Work', 'http://www.thefreedictionary.com/work', 11],
                ['Eat', 'http://www.thefreedictionary.com/eat', 2],
                ['Commute', 'http://www.thefreedictionary.com/commute', 2],
                ['Watch TV', 'http://www.thefreedictionary.com/television',2],
                ['Sleep', 'http://www.thefreedictionary.com/sleep', 7]
                ]);

                var view = new google.visualization.DataView(data);
                view.setColumns([0, 2]);

                var options =
                title: 'My Daily Activities'
                ;

                var chart = new google.visualization.PieChart(
                document.getElementById('chart_div'));
                chart.draw(view, options);

                var selectHandler = function(e)
                window.location = data.getValue(chart.getSelection()[0]['row'], 1 );


                // Add our selection handler.
                google.visualization.events.addListener(chart, 'select', selectHandler);

                </script>
                </head>
                <body>
                <div id="chart_div" style="width: 900px; height: 900px;"></div>
                </body>
                </html>


                BTW, the Google Charts API really rocks! Thanks whoever wrote this.






                share|improve this answer




















                • Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                  – Spartacus38
                  Feb 5 '14 at 19:06










                • How about developers.google.com/chart/interactive/docs/php_example?
                  – Mark Butler
                  Feb 5 '14 at 19:11










                • Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                  – Spartacus38
                  Feb 5 '14 at 19:14














                up vote
                25
                down vote













                Lucky Frank's answer is good, but it just prints an alert box. Here is a more complete answer. I put the links in the DataTable, then I create a DataView so they are not passed to the chart.



                <html>
                <head>
                <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                google.load("visualization", "1", packages:["corechart"]);
                google.setOnLoadCallback(drawChart);
                function drawChart()
                var data = google.visualization.arrayToDataTable([
                ['Task', 'link', 'Hours per Day'],
                ['Work', 'http://www.thefreedictionary.com/work', 11],
                ['Eat', 'http://www.thefreedictionary.com/eat', 2],
                ['Commute', 'http://www.thefreedictionary.com/commute', 2],
                ['Watch TV', 'http://www.thefreedictionary.com/television',2],
                ['Sleep', 'http://www.thefreedictionary.com/sleep', 7]
                ]);

                var view = new google.visualization.DataView(data);
                view.setColumns([0, 2]);

                var options =
                title: 'My Daily Activities'
                ;

                var chart = new google.visualization.PieChart(
                document.getElementById('chart_div'));
                chart.draw(view, options);

                var selectHandler = function(e)
                window.location = data.getValue(chart.getSelection()[0]['row'], 1 );


                // Add our selection handler.
                google.visualization.events.addListener(chart, 'select', selectHandler);

                </script>
                </head>
                <body>
                <div id="chart_div" style="width: 900px; height: 900px;"></div>
                </body>
                </html>


                BTW, the Google Charts API really rocks! Thanks whoever wrote this.






                share|improve this answer




















                • Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                  – Spartacus38
                  Feb 5 '14 at 19:06










                • How about developers.google.com/chart/interactive/docs/php_example?
                  – Mark Butler
                  Feb 5 '14 at 19:11










                • Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                  – Spartacus38
                  Feb 5 '14 at 19:14












                up vote
                25
                down vote










                up vote
                25
                down vote









                Lucky Frank's answer is good, but it just prints an alert box. Here is a more complete answer. I put the links in the DataTable, then I create a DataView so they are not passed to the chart.



                <html>
                <head>
                <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                google.load("visualization", "1", packages:["corechart"]);
                google.setOnLoadCallback(drawChart);
                function drawChart()
                var data = google.visualization.arrayToDataTable([
                ['Task', 'link', 'Hours per Day'],
                ['Work', 'http://www.thefreedictionary.com/work', 11],
                ['Eat', 'http://www.thefreedictionary.com/eat', 2],
                ['Commute', 'http://www.thefreedictionary.com/commute', 2],
                ['Watch TV', 'http://www.thefreedictionary.com/television',2],
                ['Sleep', 'http://www.thefreedictionary.com/sleep', 7]
                ]);

                var view = new google.visualization.DataView(data);
                view.setColumns([0, 2]);

                var options =
                title: 'My Daily Activities'
                ;

                var chart = new google.visualization.PieChart(
                document.getElementById('chart_div'));
                chart.draw(view, options);

                var selectHandler = function(e)
                window.location = data.getValue(chart.getSelection()[0]['row'], 1 );


                // Add our selection handler.
                google.visualization.events.addListener(chart, 'select', selectHandler);

                </script>
                </head>
                <body>
                <div id="chart_div" style="width: 900px; height: 900px;"></div>
                </body>
                </html>


                BTW, the Google Charts API really rocks! Thanks whoever wrote this.






                share|improve this answer












                Lucky Frank's answer is good, but it just prints an alert box. Here is a more complete answer. I put the links in the DataTable, then I create a DataView so they are not passed to the chart.



                <html>
                <head>
                <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                google.load("visualization", "1", packages:["corechart"]);
                google.setOnLoadCallback(drawChart);
                function drawChart()
                var data = google.visualization.arrayToDataTable([
                ['Task', 'link', 'Hours per Day'],
                ['Work', 'http://www.thefreedictionary.com/work', 11],
                ['Eat', 'http://www.thefreedictionary.com/eat', 2],
                ['Commute', 'http://www.thefreedictionary.com/commute', 2],
                ['Watch TV', 'http://www.thefreedictionary.com/television',2],
                ['Sleep', 'http://www.thefreedictionary.com/sleep', 7]
                ]);

                var view = new google.visualization.DataView(data);
                view.setColumns([0, 2]);

                var options =
                title: 'My Daily Activities'
                ;

                var chart = new google.visualization.PieChart(
                document.getElementById('chart_div'));
                chart.draw(view, options);

                var selectHandler = function(e)
                window.location = data.getValue(chart.getSelection()[0]['row'], 1 );


                // Add our selection handler.
                google.visualization.events.addListener(chart, 'select', selectHandler);

                </script>
                </head>
                <body>
                <div id="chart_div" style="width: 900px; height: 900px;"></div>
                </body>
                </html>


                BTW, the Google Charts API really rocks! Thanks whoever wrote this.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 6 '13 at 12:08









                Mark Butler

                3,62323138




                3,62323138











                • Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                  – Spartacus38
                  Feb 5 '14 at 19:06










                • How about developers.google.com/chart/interactive/docs/php_example?
                  – Mark Butler
                  Feb 5 '14 at 19:11










                • Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                  – Spartacus38
                  Feb 5 '14 at 19:14
















                • Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                  – Spartacus38
                  Feb 5 '14 at 19:06










                • How about developers.google.com/chart/interactive/docs/php_example?
                  – Mark Butler
                  Feb 5 '14 at 19:11










                • Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                  – Spartacus38
                  Feb 5 '14 at 19:14















                Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                – Spartacus38
                Feb 5 '14 at 19:06




                Wow Mark Butler I've been search forever for this! Sorry to reply to an old thread, but do you know how one would be able to get this to work using MySQL? I am currently using MySQL with my existing google chart, but I use two pages, one for the chart, and the other for the json. Thanks!
                – Spartacus38
                Feb 5 '14 at 19:06












                How about developers.google.com/chart/interactive/docs/php_example?
                – Mark Butler
                Feb 5 '14 at 19:11




                How about developers.google.com/chart/interactive/docs/php_example?
                – Mark Butler
                Feb 5 '14 at 19:11












                Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                – Spartacus38
                Feb 5 '14 at 19:14




                Yeah that's basically exactly how my code looks, but that doesn't explain how to get a string from SQL and turn it into a link. My chart works perfectly great, but now I want more depth where they click on the point and view the details of the metrics.
                – Spartacus38
                Feb 5 '14 at 19:14










                up vote
                0
                down vote













                The simple way of adding link to google barchart;



                var data = google.visualization.arrayToDataTable([
                ['Element', 'Density', role: 'style' , role: 'link' ],
                ['Copper', 8.94, '#b87333', '/your/custom/link' ],
                ['Silver', 10.49, 'silver', '/your/custom/link' ],
                ['Gold', 19.30, 'gold', '/your/custom/link' ],
                ['Platinum', 21.45, 'color: #e5e4e2', '/your/custom/link' ]
                ]);


                and before chart.draw;



                 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, 3);
                location.href = link;

                );





                share|improve this answer
























                  up vote
                  0
                  down vote













                  The simple way of adding link to google barchart;



                  var data = google.visualization.arrayToDataTable([
                  ['Element', 'Density', role: 'style' , role: 'link' ],
                  ['Copper', 8.94, '#b87333', '/your/custom/link' ],
                  ['Silver', 10.49, 'silver', '/your/custom/link' ],
                  ['Gold', 19.30, 'gold', '/your/custom/link' ],
                  ['Platinum', 21.45, 'color: #e5e4e2', '/your/custom/link' ]
                  ]);


                  and before chart.draw;



                   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, 3);
                  location.href = link;

                  );





                  share|improve this answer






















                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    The simple way of adding link to google barchart;



                    var data = google.visualization.arrayToDataTable([
                    ['Element', 'Density', role: 'style' , role: 'link' ],
                    ['Copper', 8.94, '#b87333', '/your/custom/link' ],
                    ['Silver', 10.49, 'silver', '/your/custom/link' ],
                    ['Gold', 19.30, 'gold', '/your/custom/link' ],
                    ['Platinum', 21.45, 'color: #e5e4e2', '/your/custom/link' ]
                    ]);


                    and before chart.draw;



                     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, 3);
                    location.href = link;

                    );





                    share|improve this answer












                    The simple way of adding link to google barchart;



                    var data = google.visualization.arrayToDataTable([
                    ['Element', 'Density', role: 'style' , role: 'link' ],
                    ['Copper', 8.94, '#b87333', '/your/custom/link' ],
                    ['Silver', 10.49, 'silver', '/your/custom/link' ],
                    ['Gold', 19.30, 'gold', '/your/custom/link' ],
                    ['Platinum', 21.45, 'color: #e5e4e2', '/your/custom/link' ]
                    ]);


                    and before chart.draw;



                     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, 3);
                    location.href = link;

                    );






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 11 at 11:59









                    Tuncay Elvanağaç

                    212




                    212




















                        up vote
                        -3
                        down vote













                        I simply use echo command. You can just replace the text between a comma with a php echo statement. for example you could replace the 11 with a link to sql data:



                        ['Work', 'http://www.thefreedictionary.com/work', < ? php echo $row_rs_age_total['Old']], $row_rs_age_total['Old']; ?>],





                        share|improve this answer


























                          up vote
                          -3
                          down vote













                          I simply use echo command. You can just replace the text between a comma with a php echo statement. for example you could replace the 11 with a link to sql data:



                          ['Work', 'http://www.thefreedictionary.com/work', < ? php echo $row_rs_age_total['Old']], $row_rs_age_total['Old']; ?>],





                          share|improve this answer
























                            up vote
                            -3
                            down vote










                            up vote
                            -3
                            down vote









                            I simply use echo command. You can just replace the text between a comma with a php echo statement. for example you could replace the 11 with a link to sql data:



                            ['Work', 'http://www.thefreedictionary.com/work', < ? php echo $row_rs_age_total['Old']], $row_rs_age_total['Old']; ?>],





                            share|improve this answer














                            I simply use echo command. You can just replace the text between a comma with a php echo statement. for example you could replace the 11 with a link to sql data:



                            ['Work', 'http://www.thefreedictionary.com/work', < ? php echo $row_rs_age_total['Old']], $row_rs_age_total['Old']; ?>],






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited May 4 '15 at 6:45









                            Alexander Vogt

                            15.3k133552




                            15.3k133552










                            answered May 4 '15 at 6:26









                            Tim

                            1




                            1



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6205621%2fhow-to-add-links-in-google-chart-api%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                這個網誌中的熱門文章

                                Barbados

                                How to read a connectionString WITH PROVIDER in .NET Core?

                                Node.js Script on GitHub Pages or Amazon S3