Skip to content
Snippets Groups Projects
Commit 1d3942b2 authored by timmolter's avatar timmolter
Browse files

removed NaNs as acceptable data points, made charts dynamically resizable,...

removed NaNs as acceptable data points, made charts dynamically resizable, fixed chart padding and layout calculations, removed deprecated SwingWrapper constructor
parent 4e918d43
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 215 deletions
......@@ -58,10 +58,10 @@ public class Axis implements IChartPart {
private BigDecimal max = null;
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/** the paint zone */
private Rectangle paintZone = new Rectangle(); // default all-zero rectangle
private Rectangle paintZone;
/** An axis direction */
public enum Direction {
......@@ -198,6 +198,9 @@ public class Axis implements IChartPart {
@Override
public void paint(Graphics2D g) {
paintZone = new Rectangle();
bounds = new Rectangle();
// determine Axis bounds
if (direction == Direction.Y) { // Y-Axis
......
......@@ -77,9 +77,6 @@ public class AxisPair implements IChartPart {
if (xData != null && xData.size() == 0) {
throw new IllegalArgumentException("X-Axis data cannot be empty!!!");
}
if (yData.size() == 1 && Double.isNaN(yData.iterator().next().doubleValue())) {
throw new IllegalArgumentException("Y-Axis data cannot contain a single NaN value!!!");
}
Series series = null;
if (xData != null) {
......
......@@ -43,10 +43,10 @@ public class AxisTick implements IChartPart, IHideable {
private AxisTickMarks axisTickMarks;
/** the arraylist of tick label position in pixels */
private List<Integer> tickLocations = new LinkedList<Integer>();
private List<Integer> tickLocations;
/** the arraylist of tick label vales */
private List<String> tickLabels = new LinkedList<String>();
private List<String> tickLabels;
private int workingSpace;
......@@ -66,7 +66,7 @@ public class AxisTick implements IChartPart, IHideable {
private SimpleDateFormat simpleDateformat = new SimpleDateFormat("MM-dd");
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/** the visibility state of axistick */
protected boolean isVisible = true; // default to true
......@@ -119,6 +119,8 @@ public class AxisTick implements IChartPart, IHideable {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
if (axis.getDirection() == Axis.Direction.Y) {
workingSpace = (int) axis.getPaintZone().getHeight(); // number of pixels the axis has to work with for drawing AxisTicks
// System.out.println("workingspace= " + workingSpace);
......@@ -160,6 +162,9 @@ public class AxisTick implements IChartPart, IHideable {
*/
private void determineAxisTick() {
tickLocations = new LinkedList<Integer>();
tickLabels = new LinkedList<String>();
// System.out.println("workingSpace= " + workingSpace);
int tickSpace = AxisPair.getTickSpace(workingSpace);
......
......@@ -41,7 +41,7 @@ public class AxisTickLabels implements IChartPart {
private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY);// default foreground color
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/**
* Constructor
......@@ -68,6 +68,8 @@ public class AxisTickLabels implements IChartPart {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
g.setColor(foreground);
if (axis.getDirection() == Axis.Direction.Y) { // Y-Axis
......@@ -80,7 +82,9 @@ public class AxisTickLabels implements IChartPart {
String tickLabel = axisTick.getTickLabels().get(i);
int tickLocation = axisTick.getTickLocations().get(i);
TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
FontRenderContext frc = g.getFontRenderContext();
// TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
TextLayout layout = new TextLayout(tickLabel, font, frc);
Rectangle tickLabelBounds = layout.getPixelBounds(null, 0, 0);
layout.draw(g, xOffset, (int) (yOffset + axis.getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));
......@@ -104,7 +108,8 @@ public class AxisTickLabels implements IChartPart {
String tickLabel = axisTick.getTickLabels().get(i);
int tickLocation = axisTick.getTickLocations().get(i);
TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
FontRenderContext frc = g.getFontRenderContext();
TextLayout layout = new TextLayout(tickLabel, font, frc);
Rectangle tickLabelBounds = layout.getPixelBounds(null, 0, 0);
layout.draw(g, (int) (xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0), yOffset);
......
......@@ -43,7 +43,7 @@ public class AxisTickMarks implements IChartPart {
public static final int TICK_LENGTH = 3;
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/**
* Constructor
......@@ -66,6 +66,8 @@ public class AxisTickMarks implements IChartPart {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
g.setColor(foreground);
if (axis.getDirection() == Axis.Direction.Y) { // Y-Axis
......
......@@ -25,7 +25,6 @@ import java.awt.geom.AffineTransform;
import com.xeiam.xchart.interfaces.IHideable;
/**
* AxisTitle
*/
......@@ -47,7 +46,7 @@ public class AxisTitle implements IHideable {
private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY); // default foreground color
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
protected final static int AXIS_TITLE_PADDING = 10;
......@@ -96,18 +95,19 @@ public class AxisTitle implements IHideable {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
g.setColor(foreground);
if (axis.getDirection() == Axis.Direction.Y) {
if (isVisible && !this.text.trim().equalsIgnoreCase("")) {
if (isVisible) {
FontRenderContext frc = g.getFontRenderContext();
TextLayout nonRotatedTextLayout = new TextLayout(this.text, this.font, frc);
TextLayout nonRotatedTextLayout = new TextLayout(text, font, frc);
Rectangle nonRotatedRectangle = nonRotatedTextLayout.getPixelBounds(null, 0, 0);
// System.out.println(nonRotatedRectangle);
TextLayout rotatedTextLayout = new TextLayout(this.text, this.font.deriveFont(AffineTransform.getRotateInstance(Math.PI / -2.0, 0, 0)), frc);
TextLayout rotatedTextLayout = new TextLayout(text, font.deriveFont(AffineTransform.getRotateInstance(Math.PI / -2.0, 0, 0)), frc);
// Rectangle rotatedRectangle = rotatedTextLayout.getPixelBounds(null, 0, 0);
// System.out.println(rotatedRectangle);
......@@ -129,7 +129,7 @@ public class AxisTitle implements IHideable {
if (isVisible) {
FontRenderContext frc = g.getFontRenderContext();
TextLayout textLayout = new TextLayout(this.text, this.font, frc);
TextLayout textLayout = new TextLayout(text, font, frc);
Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
// System.out.println(rectangle);
......
......@@ -15,7 +15,6 @@
*/
package com.xeiam.xchart;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.ArrayList;
......@@ -57,10 +56,7 @@ public class Chart {
/**
* @param g
*/
public void paint(final Graphics2D g, int width, int height) {
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
public void paint(Graphics2D g, int width, int height) {
this.width = width;
this.height = height;
......@@ -71,7 +67,7 @@ public class Chart {
/**
* @param g
*/
public void paint(final Graphics2D g) {
public void paint(Graphics2D g) {
// Sanity check
if (axisPair.getSeriesMap().isEmpty()) {
......
......@@ -49,10 +49,11 @@ public class ChartLegend implements IHideable {
/** the foreground color */
private Color foreground = ChartColor.getAWTColor(ChartColor.BLACK); // default foreground color
private final int LEGEND_PADDING = 10;
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/**
* Constructor
......@@ -71,6 +72,8 @@ public class ChartLegend implements IHideable {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
if (isVisible) {
Map<Integer, Series> seriesMap = chart.getAxisPair().getSeriesMap();
......
......@@ -45,7 +45,7 @@ public class ChartTitle implements IHideable {
private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY); // default foreground color
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
/**
* Constructor
......@@ -74,17 +74,20 @@ public class ChartTitle implements IHideable {
@Override
public void paint(Graphics2D g) {
FontRenderContext frc = g.getFontRenderContext();
TextLayout textLayout = new TextLayout(this.text, this.font, frc);
Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
int xOffset = (int) ((chart.getWidth() - rectangle.getWidth()) / 2.0);
int yOffset = (int) ((isVisible ? (Chart.CHART_PADDING - rectangle.getY()) : 0));
bounds = new Rectangle(xOffset, yOffset + (isVisible ? (int) rectangle.getY() : 0), (int) rectangle.getWidth(), (int) (isVisible ? rectangle.getHeight() : 0));
// g.setColor(Color.green);
// g.draw(bounds);
bounds = new Rectangle();
if (isVisible) {
FontRenderContext frc = g.getFontRenderContext();
TextLayout textLayout = new TextLayout(text, font, frc);
Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
int xOffset = (int) ((chart.getWidth() - rectangle.getWidth()) / 2.0);
int yOffset = (int) ((isVisible ? (Chart.CHART_PADDING - rectangle.getY()) : 0));
bounds = new Rectangle(xOffset, yOffset + (isVisible ? (int) rectangle.getY() : 0), (int) rectangle.getWidth(), (int) (isVisible ? rectangle.getHeight() : 0));
// g.setColor(Color.green);
// g.draw(bounds);
g.setColor(foreground);
textLayout.draw(g, xOffset, yOffset);
}
......
......@@ -34,7 +34,7 @@ public class Plot implements IChartPart {
public static final int PLOT_PADDING = 3;
/** the bounds */
private Rectangle bounds = new Rectangle(); // default all-zero rectangle
private Rectangle bounds;
public Plot(Chart chart) {
......@@ -52,6 +52,8 @@ public class Plot implements IChartPart {
@Override
public void paint(Graphics2D g) {
bounds = new Rectangle();
// calculate bounds
int xOffset = (int) (chart.getAxisPair().getYAxis().getBounds().getX() + chart.getAxisPair().getYAxis().getBounds().getWidth() + (chart.getAxisPair().getYAxis().getAxisTick().isVisible ? (Plot.PLOT_PADDING + 1) : 0));
int yOffset = (int) (chart.getAxisPair().getYAxis().getBounds().getY());
......
......@@ -102,55 +102,53 @@ public class PlotContent implements IChartPart {
if (errorBars != null) {
eb = ebItr.next().doubleValue();
}
if (!Double.isNaN(x.doubleValue()) && !Double.isNaN(y.doubleValue())) {
// int xTransform = (int) (xLeftMargin + ((x - xMin) / (xMax - xMin) * xTickSpace));
int xTransform = (int) (xLeftMargin + (x.subtract(xMin).doubleValue() / xMax.subtract(xMin).doubleValue() * xTickSpace));
// int yTransform = (int) (bounds.getHeight() - (yTopMargin + (y - yMin) / (yMax - yMin) * yTickSpace));
int yTransform = (int) (bounds.getHeight() - (yTopMargin + y.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace));
// int xTransform = (int) (xLeftMargin + ((x - xMin) / (xMax - xMin) * xTickSpace));
int xTransform = (int) (xLeftMargin + (x.subtract(xMin).doubleValue() / xMax.subtract(xMin).doubleValue() * xTickSpace));
// int yTransform = (int) (bounds.getHeight() - (yTopMargin + (y - yMin) / (yMax - yMin) * yTickSpace));
int yTransform = (int) (bounds.getHeight() - (yTopMargin + y.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace));
// a check if all y data are the exact same values
if (Math.abs(xMax.subtract(xMin).doubleValue()) / 5 == 0.0) {
xTransform = (int) (bounds.getWidth() / 2.0);
}
// a check if all y data are the exact same values
if (Math.abs(xMax.subtract(xMin).doubleValue()) / 5 == 0.0) {
xTransform = (int) (bounds.getWidth() / 2.0);
}
// a check if all y data are the exact same values
if (Math.abs(yMax.subtract(yMin).doubleValue()) / 5 == 0.0) {
yTransform = (int) (bounds.getHeight() / 2.0);
}
// a check if all y data are the exact same values
if (Math.abs(yMax.subtract(yMin).doubleValue()) / 5 == 0.0) {
yTransform = (int) (bounds.getHeight() / 2.0);
}
int xOffset = (int) (bounds.getX() + xTransform - 1);
int yOffset = (int) (bounds.getY() + yTransform);
// System.out.println(yOffset);
// System.out.println(yTransform);
// paint line
if (series.getLineStyle() != null) {
if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) {
g.setColor(series.getLineColor());
g.setStroke(series.getLineStyle());
g.drawLine(previousX, previousY, xOffset, yOffset);
}
previousX = xOffset;
previousY = yOffset;
int xOffset = (int) (bounds.getX() + xTransform - 1);
int yOffset = (int) (bounds.getY() + yTransform);
// System.out.println(yOffset);
// System.out.println(yTransform);
// paint line
if (series.getLineStyle() != null) {
if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) {
g.setColor(series.getLineColor());
g.setStroke(series.getLineStyle());
g.drawLine(previousX, previousY, xOffset, yOffset);
}
previousX = xOffset;
previousY = yOffset;
}
// paint marker
if (series.getMarker() != null) {
g.setColor(series.getMarkerColor());
series.getMarker().paint(g, xOffset, yOffset);
}
// paint marker
if (series.getMarker() != null) {
g.setColor(series.getMarkerColor());
series.getMarker().paint(g, xOffset, yOffset);
}
// paint errorbar
if (errorBars != null) {
g.setColor(ChartColor.getAWTColor(ChartColor.DARK_GREY));
g.setStroke(SeriesLineStyle.getBasicStroke(SeriesLineStyle.SOLID));
int bottom = (int) (-1 * bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
int top = (int) (bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
g.drawLine(xOffset, yOffset + bottom, xOffset, yOffset + top);
g.drawLine(xOffset - 3, yOffset + bottom, xOffset + 3, yOffset + bottom);
g.drawLine(xOffset - 3, yOffset + top, xOffset + 3, yOffset + top);
}
// paint errorbar
if (errorBars != null) {
g.setColor(ChartColor.getAWTColor(ChartColor.DARK_GREY));
g.setStroke(SeriesLineStyle.getBasicStroke(SeriesLineStyle.SOLID));
int bottom = (int) (-1 * bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
int top = (int) (bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
g.drawLine(xOffset, yOffset + bottom, xOffset, yOffset + top);
g.drawLine(xOffset - 3, yOffset + bottom, xOffset + 3, yOffset + bottom);
g.drawLine(xOffset - 3, yOffset + top, xOffset + 3, yOffset + top);
}
}
......
......@@ -32,8 +32,6 @@ public class Series {
private String name = "";
// private AxisType seriesType;
protected Collection<?> xData;
protected Collection<Number> yData;
......@@ -121,25 +119,17 @@ public class Series {
BigDecimal bigDecimal = null;
if (axisType == AxisType.NUMBER) {
bigDecimal = new BigDecimal(((Number) dataPoint).doubleValue());
verify(bigDecimal);
bigDecimal = new BigDecimal(((Number) dataPoint).toString());
} else if (axisType == AxisType.DATE) {
Date date = (Date) dataPoint;
bigDecimal = new BigDecimal(date.getTime());
verify(bigDecimal);
}
// if (min == null || bigDecimal < min) {
if (min == null || bigDecimal.compareTo(min) < 0) {
if (!Double.isNaN(bigDecimal.doubleValue())) {
min = bigDecimal;
}
min = bigDecimal;
}
// if (max == null || bigDecimal > max) {
if (max == null || bigDecimal.compareTo(max) > 0) {
if (!Double.isNaN(bigDecimal.doubleValue())) {
max = bigDecimal;
}
max = bigDecimal;
}
}
......@@ -162,45 +152,16 @@ public class Series {
while (itr.hasNext()) {
BigDecimal bigDecimal = new BigDecimal(itr.next().doubleValue());
BigDecimal eb = new BigDecimal(ebItr.next().doubleValue());
verify(bigDecimal);
if (min == null || (bigDecimal.subtract(eb)).compareTo(min) < 0) {
if (!Double.isNaN(bigDecimal.doubleValue())) {
min = bigDecimal.subtract(eb);
}
min = bigDecimal.subtract(eb);
}
if (max == null || (bigDecimal.add(eb)).compareTo(max) > 0) {
if (!Double.isNaN(bigDecimal.doubleValue())) {
max = bigDecimal.add(eb);
}
max = bigDecimal.add(eb);
}
}
return new BigDecimal[] { min, max };
}
/**
* Checks for invalid values in data array
*
* @param data
*/
private void verify(BigDecimal value) {
// TODO get rid of this if not a Number axis type
double doubleValue = value.doubleValue();
if (doubleValue == Double.POSITIVE_INFINITY) {
throw new RuntimeException("Axis data cannot contain Double.POSITIVE_INFINITY!!!");
} else if (doubleValue == Double.NEGATIVE_INFINITY) {
throw new RuntimeException("Axis data cannot contain Double.NEGATIVE_INFINITY!!!");
}
// TODO get rid of this if not a Date axis type
long longValue = value.longValue();
if (longValue == Long.MAX_VALUE) {
throw new RuntimeException("Axis data cannot be greater than Long.MAX_VALUE!!!");
} else if (longValue == Long.MIN_VALUE) {
throw new RuntimeException("Axis data cannot be less than Long.MIN_VALUE!!!");
}
}
public String getName() {
return name;
......
......@@ -43,23 +43,6 @@ public class SwingWrapper {
this.charts.add(chart);
}
/**
* Deprecated Constructor - use the one that takes a Collection! This will be removed in next version.
*
* @param charts
* @param numRows
* @param numColumns
*/
@Deprecated
public SwingWrapper(Chart[] charts, int numRows, int numColumns) {
for (int i = 0; i < charts.length; i++) {
this.charts.add(charts[i]);
}
this.numRows = numRows;
this.numColumns = numColumns;
}
/**
* Constructor - The number of rows and columns will be calculated automatically
*
......
......@@ -29,11 +29,12 @@ import com.xeiam.xchart.Chart;
*/
public class XChartJPanel extends JPanel {
private Chart chart;
private final Chart chart;
public XChartJPanel(Chart chart) {
public XChartJPanel(final Chart chart) {
this.chart = chart;
}
@Override
......@@ -41,10 +42,7 @@ public class XChartJPanel extends JPanel {
super.paintComponent(g);
super.removeAll();
System.out.println(getSize().toString());
chart.paint((Graphics2D) g, getSize().width, getSize().height);
chart.paint((Graphics2D) g, getWidth(), getHeight());
}
@Override
......
/**
* Copyright 2011-2012 Xeiam LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.xeiam.xchart.example;
import java.util.Arrays;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.swing.SwingWrapper;
/**
* Creates a simple charts using Longs as inputs
*
* @author timmolter
*/
public class Example10 {
public static void main(String[] args) throws Exception {
Collection<Number> xData = Arrays
.asList(new Number[] { 1222812000000L, 1222898400000L, 1222984800000L, 1223071200000L, 1223157600000L, 1223244000000L, 1223330400000L, 1223416800000L, 1223503200000L, 1223589600000L });
// .asList(new Number[] { 12228120L, 12228984L, 12229848L, 12230712L, 12231576L, 12232440L, 12233304L, 12234168L, 12235032L, 12235896L });
// .asList(new Number[] { 12228120, 12228984, 12229848, 12230712, 12231576, 12232440, 12233304, 12234168, 12235032, 12235896 });
// .asList(new Number[] { 12228120.0, 12228984.0, 12229848.0, 12230712.0, 12231576.0, 12232440.0, 12233304.0, 12234168.0, 12235032.0, 12235896.0 });
// .asList(new Number[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 });
// .asList(new Number[] { 0.0, 100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0 });
// .asList(new Number[] { 0.0, 100000000.0, 200000000.0, 300000000.0, 400000000.0, 500000000.0, 600000000.0, 700000000.0, 800000000.0, 900000000.0 });
Collection<Number> yData = Arrays.asList(new Number[] { 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0 });
// Create Chart
Chart chart = new Chart(700, 500);
chart.setChartTitle("Sample Chart");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
chart.addSeries("y(x)", xData, yData);
new SwingWrapper(chart).displayChart();
}
}
......@@ -48,19 +48,12 @@ public class Example3 {
chart.setChartTitle("Sample Chart");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
// chart.setAxisTicksVisible(false);
// chart.setAxisTitlesVisible(false);
// chart.setXAxisTitleVisible(false);
// chart.setXAxisTicksVisible(false);
chart.setChartTitleVisible(false);
chart.setChartLegendVisible(false);
chart.setChartGridlinesVisible(false);
String seriesName = "y=" + 2 * i + "x-" + i * b + "b";
chart.addSeries(seriesName, xData, yData);
}
// JFrame testFrame = new TestFrame(chart);
new SwingWrapper(chart).displayChart();
}
}
......@@ -15,29 +15,33 @@
*/
package com.xeiam.xchart.example;
import java.util.Arrays;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.swing.SwingWrapper;
/**
* Create chart with NaN values
* Creates a simple charts using Longs as inputs
*
* @author timmolter
*/
public class Example7 {
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Collection<Number> xData = Arrays.asList(new Number[] { 12228120L, 12228984L, 12229848L, 12230712L, 12231576L, 12232440L, 12233304L, 12234168L, 12235032L, 12235896L });
Collection<Number> yData = Arrays.asList(new Number[] { 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0 });
// Create Chart
Chart chart = new Chart(700, 500);
// Customize Chart
chart.setChartTitle("Sample Chart");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
chart.addSeries("NaN Value at (3,2)", null, new double[] { 0, 1, Double.NaN, 3, 4 });
chart.addSeries("y(x)", xData, yData);
new SwingWrapper(chart).displayChart();
}
}
......@@ -52,7 +52,8 @@ public class Example9 {
chart.setChartTitle("Sample Chart with Date X-Axis");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
chart.setChartGridlinesVisible(false);
chart.setXAxisTicksVisible(false);
chart.addDateSeries("Fake Data", xData, yData);
new SwingWrapper(chart).displayChart();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment