Google Apps Script: How to set "Use column A as labels" in chart embedded in spreadsheet?

Found it! Set the option useFirstColumnAsDomain to true with EmbeddedChartBuilder.setOption.

This option appears to be undocumented. I found it by going to "Publish chart" (click on the chart, then select from the drop-down in the top right) and inspecting the JavaScript data structure in the given code. To be exact, I created a chart with "Use column A as labels" unchecked, grabbed the publish data structure, then checked "use column A as labels", grabbed the new publish data structure, and compared the two. To compare, I suggest normalizing the JSON and running diff. This technique can be used to reverse-engineer any settings in the chart editor.


I just experienced this same problem. I took a similar approach as Andrew, but found a different solution (presumably because Google has added functionality to their graphs in Spreadsheets).

I used http://jsbeautifier.org/ to format the code after publishing, and I found this part to be responsible for adding the data labels. Note that you can even change the color of the stem that connects the bar to the data label:

"series": {
                    "0": {
                        "errorBars": {
                            "errorType": "none"
                        },
                        "dataLabel": "value",
                        "annotations": {
                            "stemColor": "none"
                        }
                    },
                    "color": "black",
                    "targetAxisIndex": 0,
                    "annotations": {
                        "textStyle": {
                            "color": "red",
                            "fontSize": 12
                        }
                    }
                },