Re: Customs Labels under horizontal axis

57 views
Skip to first unread message

asgallant

unread,
Oct 16, 2012, 4:36:39 PM10/16/12
to google-visua...@googlegroups.com
The only way to do that would be to have the first column be type "string", and enter the numbers as strings, eg:

data.addColumn('string', 'Y');
data.addColumn('number', 'X');
data.addRows(6);
data.setCell(0, 0, 'zero');
...

This will make your axis into a discrete axis instead of a continuous axis, though (see the difference here).

On Tuesday, October 16, 2012 2:13:39 PM UTC-4, NickMi wrote:
I spent hours to find answer for this question......

I have simple line graph (xy style):


        google.load("visualization", "1", {packages:["corechart"]});
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('number', 'Y');
            data.addColumn('number', 'X');
            data.addRows(6);
            data.setCell(0, 0, 0);
            data.setCell(0, 0, 1);
            data.setCell(1, 0, 2);
            data.setCell(1, 1, 2);
            data.setCell(2, 0, 3);
            data.setCell(2, 1, 3);
            data.setCell(3, 0, 4);
            data.setCell(3, 1, 4);
            data.setCell(4, 0, 5);
            data.setCell(4, 1, 5);
            data.setCell(5, 0, 6);
            data.setCell(5, 1, 6);

            var options = {
                title: 'Title'
            };
            var table = new google.visualization.LineChart(document.getElementById('chart_div'));
            table.draw(data, options);


Well, labels under X-Axis is the actual numbers! I would to know how can I set my customs labels under X-Axis(example: Zero, One, Two, Four, but not 0, 1, 2, 4 ,5). By words, but not by arabic numbers. I hope someone will help me.
 
 

NickMi

unread,
Oct 17, 2012, 7:26:39 AM10/17/12
to google-visua...@googlegroups.com
Thanks for reply, but I need exactly continues graph... Graph that represents the X and Y number values....... Difficult to belive that it's impossible to do so with google visualization......

asgallant

unread,
Oct 17, 2012, 10:51:05 AM10/17/12
to google-visua...@googlegroups.com
You can have graphs with X and Y number values, that's not the problem.  You just can't format the axes to use words for the numbers.  The Visualization API is hardly unique here, I've never come across a chart API that allows this.
Reply all
Reply to author
Forward
0 new messages