Closed JRobes closed 4 months ago
This looks really interesting, I will take a closer look
I'm glad to hear that. Do not hesitate to ask me if you need further details. The pictures created are really fine as you could check in mudiaurum.com => graphics (7 days pictures)
The link didn't work for me. Anyway I created a small demo program to try out the renderer (see below). It seems to work well for the line rendering but I noticed the FillType
options aren't fully working yet.
/* --------------------------
* XYBezierRendererDemo1.java
* --------------------------
* (C) Copyright 2022, by David Gilbert.
*
*/
package org.jfree.chart.demo;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYBezierRenderer;
import org.jfree.chart.swing.ApplicationFrame;
import org.jfree.chart.swing.ChartPanel;
import org.jfree.chart.swing.UIUtils;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
* A simple demonstration of the {@link XYBezierRenderer} class.
*/
public class XYBezierRendererDemo1 extends ApplicationFrame {
/**
* Constructs the demo application.
*
* @param title the frame title.
*/
public XYBezierRendererDemo1(String title) {
super(title);
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
setContentPane(chartPanel);
}
/**
* Creates a sample chart.
*
* @param dataset a dataset for the chart.
*
* @return A sample chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createXYLineChart("XYBezierRenderer Demo 1", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
XYBezierRenderer renderer = new XYBezierRenderer(10, 25, XYBezierRenderer.FillType.TO_ZERO);
renderer.setSeriesLinesVisible(0, true);
renderer.setSeriesShapesVisible(0, false);
renderer.setSeriesLinesVisible(1, true);
renderer.setSeriesShapesVisible(1, true);
renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
renderer.setDefaultEntityRadius(6);
plot.setRenderer(renderer);
return chart;
}
/**
* Creates a sample dataset.
*
* @return A dataset.
*/
private static XYDataset createDataset() {
XYSeries series1 = new XYSeries("Series 1");
series1.add(1.0, 3.3);
series1.add(2.0, 4.4);
series1.add(3.0, 1.7);
XYSeries series2 = new XYSeries("Series 2");
series2.add(1.0, 7.3);
series2.add(2.0, 0.0);
series2.add(3.0, 9.6);
series2.add(4.0, 5.6);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
return dataset;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset());
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
XYBezierRendererDemo1 demo = new XYBezierRendererDemo1(
"JFreeChart: XYBezierRendererDemo1.java");
demo.pack();
UIUtils.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
For reference, I get the same result:
$ host mudiaurum.com
Host mudiaurum.com not found: 3(NXDOMAIN)
$ git clone https://github.com/JRobes/jfreechart.git robes
$ pushd robes
$ git checkout jrobes/2.0.0
$ mvn clean compile
$ javac -cp target/classes XYBezierRendererDemo1.java
$ java -cp .:target/classes XYBezierRendererDemo1
Typing mundiaurum.com in any browser should work
Ah, that link works. Looks very nice.
I have modified XYBezierRenderer to fix the bug commented by David about the FillType options. Now the FillType options works fine, see plot below:
This is fantastic! When can it get merged?
I have uploaded the code but I don know how to merge the pull request. Any help is welcomed
@coreagile : Pending a merge by the owner, anyone can clone JRobes' JFreeChart fork, found here, and test it as shown here.
@JRobes : I haven't had a chance to look at your later commits. If I understand correctly, you would only need to consider merging pull requests submitted by others to your fork. This workflow guide may be relevant.
Still trying to merge pull request to master but I have not this option available from GitHub.
I just see the following:
@JRobes: I don't think you can merge into the main branch of this repository; your pull request appears to include changes that you pushed to your fork.
In the interim, others can clone your brach for study, as show here.
Alternatively, it looks like others can merge your fork into theirs; see How to apply unmerged upstream pull requests from other forks into my fork, but I have't tried it.
Merged, thanks.
Plot charts using Bezier curves. With Bezier curves you can control how the curve fits (bends) to the points on the graph. This is done with the parameter 'tension' This solution arises from the problem defined in stackoverflow: StackOverflow question
XYBezierRenderer extends XYLineAndShapeRenderer. XYBezierRendererTest has been also added to branch.