public ChartModel getChartModel(int segments) {
   ChartModel cm =
       new ChartModel(
           "Sales by Month 2008", "font-size: 14px; font-family: Verdana; color:#ffff00;");
   cm.setBackgroundColour("#000077");
   XAxis xa = new XAxis();
   xa.setLabels(TestData.getShortMonths(segments));
   xa.getLabels().setColour("#ffff00");
   xa.setGridColour("-1");
   xa.setColour("#aa5500");
   xa.setZDepth3D(5);
   cm.setXAxis(xa);
   YAxis ya = new YAxis();
   ya.setSteps(16);
   ya.setMax(160);
   ya.setGridColour("#000099");
   ya.setColour("#ffff00");
   cm.setYAxis(ya);
   cm.setYAxisLabelStyle(10, "#ffff00");
   BarChart bchart = new BarChart(BarStyle.THREED);
   bchart.setColour("#CC6600");
   bchart.setTooltip("$#val#");
   for (int t = 0; t < segments; t++) {
     bchart.addValues(Random.nextInt(50) + 50);
   }
   cm.addChartConfig(bchart);
   return cm;
 }
 public ChartModel getChartModel(int segments) {
   ChartModel cm =
       new ChartModel("Sales by Month 2007", "font-size: 14px; font-family: Verdana;");
   cm.setBackgroundColour("-1");
   XAxis xa = new XAxis();
   for (String m : TestData.getMonths()) {
     Label l = new Label(m, 45);
     l.setSize(10);
     l.setColour("#000000");
     xa.addLabels(l);
   }
   xa.setGridColour("-1");
   cm.setXAxis(xa);
   YAxis ya = new YAxis();
   ya.setSteps(16);
   ya.setMax(160);
   ya.setGridColour("#8888FF");
   cm.setYAxis(ya);
   BarChart bchart = new BarChart(BarStyle.GLASS);
   bchart.setColour("#FF00CC");
   bchart.setTooltip("$#val#");
   for (int t = 0; t < 12; t++) {
     if (t == segments - 1) {
       bchart.addBars(new BarChart.Bar(Random.nextInt(50) + 50, "#8888FF"));
     } else {
       bchart.addValues(Random.nextInt(50) + 50);
     }
   }
   cm.addChartConfig(bchart);
   return cm;
 }
Exemple #3
0
  public Widget aa() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", new Object[] {});
      ContentPanel panel = new ContentPanel();
      panel.setAutoHeight(true);
      ToolBar tb = new ToolBar();
      Button addsuit = new Button("从商品库里添加套装商品");
      addsuit.setIconStyle("b2csuit");
      panel.setHeading("商品库,如果加入套装你必须先选择一行(必选)");
      tb.add(addsuit);
      panel.setTopComponent(tb);
      // addsuit.addListener(Events.Select, this);
      panel.setAutoWidth(true);
      CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
      List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
      columns.add(cbs.getColumn());
      ColumnConfig gcode = new ColumnConfig("gcode", "商品大类编码", 100);
      TextField<String> gcodetext = new TextField<String>();
      gcode.setEditor(new CellEditor(gcodetext));
      columns.add(gcode);
      ColumnConfig gname = new ColumnConfig("discountprice", "商品大类名称", 100);
      TextField<String> gnametext = new TextField<String>();
      gname.setEditor(new CellEditor(gnametext));
      columns.add(gname);

      ColumnConfig treecode = new ColumnConfig("price", "商品分类树编码", 100);

      TextField<String> treecodetext = new TextField<String>();
      treecode.setEditor(new CellEditor(treecodetext));
      columns.add(treecode);

      ColumnConfig b2cgcodecolumn = new ColumnConfig("b2cgcode", "商品编码", 100);
      TextField<String> b2cgcodetext = new TextField<String>();
      b2cgcodecolumn.setEditor(new CellEditor(b2cgcodetext));
      columns.add(b2cgcodecolumn);
      ColumnConfig b2cgname = new ColumnConfig("b2cgname", "商品名称", 100);
      TextField<String> b2cgnametext = new TextField<String>();
      b2cgname.setEditor(new CellEditor(b2cgnametext));
      columns.add(b2cgname);

      ModelType type = new ModelType();
      type.setRoot("records");
      type.setRecordName("record");

      type.addField("gcode");
      type.addField("gname");
      type.addField("b2cgcode");
      type.addField("price");
      type.addField("discountprice");
      type.addField("b2cgname");
      type.addField("mainimagepath");
      type.addField("treecode");
      type.addField("detailimage");

      StoreInfo info = new StoreInfo();

      info.setTablename("b2cgcode");
      info.setKeyname(new String[] {"b2cgcode"});
      info.setSql("select * from b2cgcode");
      BaseStore<JDBCModelData> store = new BaseStore<JDBCModelData>(type, info);

      ChartModel model =
          new ChartModel(
              "Team Sales by Month", "font-size: 14px; font-family: Verdana; text-align: center;");
      model.setBackgroundColour("#fefefe");
      model.setLegend(new Legend(Position.TOP, true));
      model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

      BarChart bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#00aa00");
      BarDataProvider barProvider = new BarDataProvider("price", "b2cgname");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      //  bar.addChartListener(listener);
      model.addChartConfig(bar);

      bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#ff6600");
      barProvider = new BarDataProvider("discountprice");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      // bar.addChartListener(listener);
      model.addChartConfig(bar);

      LineChart line = new LineChart();
      line.setAnimateOnShow(true);
      line.setText("Average");
      line.setColour("#FF0000");
      LineDataProvider lineProvider = new LineDataProvider("discountprice");
      lineProvider.bind(store);
      line.setDataProvider(lineProvider);
      model.addChartConfig(line);

      /*	    PieChart pie = new PieChart();
      PieDataProvider piedataprovider = new PieDataProvider("discountprice");
      piedataprovider.bind(store);
      pie.setDataProvider(piedataprovider);
      model.addChartConfig(pie);*/

      String url = "chart/open-flash-chart.swf";
      final Chart chart = new Chart(url);
      chart.setChartModel(model);
      chart.setHeight("300px");
      ContentPanel cp = new ContentPanel();
      cp.setHeading("Chart");
      cp.add(chart);
      ColumnModel cm = new ColumnModel(columns);
      BaseGrid grid = new BaseGrid(store, cm);
      grid.setHeight("300px");
      cp.add(grid);
      armStatus = ArmWrapper.GOOD;
      return cp;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", armStatus);
    }
  }