There is something happening with a stacked column chart I cannot figure 
out...

Here is a boiled down data set:

             ...    name1    value1    name2    value2    name3    value3 
   name4    value4    name5    value5    type     date ...
row 1                   a        20            b        30             c 
       20              d        15               e        15         
1         
row 2                   f         20            g        30             h 
       20               i        15          NULL        0          2
row 3                   j         20            k        30             l  
       20        NULL         0           NULL        0         3

I use a category filter to filter data on the type column. Before the 
column chart draws, I also update several chart options (colors, title, 
etc) and also the datatable column names on the five value columns so the 
column name is the name column value. Since this is a stacked column chart 
with all 5 values in one column, the legend shows the color series and 
names nicely. When a type selection is made, the legend changes to show a 
new color series and 3-5 color squares with the corresponding names.  This 
is all very nice....

...until I filter the datatable by date. After that, the legend will change 
color and will show the appropriate number of legend items, but it will not 
update the names that are next to each color square.  The names appear to 
be "stuck" on the values that existed  before the datatable filter. There 
are no errors. It is strange that all the updates to the chart options do 
update except for the legend names.

Has anyone run into something like this before?

There is a lot of code, so here is the relevant functions:

function changeStudentChart(type,group){
//returns nothing
//change attributes of the column chart based on the assessment type
    switch (type){
    case 'Mindset':
        colors=gcolors[0];//mindset blues
        stackcolStudent.setView({'columns': [3,11,5,12,6,13,7,14,8,15,9]});
        break; 
    case 'Brain Health':
        colors=gcolors[1];//health purples
        stackcolStudent.setView({'columns': [3,11,5,12,6,13,7]});
        break; 
    case 'Stress Management':
        colors=gcolors[2]; //stress oranges
        stackcolStudent.setView({'columns': [3,11,5,12,6,13,7,14,8]});
        break;
    case 'Strategy':
        colors=gcolors[3]; //strategy greens
        stackcolStudent.setView({'columns': [3,11,5,12,6,13,7,14,8,15,9]});
        break;
    default : 
        console.debug('Assessment Type not recognized.');
    }
    changeColumnNames(type);
    //set background color theme
    stackcolStudent.setOption('colors',colors); 
    stackcolStudent.setOption('title',group+' '+type+' Average');
    assessmentPicker.draw(); // this triggers an update of the 
stackcolStudent chart
}

function changeColumnNames(type){ //TODO: accept a numeric type rather than 
a string
//returns nothing
//Modifies the chart column names so the legend will be updated
    rowArray = datatable_student.getFilteredRows([{column: 4, value: 
type}]); //,{column: 16, minValue: 1}]);
   // console.debug('rowArray rows='+rowArray.length+'rowArray='+rowArray);
    if(rowArray.length==0){
        //do not show a legend if there are no rows to display
        stackcolStudent.setOption('legend','none'); 
    }else{
        //since all rows will have the same column names, just use the 
first row
        rowNum = rowArray[0];
       // console.debug('rowNum='+rowNum);
        //Modify the column name to be the tooltip column value
        
//console.debug('('+rowNum+',5)='+datatable_student.getFormattedValue(rowNum, 
5));
        if(datatable_student.getFormattedValue(rowNum, 5)==''){
            //do not show a legend if the row does not have values
            stackcolStudent.setOption('legend','none'); 
        }else{
            //console.trace();
            stackcolStudent.setOption('legend','top');
            datatable_student.setColumnLabel(11, 
datatable_student.getFormattedValue(rowNum, 5));
            datatable_student.setColumnLabel(12, 
datatable_student.getFormattedValue(rowNum, 6));
            datatable_student.setColumnLabel(13, 
datatable_student.getFormattedValue(rowNum, 7));
            datatable_student.setColumnLabel(14, 
datatable_student.getFormattedValue(rowNum, 8));
            datatable_student.setColumnLabel(15, 
datatable_student.getFormattedValue(rowNum, 9));
            //datatable_student.setColumnLabel(16, 
datatable_student.getFormattedValue(rowNum, 10));
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to