I create .json files directly from a Java program. I am finding it difficult to understand where to put some of the json notations and what format to use.
I can’t figure out how to add an annotation to a JSON chart.
Here is a simple plot.json chart w/out any annotations:
{
“data”: [
{
“name”: “My 1st Data set name”,
“type”: “scatter”,
“x”: [1.0, 2.0, 3.0, 4.0],
“y”: [1.0, 4.0, 2.0, 3.0],
“mode”: “lines+markers”
},
{
“name”: “My 2nd Data set name”,
“type”: “scatter”,
“x”: [1.0, 2.0, 3.0, 4.0],
“y”: [3.0, 1.0, 3.0, 4.0],
“mode”: “markers”
}
],
“layout”: {
“title”: {
“text”: “Layout Title”
}
}
}
When I run this through orca “orca graph plot.json” I get the attached png:
If I wanted to add an annotation to the JSON chart such as:
“annotation”: {
“x”=0.5,
“y”=0.5,
“xref”=“x”,
“yref”=“y”,
“text”=“My annotation”,
“xanchor”=“right”,
“yanchor”=“bottom”
}
Where would I add the above text… No matter where I put it, it does not add an annotation to the chart. orca won’t even parse the json file I think. I can’t tell if my JSON above for the annotation is incorrect (i.e. won’t parse) or where I place the above in my plot.json file is incorrect (i.e. won’t parse because of the location I added the code).
I have tried placing it inside layout and outside layout. I made sure the commas are corrected on the previous lines when I added the above because the JSON format is super finicky about commas.
I put this question at the top level because there is no JSON category.
Thanks in advance!