juxwn
juxwn

Reputation: 13

undefined value in Highchart

I created a pie chart out of a html table with Highcharts. Everything works fine, the only problem is that whenever I hover a piece of my chart, it displays undefined. Below two screenshots of how my current solution looks like and what it should look like: what my solution looks like what it should look like.

Javascript code for highchart:

<script>
Highcharts.chart('container', {
    data: {
        table: 'datatable'
    },
    chart: {
        type: 'pie'
    },
    title: {
        text: 'Auswertung Herkunftsbefragung'
    },
    tooltip: {
        formatter: function(){
            return '<b>' +this.series.name + '</b><br />'+this.pointy+' '+this.point.name.toLowerCase();
        }
    }
});
</script>

PHP Code which builds the HTML table:

<table id="datatable" style="border: 1px solid black"><thead><tr>
<th>Country</th>
<th>Counter</th>
</tr></thead><tbody>
<?php
foreach($analysis_data as $row){
    echo "<tr>";
    foreach(['country', 'counter'] as $attribute){
        echo "<td>".$row[$attribute]."</td>";
    }
    echo "</tr>";
}
?>
</tbody></table>

Does anybody know what I have to modify to archieve this?

Upvotes: 0

Views: 433

Answers (1)

juxwn
juxwn

Reputation: 13

<script>
Highcharts.chart('container', {
    data: {
        table: 'datatable'
    },
    chart: {
        type: 'pie'
    },
    title: {
        text: 'Auswertung Herkunftsbefragung'
    },
    tooltip: {
        formatter: function(){
            return '<b>' +this.series.name + '</b><br />'+this.point.y+' '+this.point.name.toLowerCase();
        }
    }
});
</script>

this.point.y is undefined. Thanks to @Troopers

Upvotes: 0

Related Questions