aspose file tools*
The moose likes Other Open Source Projects and the fly likes Axis on Cewolf graphs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Axis on Cewolf graphs" Watch "Axis on Cewolf graphs" New topic
Author

Axis on Cewolf graphs

MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Hi all,

I have recently chosen to use Cewolf for some overview graphs on a website design. Due to the nature of these graphs, they need to have no X or Y labling what so ever.

I have obviously been able to remove the labeling, header and legend, but I cant find a way of removing the values on the Y axis. Does anyone know a way of doing this?

Also, I have the problem that seems to be very fundimental but I'm struggling for a simple solution. How do you simply just change the colour of the bars or lines on graphs? Theres no Tag for it.

Thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
How do you simply just change the colour of the bars or lines on graphs? Theres no Tag for it.

That's the realm of chart postprocessors (which let you alter the appearance of a chart in ways for which there is no dedicated cewolf tag). Cewolf comes with a number postprocessors, among them de.laures.cewolf.cpp.SeriesPaintProcessor which can change the colors in various types of plots. The "Cewolf Set" demo of the example web app shows it in action in the StackedHorizontalBar and LineChart charts (the source for this is part of the cewolfset.jsp page).

I have recently chosen to use Cewolf for some overview graphs on a website design. Due to the nature of these graphs, they need to have no X or Y labling what so ever.

That, too, is a job of postprocessors, but there's no pre-made one that does this; shouldn't be hard, though. The general flow in the processChart method would be: 1) get the plot, 2) cast it to XYPlot, 3) get domain and range axes 4) cast those to NumberAxis, 5) call the setNumberFormatOverride(java.text.NumberFormat) method with a NumberFormat that always returns the empty string.
If you do end up writing a postprocessor, you might consider donating the code to the cewolf project; I can guarantee that it would find its way into the distribution :-)


Ping & DNS - my free Android networking tools app
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:
That's the realm of chart postprocessors (which let you alter the appearance of a chart in ways for which there is no dedicated cewolf tag). Cewolf comes with a number postprocessors, among them de.laures.cewolf.cpp.SeriesPaintProcessor which can change the colors in various types of plots. The "Cewolf Set" demo of the example web app shows it in action in the StackedHorizontalBar and LineChart charts (the source for this is part of the cewolfset.jsp page).


Fantastic, thanks for that. I did:
plot.getRenderer().setSeriesPaint(i, java.awt.Color.decode(colorStr));
and it worked a treat.

Ulf Dittmer wrote:
That, too, is a job of postprocessors, but there's no pre-made one that does this; shouldn't be hard, though. The general flow in the processChart method would be: 1) get the plot, 2) cast it to XYPlot, 3) get domain and range axes 4) cast those to NumberAxis, 5) call the setNumberFormatOverride(java.text.NumberFormat) method with a NumberFormat that always returns the empty string.
If you do end up writing a postprocessor, you might consider donating the code to the cewolf project; I can guarantee that it would find its way into the distribution :-)


Good idea. Ill get this postprocessor done, as I need to do it anyway, and get it over to you for the project.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Actually, I've thought about this some more, and decided that it would make sense to add parameters to the chart tag that allow you to set this. So I've just uploaded a new version of the library that implements it; the Testpage of the example web app shows those attributes in action.
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:Actually, I've thought about this some more, and decided that it would make sense to add parameters to the chart tag that allow you to set this. So I've just uploaded a new version of the library that implements it; the Testpage of the example web app shows those attributes in action.


Ah, and I had just about done it! haha. You mean the XY axis values being blank? What chart tag have you added?
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Well anyway, I did a ChartPostProcessor and it worked a treat:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
I added xticklabelsvisible, yticklabelsvisible, xtickmarksvisible and ytickmarksvisible attributes to the chart tag. The new version is downloadable from my web site now.
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Sorry to bother you again Ulf, but I wanted some guidence on how to write a ChartPostProcessor to remove the white space on the left and right of the graphs.

I need about 30 graphs next to each other. so that the border lines of the chart join together, Also, I need the space between the border of the chart and the first bar of the chart to go away. Below is what i mean



The top is what I have now. And below is what I need
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
You can get closer to that through JFreeChart.setPadding(new RectangleInsets(...)) and Plot.setInsets(new RectangleInsets(....)) with zero-valued parameters, but probably not quite down to adjacent charts.

Have you considered a single chart that has all the values, and then adding a custom domain axis that displays a single string for each day?
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:You can get closer to that through JFreeChart.setPadding(new RectangleInsets(...)) and Plot.setInsets(new RectangleInsets(....)) with zero-valued parameters, but probably not quite down to adjacent charts.

Have you considered a single chart that has all the values, and then adding a custom domain axis that displays a single string for each day?


The issue with that is each chart needs to be clickable to load larger graphs elsewhere. Even if i was to add hotspots along a single chart, it would affect usability to wait for the load of one massive chart (there are 30 of these at a time)
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:You can get closer to that through JFreeChart.setPadding(new RectangleInsets(...)) and Plot.setInsets(new RectangleInsets(....)) with zero-valued parameters, but probably not quite down to adjacent charts.

Have you considered a single chart that has all the values, and then adding a custom domain axis that displays a single string for each day?


I used Plot.setInsets(new RectangleInsets(0,0,0,0)) and it removed the space around the border of the graphs which is great! but JFreeChart.setPadding(new RectangleInsets(...)) is throwing the error

"non-static method setPadding(org.jfree.ui.RectangleInsets) cannot be referenced from a static context"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
That was just sample usage - you need to replace "JFreeChart" by a reference to a JFreeChart object - which the post-processor will give you.
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:That was just sample usage - you need to replace "JFreeChart" by a reference to a JFreeChart object - which the post-processor will give you.




I tried the above but to no avail

Am I doing something wrong or is there no way of removing that space at the start and end of the x axis. I want zero to be at zero on the chart. Any ideas?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis on Cewolf graphs