I'm using JFreeChart with Java to produce BoxAndWhisker boxplots. I want to embed the legend into the boxplot area.
I realize a similar question has been asked for embedding the legend into the plot area in general. However, the answer does not work for boxplots because they do not work with XYTitleAnnotations but with CategoryAnnotations.
I don't know which CategoryAnnotation to use and how. None of the three implementing classes seem to have the functionality I want.
Is this even possible for boxplots? If so, how?
I don't think that this is possible as the two implementations of CategoryAnnotation are used to annotate a Category and draw a line between two categories.
You can however move the position of the legend:
LegendTitle legend= localJFreeChart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);
Related
I see that I can use setLabelLinkPaint() to universally apply a color to all label links, but I'm looking to set each individual label link to a different color. Is there a way to do this?
It looks like for now the most straightforward way to approach this problem is to subclass the PiePlot class and override the drawRightLabel and drawLeftLabel methods. In my case, I needed to have the label link color match the corresponding pie chart section, so in my overridden methods I set g2.setPaint(getSectionPaint(record.getKey())).
My advice to anyone trying to do something similar is to watch out for casting errors if casting from a JFreeChart chart object. You will likely have to additionally subclass ChartFactory and modify it so that it uses your subclassed PiePlot and not the original one.
Basically I am attempting to use JFreeChart right now to graph some values. The only problem is that the values are incredibly minuscule, e.g 7.069781E-13. I believe these values are too small for JFreeChart to display. How can I display these small values visually in Java in a line chart format?
It looks like this currently:
And I want to make it look similar to this:
I found a work around.
I simply multiplied all the values by a factor of 100 so the graph now looks similar to the one in the example. I will include a disclaimer in the legend saying the chart has been multiplied by a factor to clearly see the line chart.
Also consider these alternative:
Invoke setRange(), seen here, to expand the y axis in the area of interest.
Add suitable controls, seen here, to control y zoom.
Advise users how to use the mouse for zoom control, as shown here.
I am working with AndroidPlot since about one year to display different Diagrams in my app.
Now I am working with BarCharts, the charts are finished but how can I make corners rounded?
I found some results for lines:
How to make line with rounded (smooth) corners with AndroidPlot
I tried already:
BarFormatter formatter1,formatter2, formatter3;
formatter1.getBorderPaint().setStrokeJoin(Paint.Join.ROUND);
formatter1.getFillPaint().setStrokeJoin(Paint.Join.ROUND);
doesn't seems to have any impact.
then I tried:
XYPlot plot; //Initialized with UI-Diagrammm above
...
plot.setBorderStyle(XYPlot.BorderStyle.ROUNDED,5f,5f);
Does anyone had the problem already and got an answer how to do this.
Thanks for Help,
Franzi
Bars are rendered by Androidplot's BarRenderer class which uses the Canvas.drawRect(...) method to draw individual bars. In order to get rounded edges it would either need to call Canvas.drawRoundRect or possibly even better, draw each bar as a path using Path.lineTo(...) and Path.arcTo(...) methods so that only the top of the bars are rounded. This functionality unfortunately does not exist yet but you could open a feature request if you want.
Or you could implement it yourself by creating a custom renderer that extends BarRenderer and overriding drawBar(...). Documentation available here
I need to create a chart like this picture bellow in Android.
and I am already aware of MPAndroidChart and AndroidHelloCharts libraries. but none of them are capable of drawing such thing.
do you know any way to create a chart like this?
please explain and at least suggest me some tutorials or articles that are related to what I am about to do.
thank you
Its actually pretty simple to create your own bar chart.
First you need to use drawRect to draw a rectangle.
And then drawText to draw text below the rectangle.
You may have noticed that both methods take a paint object as the parameter , you can think of the paint object like a brush. So you set the color to the brush and draw different elements.
I have written about it
here
I'm not a UI person, so I'm hoping to get some suggestions for how to draw this in Swing. I want to end up with something like the figure below.
It's showing availability over time (time axis not shown in image, but it'd be at the bottom or top). The vertical bar represents the current time. I looked at libraries like JFreeChart, but I don't see anything that can easily be turned into this, or did I miss something? It's easy enough to draw something like this manually by overriding paint() in a JPanel or something, but I don't want to have to manually handle the collapsing/expanding logic over elements on the left. My next thought was maybe a JTree with custom cells where I could draw the availability bars. This way I won't have to deal with the collapse/expand logic.
Any suggestions? Is there a charting/graphing library I could use? Should I do it from scratch? Extend some existing Swing component?
Thanks
JFreeChart can do everything except the outline, for which I'd use outline and a suitable table cell renderer.
The term you are looking for is a "Gantt chart". JFreeChart does have a chart for that, but it's not interactive. There are some free Java library (e-gantt is one), but not in combination with a tree table (as far as I know).
So if that is required, you could build something of a tree table as suggested in the other answers or go with a commercial library (JGantt, Jide Gantt (disclaimer I worked on that one ;))