Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column Google chart legend position issue

I want to simply set the marked place legend on top of the graph.
The following is the Google Chart code which does not work:

var wrapper = new google.visualization.ChartWrapper({
  chartType: 'ColumnChart',
  dataTable: Dydata,
  containerId: 'visualization',
  legend: { position: 'bottom', alignment: 'start' },
  width: 520,
  height: 350
});
wrapper.draw();
like image 830
user2660267 Avatar asked Aug 12 '13 10:08

user2660267


2 Answers

If you want the legend at the top of your chart, you need to set the legend.position option to "top":

legend: { position: 'top', alignment: 'start' }

and when using a ChartWrapper, your options need to be inside the "options" parameter:

var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    dataTable: Dydata,
    containerId: 'visualization',
    options: {
        legend: { position: 'top', alignment: 'start' },
        width: 520,
        height: 350
    }
});
wrapper.draw();
like image 99
asgallant Avatar answered Oct 02 '22 21:10

asgallant


we need to add the code inside option section eg. as below :

chart1.options = {
        legend: { position: 'top', alignment: 'end' },
        "title": "Sales per month",
        "isStacked": "true",
        // "fill": 20,
        "displayExactValues": true,
        "vAxis": {
            "title": "Sales unit",
            "gridlines": {
                "count": 10
            }
        },
        "hAxis": {
            "title": "Date"
        }
    };
like image 45
SantoshK Avatar answered Oct 02 '22 20:10

SantoshK