Last active
September 30, 2015 20:27
-
-
Save kevindoran/1857288 to your computer and use it in GitHub Desktop.
Google Charts BackBean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ManagedBean | |
public class ChartBackBean { | |
private GoogleChartModel chartModel = new DefaultGoogleChartModel("AnnotatedTimeLine"); | |
public ChartBackBean() { | |
chartModel.addColumn(new Column(Column.JavaScriptType.date, "Date")); | |
chartModel.addColumn(new Column(Column.JavaScriptType.number, "Price")); | |
for(int i=20; i>0; i--) { | |
DateTime date = DateTime.now().minusDays(i); | |
int price = (int) (Math.random() * 10); | |
int noOfRows = 2; | |
Row row = new Row(noOfRows); | |
row.addEntry(date); | |
row.addEntry(String.valueOf(price)); | |
chartModel.addRow(row); | |
chartModel.setOptions("'displayAnnotations':true, 'fill':30"); // Simply inserted as javascript. | |
} | |
} | |
public GoogleChartModel getChartModel() { | |
return chartModel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment