public static PieChartJson productPieChart(String diagName, Map<String, DiagCountDTO> values) { PieChart chart = new PieChart(); chart.setCaption(diagName); chart.setFormatnumberscale("0"); chart.setUnescapeLinks("0"); List<Data> data = new ArrayList<Data>(); Iterator<String> it = values.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String dName = key.substring(0, key.lastIndexOf("-")); String dValue = key.substring(key.lastIndexOf("-") + 1); String value = Integer.toString(values.get(key).getCount()); key = key.endsWith("1") ? key.substring(0, key.lastIndexOf("1") - 1) : key; data.add( new PieData( key, value, "javascript:showPatientTable('" + DiagMap.getKey(dName) + "','" + DiagMap.getKey(dValue) + "')")); } PieChartJson chartJson = new PieChartJson(); chartJson.setData(data); chartJson.setChart(chart); return chartJson; }
public static ColumnChartJson produceColumnChart( List<String> diagNames, Map<String, DiagCountDTO> values) { ColumnChart chart = new ColumnChart(); chart.setCaption("疾病分布图"); chart.setShowvalues("0"); chart.setPalette("2"); chart.setXaxisname("疾病"); chart.setYaxisname("病例"); chart.setDecimals("0"); chart.setFormatnumberscale("0"); chart.setUnescapeLinks("0"); List<Data> data = new ArrayList<Data>(); Iterator<String> it = values.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String value = Integer.toString(values.get(key).getCount()); data.add(new ColumnData(key, value, "javascript:showDetail('" + DiagMap.getKey(key) + "')")); } List<Definition> definitions = new ArrayList<Definition>(); ColumnDefinition definition = new ColumnDefinition("myAnim", "animation"); definitions.add(definition); List<Application> applications = new ArrayList<Application>(); Application application = new Application("VLINES", "myAnim"); applications.add(application); Styles style = new Styles(); style.setApplication(applications); style.setDefinition(definitions); ColumnChartJson chartJson = new ColumnChartJson(); chartJson.setChart(chart); chartJson.setStyles(style); chartJson.setData(data); return chartJson; }
/** * 画Stack2D图 * * @param diagNames * @param dividedCategoryList * @param patientDiags * @param patientId * @return */ public static StackChartJson produceStack2DChart( List<String> diagNames, Map<String, List<DiagCountDTO>> dividedCategoryList, List<String> patientDiags, String patientId) { StackChart chart = new StackChart(); chart.setBgcolor("E9E9E9"); chart.setOutcnvbasefontcolor("666666"); chart.setCaption("Monthly Sales Summary Comparison"); chart.setXaxisname("病例数量"); chart.setYaxisname("疾病"); chart.setFormatnumberscale("0"); chart.setUnescapeLinks("0"); chart.setShowvalues("0"); chart.setNumberprefix(""); chart.setNumvdivlines("10"); chart.setShowalternatevgridcolor("1"); chart.setAlternatevgridcolor("e1f5ff"); chart.setDivlinecolor("e1f5ff"); chart.setVdivlinecolor("e1f5ff"); chart.setBasefontcolor("666666"); chart.setTooltipbgcolor("F3F3F3"); chart.setTooltipbordercolor("666666"); chart.setCanvasbordercolor("666666"); chart.setCanvasborderthickness("1"); chart.setShowplotborder("1"); chart.setPlotfillalpha("80"); List<Category> categoryList = new ArrayList<Category>(); List<Data> dataList = null; List<DiagCountDTO> count = null; DataSet dataSet = null; List<DataSet> dataSetList = new ArrayList<DataSet>(); Random colorSeed = new Random(); boolean flag = false; Category category = null; List<Integer> hasDiag = null; for (String key : dividedCategoryList.keySet()) { count = dividedCategoryList.get(key); dataList = new ArrayList<Data>(); for (int x = 0; x < count.size(); x++) { if (!flag) { hasDiag = Arrays.asList(new Integer[count.size()]); if (patientDiags != null && patientDiags.size() > 0 && patientDiags.contains(count.get(x).getSubject())) { category = new Category("★" + patientId + "★" + count.get(x).getSubject()); hasDiag.set(x, 1); } else { category = new Category(count.get(x).getSubject()); hasDiag.set(x, 0); } categoryList.add(category); } System.out.println( count.get(x).getSubject() + "->" + DiagMap.getKey(count.get(x).getSubject())); dataList.add( new StackData( Integer.toString(count.get(x).getCount()), "javascript:showAgeDistibution('" + DiagMap.getKey(count.get(x).getSubject()) + "','" + hasDiag.get(x) + "')")); } int colorNum = colorSeed.nextInt(colors.length); dataSet = new DataSet(key, colors[colorNum], colors[colorNum], colors[colorNum], dataList); dataSetList.add(dataSet); flag = true; } Categories categories = new Categories(categoryList); List<Categories> categoriesList = new ArrayList<Categories>(); categoriesList.add(categories); Application application = new Application("TRENDLINES", "TrendAnim"); List<Application> applicationList = new ArrayList<Application>(); applicationList.add(application); StackDefinition definition = new StackDefinition(); List<Definition> definitionList = new ArrayList<Definition>(); definitionList.add(definition); Styles styles = new Styles(definitionList, applicationList); StackChartJson chartJson = new StackChartJson(chart, categoriesList, dataSetList, styles); return chartJson; }