Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#89 same color

closed
nobody
None
5
2004-09-30
2004-08-10
bon
No

When i plot a overlaid graph (xyarea and vertical bar), it
paints both the things in same color. Is there a way to
specify color for individual dataset.

Discussion

  • siesta
    siesta
    2004-08-10

    Logged In: YES
    user_id=1060048

    You have to use a ChartPostProcessor, like this:
    ChartPostProcessor dataColor = new ChartPostProcessor() {
    public void processChart(Object chart, Map params) {

    XYPlot plot = ((JFreeChart) chart).getXYPlot();
    String colorStr1 = (String) params.get("color1");
    plot.getRenderer(0).setPaint(
    java.awt.Color.decode(colorStr1));
    String colorStr2 = (String) params.get("color2");
    plot.getRenderer(1).setPaint(
    java.awt.Color.decode(colorStr2));
    }
    };

    pageContext.setAttribute("dataColor", dataColor);

    And add the following tag in the cewolf:overlaidchart tag scope.
    <cewolf:chartpostprocessor id="dataColor">
    <cewolf:param name="color1" value='<%= "#00FF00" %>'/>
    <cewolf:param name="color2" value='<%= "#00FFFF" %>'/>
    </cewolf:chartpostprocessor>

    This is currently the only way to change the colors of the plot.

     
  • bon
    bon
    2004-08-11

    Logged In: YES
    user_id=1101112

    hi,
    the code only works with jfreechart-0.9.20.jar and not with
    previous stable .war version. Again now it takes only two
    dataset for type overlaidxy in overlaidchart chart whereas I
    need to use five dataset. When I use more than two dataset
    it gives me assertion failed exception saying you can have
    only two datasets for type overlaidxy. Is there a way to get
    around this.

     
  • bon
    bon
    2004-08-11

    Logged In: YES
    user_id=1101112

    It's o.k as I have modified CewolfChartFactory at my end to
    suit my needs. Thanks for the ChartPostProcessor code
    snippet. It really helped.

     
  • siesta
    siesta
    2004-08-11

    Logged In: YES
    user_id=1060048

    Are you sure that you cannot use a single DataSet with
    multiple series ? This is how the JFreeChart guys intended
    the thing to be used. For example, if you want to plot
    several xyareas, you use a single DataSet with several
    series. To paint them with different colors, you then use
    the Render setSeriesPaint(seriesIndex) method...

     
  • bon
    bon
    2004-08-11

    Logged In: YES
    user_id=1101112

    I mean more than two dataset with overlaidxy type of
    overlaid chart gives exception of assertion failure. I have
    checked the CewolfChartFactory.java it has statement of
    assertion in case of Overlaidxy type, limiting number of
    dataset to two. At my end I have removed that added code
    for extra datasets which was my need. Now it is giving me
    good results.

     
  • bon
    bon
    2004-09-30

    • status: open --> closed