Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. // datas get from database
  2. "trendlines": [
  3. {
  4. "line": [
  5. {
  6. "startvalue": "175000",
  7. "color": "#8cbb2c",
  8. "thickness": "4",
  9. "alpha": "60",
  10. "displayvalue": "Target - $175K"
  11. }
  12. ]
  13. }
  14. ]
  15.  
  16. <%
  17.  
  18. //prepare trendlines
  19. ArrayList trendlines= new ArrayList();
  20. trendlines.add(buildTrendlines("startvalue","color","displayvalue",gson));
  21.  
  22. //close the connection.
  23. result.close();
  24.  
  25.  
  26. //create 'dataMap' map object to make a complete FusionCharts datasource.
  27. Map<String, String> dataMap = new LinkedHashMap<String, String>();
  28. /*
  29. gson.toJson() the data to retrieve the string containing the
  30. JSON representation of the data in the array.
  31. */
  32. dataMap.put("chart", gson.toJson(chartobj));
  33. dataMap.put("categories", gson.toJson(categories));
  34. dataMap.put("dataset", gson.toJson(dataset));
  35. dataMap.put("trendlines",gson.toJson(trendlines));
  36. FusionCharts mslineChart= new FusionCharts(
  37. "msline",// chartType
  38. "chart1",// chartId
  39. "600","400",// chartWidth, chartHeight
  40. "chart",// chartContainer
  41. "json",// dataFormat
  42. gson.toJson(dataMap) //dataSource
  43. );
  44.  
  45. %>
  46.  
  47.  
  48. <%!
  49.  
  50.  
  51. public Map buildTrendlines(String startvalue, String color, String displayvalue, Gson gson){
  52.  
  53. Map<String, String> trendlineinner = new HashMap<String, String>();
  54. ArrayList lines = new ArrayList();
  55. Map<String, String> linesdata = new HashMap<String, String>();
  56. linesdata.put("startvalue", "17022");
  57. linesdata.put("color","#6baa01");
  58. linesdata.put("displayvalue","Average");
  59. lines.add(linesdata);
  60. trendlineinner.put("line", gson.toJson(lines));
  61. return trendlineinner;
  62. }
  63. %>
  64.  
  65. <%= mslineChart.render() %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement