package com.hantele.psmis.markethot.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.google.gson.Gson;
import com.hantele.floana.demo.action.util.ActionUtil;
import com.hantele.floana.demo.action.util.Chart;
import com.hantele.floana.demo.action.util.DataSet;
import com.hantele.floana.demo.model.TmpTaskmanager;
import com.hantele.floana.demo.ser.TmpTaskManagerSer;
public class TmpBaseChartController extends MultiActionController{
private TmpTaskManagerSer tmpTaskManagerSer;
public TmpTaskManagerSer getTmpTaskManagerSer() {
return tmpTaskManagerSer;
}
public void setTmpTaskManagerSer(TmpTaskManagerSer tmpTaskManagerSer) {
this.tmpTaskManagerSer = tmpTaskManagerSer;
}
public ModelAndView index(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//response.setContentType("text/html;charset=UTF-8");
//line////pie///column
Chart chart = new Chart();
chart.setCaption("图表信息");
chart.setxAxisName("月份");
chart.setyAxisName("交易额");
chart.setShowValues("0");
chart.setNumberPrefix("$");
String[] cs = { "1月", "2月", "3月", "4月", "5月" };
DataSet[] ds = new DataSet[1];// 三个进行对比
ds[0] = new DataSet(); // 对比五个月的数据
ds[0].setSeriesName("2000年");
ds[0].setSetNames(cs);
String[] sv = { "" + 190, "" + 334, "" + 799, "" + 888, "" + 900 }; //////////////////图表中的值
String[] sc = { "F6BD0F", "AFD8F8", "FF8E46", "008ED6", "A186BE" }; /////各个图表段的颜色
ds[0].setSetColors(sc);
ds[0].setSetValues(sv);
chart.setDataset(ds);
chart.setyAxisMinValue("0"); // 最小值
chart.setyAxisMaxValue("1200");// 最大值
String xmlDate = chart.createRoutineChartXmlData();
///////MSLine////mscolumn/////////////////////////////MS系列
Chart chart2 = new Chart();
chart2.setCaption("图表信息");
chart2.setxAxisName("月份");
chart2.setyAxisName("交易额");
chart2.setShowValues("0");
chart2.setNumberPrefix("$");
String[] cs2 = { "1月", "2月", "3月", "4月", "5月" };
chart2.setCategories(cs2);
DataSet[] ds2 = new DataSet[4];// 三个进行对比
for (int i = 0; i < ds2.length; i++) {
ds2[i] = new DataSet(); // 对比五个月的数据
ds2[i].setSeriesName("200" + i + "年");
int a1 = new Random().nextInt(1000);
if (a1 <= 0) {
a1 = 100;
}
int a2 = new Random().nextInt(1000);
if (a2 <= 0) {
a2 = 100;
}
int a3 = new Random().nextInt(1000);
if (a3 <= 0) {
a3 = 100;
}
int a4 = new Random().nextInt(1000);
if (a4 <= 0) {
a4 = 100;
}
int a5 = new Random().nextInt(1000);
if (a5 <= 0) {
a5 = 100;
}
String[] sv2 = { "" + a1, "" + a2, "" + a3, "" + a4, "" + a5 };
ds2[i].setSetValues(sv2);
}
chart2.setDataset(ds2);
chart2.setLineStartValue("26000");
chart2.setLineColor("91C728");
chart2.setLineDisplayValue("Target");
chart2.setyAxisMinValue("0"); // 最小值
chart2.setyAxisMaxValue("1200");// 最大值
String xmlDate2 = chart2.createChartXmlData();
ModelAndView m=new ModelAndView("test/basechart");
m.addObject("msg", xmlDate);
m.addObject("msg2", xmlDate2);
return m;
}
public ModelAndView portal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView m=new ModelAndView("test/portal");
return m;
}
/*
public ModelAndView showSimpleGraphic(HttpServletRequest request,
HttpServletResponse response) throws Exception {
response.setContentType("text/html;charset=UTF-8");
//response.setCharacterEncoding("UTF-8");
Chart chart = new Chart();
chart.setCaption("图表信息");
chart.setxAxisName("月份");
chart.setyAxisName("交易额");
chart.setShowValues("0");
chart.setNumberPrefix("$");
String[] cs = { "1月", "2月", "3月", "4月", "5月" };
DataSet[] ds = new DataSet[1];// 三个进行对比
ds[0] = new DataSet(); // 对比五个月的数据
ds[0].setSeriesName("2000年");
ds[0].setSetNames(cs);
String[] sv = { "" + 190, "" + 334, "" + 799, "" + 888, "" + 900 };
String[] sc = { "F6BD0F", "AFD8F8", "FF8E46", "008ED6", "A186BE" };
ds[0].setSetColors(sc);
ds[0].setSetValues(sv);
chart.setDataset(ds);
chart.setyAxisMinValue("0"); // 最小值
chart.setyAxisMaxValue("1200");// 最大值
String xmlDate = chart.createRoutineChartXmlData();
PrintWriter pw;
try {
pw = response.getWriter();
pw.print(xmlDate);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public ModelAndView showMultiGraphic(HttpServletRequest request,
HttpServletResponse response) throws Exception {
response.setContentType("text/html;charset=UTF-8");
Chart chart = new Chart();
chart.setCaption("图表信息");
chart.setxAxisName("月份");
chart.setyAxisName("交易额");
chart.setShowValues("0");
chart.setNumberPrefix("$");
String[] cs = { "1月", "2月", "3月", "4月", "5月" };
chart.setCategories(cs);
DataSet[] ds = new DataSet[3];// 三个进行对比
for (int i = 0; i < ds.length; i++) {
ds[i] = new DataSet(); // 对比五个月的数据
ds[i].setSeriesName("200" + i + "年");
int a1 = new Random().nextInt(1000);
if (a1 <= 0) {
a1 = 100;
}
int a2 = new Random().nextInt(1000);
if (a2 <= 0) {
a2 = 100;
}
int a3 = new Random().nextInt(1000);
if (a3 <= 0) {
a3 = 100;
}
int a4 = new Random().nextInt(1000);
if (a4 <= 0) {
a4 = 100;
}
int a5 = new Random().nextInt(1000);
if (a5 <= 0) {
a5 = 100;
}
String[] sv = { "" + a1, "" + a2, "" + a3, "" + a4, "" + a5 };
ds[i].setSetValues(sv);
}
chart.setDataset(ds);
chart.setLineStartValue("26000");
chart.setLineColor("91C728");
chart.setLineDisplayValue("Target");
chart.setyAxisMinValue("0"); // 最小值
chart.setyAxisMaxValue("1200");// 最大值
String xmlDate = chart.createChartXmlData();
PrintWriter pw;
try {
pw = response.getWriter();
pw.print(xmlDate);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}*/
/*public void test() {// 随时测试
response.setCharacterEncoding("UTF-8");
Chart chart = new Chart();
chart.setCaption("图表信息");
chart.setxAxisName("月份");
chart.setyAxisName("交易额");
chart.setShowValues("0");
chart.setNumberPrefix("$");
String[] cs = { "1月", "2月", "3月", "4月", "5月" };
chart.setCategories(cs);
DataSet[] ds = new DataSet[3];// 三个进行对比
for (int i = 0; i < ds.length; i++) {
ds[i] = new DataSet(); // 对比五个月的数据
ds[i].setSeriesName("200" + i