Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SteKoe committed Oct 16, 2015
1 parent ee7b394 commit 0bcf961
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
Java API for the awesome Charts Package amChartsv3 (http://www.amcharts.com).
The Version of this API corresponds to the Version of amCharts.

## Example
## How to serialise to JSON
To serialize the AmCharts to JSON, please use GSON from google/gson. The classes are ready to be consumed by GSON as done in the following code snippet.

```java
import de.stekoe.amcharts.addition.Color;
import de.stekoe.amcharts.addition.ColorSerialiser;

Gson gson = new Gson();
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Color.class, new ColorSerialiser());
gson = gsonBuilder.create();

AmChart chart = new AmRadarChart();
String json = gson.toJson(chart);
```

## Example JSON Output

The following code is based on an example from the website of amCharts:
<pre>
Expand Down Expand Up @@ -56,4 +72,4 @@ chart.setGraphs(getGraphs());
chart.setChartCursor(getChartCursor());
chart.setCategoryField("choice");
chart.setCategoryAxis(getCategoryAxis());
</pre>
</pre>

0 comments on commit 0bcf961

Please sign in to comment.