When you say it isn't working correctly, can you describe specifically what
is happening, and how it differs from what you would like to happen?
On Sunday, February 24, 2013 9:12:09 AM UTC-5, Workaholic wrote:
>
> Hi again,
> I found that the problem is more serious than I thoght, something related
> to the way I set the series.
> The problem is when the state of the string filter changes the update of
> the series is not working correctly.
> When the filter state doesn't change it works perfect.
> Can somebody help me with this issue?
> Here is my updated code:
>
> var columnsTable = new google.visualization.DataTable();
> columnsTable.addColumn('number', 'colIndex');
> columnsTable.addColumn('string', 'colLabel');
> var initState = {
> selectedValues: []
> };
> for (var i = 1; i < drilledJoinTable.getNumberOfColumns(); i++) {
> columnsTable.addRow([i, drilledJoinTable.getColumnLabel(i)]);
> initState.selectedValues.push(drilledJoinTable.getColumnLabel(i));
> }
> labelsLength=columnsTable.getNumberOfRows();
> var chart = new google.visualization.ChartWrapper({
> chartType: 'LineChart',
> containerId: 'secondChart',
> dataTable: drilledJoinTable
> });
> var columnFilter = new google.visualization.ControlWrapper({
> controlType: 'CategoryFilter',
> containerId: 'drilledStringFilterSecondChart',
> dataTable: columnsTable,
> options: {
> filterColumnLabel: 'colLabel',
> //values:columnIndices,
> ui: {
> label: '',
> allowTyping: false,
> allowMultiple: true,
> selectedValuesLayout: 'belowStacked'
> }
> },
> //state: {selectedValues: columnIndices}
> state: initState
> });
>
> var selectedLabels = new Array();
> for(var i=0; i<drilledColumnIndices.length; i++){
>
> selectedLabels.push(drilledJoinTable.getColumnLabel(drilledColumnIndices[i]));
> }
> columnFilter.setState({selectedValues: selectedLabels});
> var series = {};
> var numberOfSeries = drilledColumnIndices.length - 1;//////////////////
> //alert(columnIndices.length);
> for ( var i = 0; i < numberOfSeries; i++) {
> series[i] = {
> targetAxisIndex: (drilledColumnIndices[i + 1] <= numberOfSeries / 2) ? 0 :
> 1
> };
> }
> chart.setOption('series', series);
> chart.setView({
> columns: drilledColumnIndices
> });
> chart.draw();
> columnFilter.draw();
> google.visualization.events.addListener(columnFilter, 'statechange',
> function () {
> //stringFilterActive=true;
> var state = columnFilter.getState();
> var row;
> drilledColumnIndices = [0];
> for (var i = 0; i < state.selectedValues.length; i++) {
> row = columnsTable.getFilteredRows([{
> column: 1,
> value: state.selectedValues[i]
> }])[0];
> drilledColumnIndices.push(columnsTable.getValue(row, 0));
> }
> // sort the indices into their original order
> drilledColumnIndices.sort(function (a, b) {
> return (a - b);
> });
> var indicesLength = drilledColumnIndices.length;
> for(var i=1; i<indicesLength; i++){
>
> drilledColumnIndices.push(drilledColumnIndices[i]+Math.ceil(labelsLength/2));
> }
> var series = {};
> var numberOfSeries = drilledColumnIndices.length - 1;/////////////////
> for ( var i = 0; i < numberOfSeries; i++) {
> series[i] = {
> targetAxisIndex: (drilledColumnIndices[i + 1] <= numberOfSeries / 2) ? 0 :
> 1
> };
> }
> chart.setOption('series', series);
> //alert("in listener");
> //alert(columnsTable.getNumberOfRows());
> //alert(columnIndices);
> chart.setView({
> columns: drilledColumnIndices
> });
>
>
> chart.draw();
> });
>
> Thanks.
>
> On Thursday, February 14, 2013 10:34:36 AM UTC+2, Workaholic wrote:
>>
>> Hi,
>> I've 2 tables with the same labels as attached.
>> I've a chart displaying only one of them for now("chart.jpg").
>> Is it possible to mix them to one chart with two y axis, each displaying
>> different table?
>>
>> Thanks.
>>
>
--
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.