Comments (7)
I am wary of silently skipping values. Might this feature see wider acceptance as a mutable property?
from jfreechart.
I've looked into the code of XYPlots and pretty much implemented the renderer for PolarPlots the same way (see PR). A mutable property would of course be possible so we can control the behavior and also be backwards compatible.
But the current handling of NaN values is obviously wrong. They don't belong to the top left corner of a plot.
So there is still the question where NaN values should be displayed. In the center (0|0) would make more sense than on top-left.
Let me know what you think.
I could update the PR accordingly.
Have a nice day ☀️
from jfreechart.
Thank you for responding. In either XYPlot
or PolarPlot
, I see no a priori way to distinguish between erroneous data values and intentionally NaN
values. In XYPlot
, a gap remains as a visible indicator of possible error; in PolarPlot
, skipped values may obscure possible error such as erroneous conversion. Although I have never encountered the need for the proposed feature, I would argue against making it the default.
from jfreechart.
I am sorry, i didn't meant skipping them. There is also a gap like in the XYPlots
.
Before:
Same data points with the updated PolarPlot Renderer:
The NaN value creates a gap in the line. Is this what you were talking about?
from jfreechart.
Yes, I believe so. Your images make it clear: in the first, I can see the NaN
and work out how to handle it; in the second, I don't see anything unusual. In effect, information has been hidden.
I can't argue that the proposed feature would never be useful. As others may rely on the existing behavior, I would caution against making it a new default.
For reference, a similar issue arose in StandardXYItemRenderer
, discussed here +ca. v.1.0.2.
Of course, I defer to the owner.
from jfreechart.
Thank you for pointing out this discussion.
I have checked out the StandardXYItemRenderer and as far as I see NaN values are handled the same as i suggested. They are not shown in the chart and there is no connecting line.
XYPlot with StandardXYItemRenderer :
Demo Code:
public static void main(String args[]) throws Exception {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(2, 3.4);
s1.add(3, 5.4);
s1.add(4, Double.NaN);
s1.add(5, 1.1);
s1.add(6, Double.NaN);
s1.add(7, Double.NaN);
s1.add(8, 6.4);
s1.add(9, 6.5);
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
dataset.addSeries(s1);
XYDatasetTableModel tablemodel = new XYDatasetTableModel();
tablemodel.setModel(dataset);
JTable dataTable = new JTable(tablemodel);
JScrollPane scroll = new JScrollPane(dataTable);
scroll.setPreferredSize(new Dimension(600, 150));
JFreeChart chart = ChartFactory.createXYLineChart(
"XY Series Demo",
"X", "Y", dataset, PlotOrientation.VERTICAL,
true,
true,
false);
StandardXYItemRenderer renderer = new StandardXYItemRenderer();
renderer.setDrawSeriesLineAsPath(true);
// enable shapes
renderer.setBaseShapesVisible(true);
((XYPlot) chart.getPlot()).setRenderer(renderer);
ChartPanel chartPanel = new ChartPanel(chart);
panel.add(chartPanel, BorderLayout.CENTER);
panel.add(scroll, BorderLayout.SOUTH);
frame.setContentPane(panel);
frame.setSize(600, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
I understand that there might be users who got used to the way it was before where NaN values were plot in the top left corner.
Since i got used to the way NaN values are handled in XYPlots, I think it would make sense to have the same handling in all plots for consistency.
I could implement the new updated PolarPlot renderer so that only when calling a function like renderer.hideNaNValues(true)
is called the new handling is used. So we still have the old handling with the NaN being at topleft as default but we can also switch to the new handling.
What do you think?
from jfreechart.
Yes, a mutable property—e.g. your hideNaNValues
set to false
by default—would be less disruptive.
To be honest, I would be unlikely to use the feature. I typically handle anomalous values upstream of the data model, and then only having verified the desired functionality. For example, rather than compromise data integrity, I might propose an adjacent visual control to show or hide the NaN
values.
from jfreechart.
Related Issues (20)
- set axis arrow and location HOT 1
- P&F chart HOT 1
- About Jakarta EE 9 HOT 6
- Removing space before and after chart HOT 8
- Publish latest javadoc HOT 1
- Histogram : How to only have integer tick in the x axis HOT 1
- org.jfree.chart.labels.ItemLabelPosition class not cloneable HOT 1
- Rotate X-axis labels vertically HOT 10
- bogus CVE claimed on this project HOT 12
- Unnecessary reference to Swing in headless mode causes considerable delay HOT 3
- Multiple vulnerabilities in jfreechart to be solved in both 1.5.x (with JDK 1.8) and 2.x (with JDK >= 1.11)? HOT 2
- Quarter constructor does not validate quarter and year parameter ranges.
- Inquiry About JFreeChart License Discrepancy Between Maven and Git Repositories HOT 4
- Vulnerable Code HOT 3
- 不给问题 HOT 2
- Main web page is still on JFreeChart 1.5.3
- Anomaly while building JFreeChart v1.5.5 HOT 2
- CVE vulnerabilities on Jfreechart
- SpiderWebPlot HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jfreechart.