小弟我要实现在一个jsp页面上画出两个曲线图,每个图都是以时间为x轴,多纵轴.并且要在鼠标指向各个数据点的时候显示其坐标.
写了一个方法
  public void drawMoreZheXian(ArrayList TimeSeriesLIst, ArrayList showList,
                              ArrayList colorList, String[] groupArr,
                              String[] titleArr, String zmStr,
                              JspWriter out, int width, int height,
                              String[] colorArr, int bgcolor) {
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(zmStr));
    if (groupArr != null && groupArr.length >= 1) {      for (int i = 0; i < groupArr.length; i++) {
   //String[] numArr = groupArr[i].split(",");
// 循环把各组值放到 collection中
TimeSeriesCollection  dataset = new TimeSeriesCollection();
        dataset.addSeries( (TimeSeries) TimeSeriesLIst.get(i));// 生产工具提示信息的ArrayList
        ArrayList[] tooltips = new ArrayList[showList.size()];
        for (int k = 0; k < showList.size(); k++) {
          tooltips[k] = getCurveSeries( (String[]) showList.get(k));
        }        ////////////////////////井数
        NumberAxis rangeAxis1 = new NumberAxis(titleArr[i]);        CustomXYToolTipGenerator ttg1 = new CustomXYToolTipGenerator();
        //加入各条曲线的工具提示条
          ttg1.addToolTipSeries(tooltips[i]);        //生成曲线的透视层
        StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(
            StandardXYItemRenderer.SHAPES_AND_LINES,
            ttg1, null);
        rangeAxis1.setAutoRangeIncludesZero(false);
        rangeAxis1.setAutoRangeStickyZero(false);
        //设置小数位数
        rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        XYPlot subplot1 = new XYPlot(dataset, null, rangeAxis1, renderer1);
        subplot1.setBackgroundPaint(new GradientPaint(0, 100,
            new Color(0xccccff), 130, 240, new Color(0xeffcd0), true));
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
        plot.add(subplot1, 1);
        plot.setBackgroundPaint(new Color(bgcolor));
        if (colorList != null && colorList.size() > 0) {
          renderer1.setSeriesPaint(0, (Color) colorList.get(i));
        }        rangeAxis1.setAutoRange(true);      JFreeChart chart = new JFreeChart("",
                                          JFreeChart.DEFAULT_TITLE_FONT, plot, false);
        chart.setBackgroundPaint(new Color(bgcolor));        plot.setDomainCrosshairVisible(false);
        plot.setRangeCrosshairVisible(false);        DateAxis axis = (DateAxis) plot.getDomainAxis();
        axis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1,
                                          new SimpleDateFormat("MM-dd")));
        XYItemRenderer xyitemrenderer = plot.getRenderer();
        if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
          XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)
              xyitemrenderer;
          xylineandshaperenderer.setBaseShapesVisible(true);
          xylineandshaperenderer.setBaseShapesFilled(true);
        }
        FileOutputStream fos_jpg = null;
        String[] imgUrl = null;
        ChartRenderingInfo info = null;
        try {
          imgUrl = ImgScgz.getImgUrl();
          fos_jpg = new FileOutputStream(imgUrl[0]);
          info = new ChartRenderingInfo();
          ChartUtilities.writeChartAsJPEG(fos_jpg, 100, chart, width, height, info); //图形的大小        }
        catch (Exception e) {
         e.printStackTrace();
         }
         finally {
           try {
             fos_jpg.close();
           }
           catch (Exception e) {}
         }
         try {
           out.print("<img src=" + imgUrl[1] + " border=0 usemap=#mapName>");
           out.print(ChartUtilities.getImageMap("mapName", info));
         }
         catch (Exception e) {}   }
}
然后在jsp中调用两次这个方法,只是传递的参数不一致,但是只能显示前一个图的数据点,后一个似乎还是用的前一个的tooltips
请教高手是怎么回事?

解决方案 »

  1.   

    方法getCurveSeries内容
      public ArrayList getCurveSeries(String[] str) {
        //所对应的工具提示
        ArrayList toolTips = new ArrayList();
        for (int i = 0; i < str.length; i++) {
          toolTips.add(str[i]);
        }
        return toolTips;
      }
      

  2.   

    不好意思啊,我不能回答你的问题,是来请教问题的!“要在鼠标指向各个数据点的时候显示其坐标.”这个怎么实现的呀!是那个toolTips吗?
      

  3.   

    http://www.7points.net/blog/user1/major/archives/2006/440.html
    这个地方说得比较详细,希望能有你要找的,我也在弄这个!