• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Axis on Cewolf graphs

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 :-)
 
MichaelJ McCabe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well anyway, I did a ChartPostProcessor and it worked a treat:

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic