Search code examples
google-apps-scriptgoogle-sheetsgoogle-visualization

Google Apps Script Combo chart duplicates same values on x-axis


When I use a Combo Chart with serie type:Line the values on the x-axis get duplicated. For example the data range used for the display:

    
    X       Y
    31      0
    31      0,1
    32,6    0,1
    32,6    0
    32,6    0,35
    34,2    0,35
    34,2    0
    34,2    0,1
    35,8    0,1
    35,8    0
    35,8    0,3
    37,4    0,3
    37,4    0
    37,4    0,1
    39      0,1
    39      0
    40,6    0
    42,2    0
    43,8    0
    45,4    0
    45,4    0,05
    47      0,05
    47      0
     

In above the Combo Chart with serie type:

Line drawn:

enter image description here
All values for X on x-axis are duplicate. The scatter chart draws 2 points for each X values. I want to show single x-axis value with different y-axis values.

I want the combo chart output should be like : enter image description here

In this sheet https://docs.google.com/spreadsheets/d/1hgptynoUuuPDg5SvTH3l68mt7eWvX5DOdvkvK_rde4Q/edit#gid=907746395, you can launch the script "unitDisplaySerie" in script editor to reproduce the problem.


Solution

  • This appears to be a bug!

    After doing some testing with both the Sheets method of creating charts and the Visualization API it seems that this is inconsistent and probably unintended. I have taken the liberty of reporting this on Google's Issue Tracker for you, detailing the behaviour:

    You can hit the ☆ next to the issue number in the top left on the page which lets Google know more people are encountering this and so it is more likely to be seen to faster.