Close More (Vert) Close

When creating a ZingChart JSON packet you may find yourself fiddling with properties to fine tune the style and structure of your chart.  An easy way to accomplish this is to utilize the dash (-) trick.  Basically, if you want to exclude a property from ZingChart's render just put a dash at the front of it, within the parenthesis.  For example here you may have placed some notes in a line chart.

{  
  "graphset" : [  
  {  
    "type" : "line",  
    "notes": [  
    	{"text": "Our first note", "x": 100, "y": 40},  
    	{"text": "I love oranges", "x": 280, "y": 100}  
  
    ],  
    "series" : [  
     {  
        "values" : [11,26,7,44,11,28,42,26,13,32,12,4,21,11,43,39]  
     },  
     {  
        "values" : [42,13,21,15,33,10,30,46,10,7,27,40,1,32,22,45]  
     },  
     {  
        "values" : [23,24,13,4,18,6,24,10,26,44,32,17,17,27,14,36]  
     }]   
  }]  
}

Commenting-Out Chart Properties

However, now you want to hide one of the notes because it is in the way of something you are working on so you just prefix the note in question with a dash and it is gone.

{  
  "graphset" : [  
  {  
    "type" : "line",  
    "notes": [  
    	{"text": "Our first note", "x": 100, "y": 40},  
    	{"-text": "I love oranges", "x": 280, "y": 100}  
  
    ],  
    "series" : [  
     {  
        "values" : [11,26,7,44,11,28,42,26,13,32,12,4,21,11,43,39]  
     },  
     {  
        "values" : [42,13,21,15,33,10,30,46,10,7,27,40,1,32,22,45]  
     },  
     {  
        "values" : [23,24,13,4,18,6,24,10,26,44,32,17,17,27,14,36]  
     }]   
  }]  
}

Benefits

No parse error and it is easy to recover the property later on.  The dash is somewhat arbitrary, but the basic rule of thumb is ZingChart will ignore unknown properties as long as they are quoted properly.  You could thus use DEBUG-text or whatever you wanted to prefix the property with, we have over time just found the single - character the most natural way to mask things out when you are tinkering with a chart JSON packet.

comments powered by Disqus