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
Related
I want to get the bounds (i.e. Bounds) of the XYChart plot area, which I define as the area contained within the axes of the plot (i.e. the axes form two legs of a rectangle). The ultimate purpose is to constrain a rubber band rectangle on the plot area. I started with this example and added in the constraint.
Based on the comments from James_D and kleopatra, I created a MVCE. I think the MVCE works remarkably well and compiles without warnings. More importantly, kleopatra's comment led to finding the bug when using the chart-plot-background method. The MVCE implements both methods. The chart-plot-background works for both ValueAxis and CategoryAxis. The axis method currently only works for ValueAxis.
Is using the bounds of .chart-plot-background a reliable method for determining the plot area or is using the value bounds of each axis more reliable? The axis approach definitely has more steps and more code.
Other options
I looked at the JavaFX source and plotArea looked promising but it isn't accessible.
The plotContent member is accessible via lookup(".plot-content") but groups all the data points, some of which may be outside the range set in the axes. Thus, the bounds of plotContent can be larger than the plot area bounds.
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 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);
I implemented my own JFreeChart XYToolTipGenerator and, as the chart it is used on is almost full screen, sometimes the tooltip position (on screen) hides the point it is related to (e.g. in the bottom right corner, since it seems that tooltip is configured to be positioned South-East of the mouse / data point). This is a problem because the user needs to be able to click on the chart's data points (as it generates a specific action).
Is there a way to either define dynamically the position of the tooltip (e.g. for data points bottom right I would ask the tooltip to be shown North-West) or, alternatively, to define a systematic position (e.g. North-West instead of South-East as it is by default)?
This problem has given me headaches for the last few days - any help or hint is more than welcome.
Many thanks!
Thomas
Here's the answer I posted on the JFreeChart forum:
JFreeChart is using the standard Swing tool tip mechanism. In the ChartPanel class, the getToolTipText(mouseEvent) method is overridden to return the appropriate text for the tooltip, and that's it.
Swing also gives you the option to override the getToolTipLocation(mouseEvent) method, and that's probably what you need here.
I have drawn a XY chart using jfree. Now i want to add zoom functionality to it. This must be done using a slider at the bottom of the chart. How can i add zoom functionality, the likes of which is present in Windows Photo Viewer?
Also, i would like to show the current Y-value of the graph as a tooltip when the user hovers his mouse over the plotted line. I am not getting much ideas.
Please help.
Thanks in advance
XYPlot et al. implement the Zoomable interface, which allows ChartPanel to control zooming. I'd think you could use these methods in your slider's ChangeListener.
I would like to show the current Y-value of the graph as a tooltip…
You can enable tool tips, as shown in this example.