raunaqmathur / google-visualization-java

Automatically exported from code.google.com/p/google-visualization-java
0 stars 0 forks source link

Not drop entire json not-last null valued cell when it have properties / formatted string #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create DataTable object with some not-last null valued cell and add 
formatted String and/or custom property
2. Get the DataTable json.

JsonRenderer implementation: The final json avoid null valued cells when the 
cell isn't last cell of the row even though includeFormatting parameter is true 
valued. The response of the JsonRenderer.renderDataTable for a four-cell row 
with null value at second and third row (but with property and/or formatted 
string) looks like: {v:X,p:{property=value}}},,,{v:Y,p:{property=value}. 

Version: All versions /all platforms (showed at 1.0.2 version but I've seen 
that 1.1.1 has the same behavior)

I understand that this behavior reduces response size but sometimes properties 
and/or formatted values can have visualization purposes (like style with a 
Table visualization) or maybe null values can be useful in some context. I 
think that this option must be optional (to avoid null valued cells or not; 
even last).

I've tried to remove the last condition (not the body condition) in the 
JsonRenderer.appendCellJson and this works for me. 

This change looks like:
[...]
//    if ((isLastColumn) || (!isJsonNull)) { - 'cause i want all info
      sb.append("{");
      // Value
      sb.append("v:").append(valueJson);
      // Formatted value
      if ((includeFormatting) && (!escapedFormattedString.equals(""))) {
        sb.append(",f:'").append(escapedFormattedString).append("'");
      }
      String customPropertiesString = getPropertiesMapString(cell.getCustomProperties());
      if (customPropertiesString != null) {
        sb.append(",p:").append(customPropertiesString);
      }
      sb.append("}");
//    }
} // appendCellJson ends here

Original issue reported on code.google.com by gleon...@gmail.com on 25 Jun 2012 at 9:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
* {v:X,p:{property=value}},,,{v:Y,p:{property=value}} not 
{v:X,p:{property=value}}},,,{v:Y,p:{property=value}
* condition body not body condition

Sorry!

Original comment by gleon...@gmail.com on 25 Jun 2012 at 9:57