XChart is a light-weight Java library for plotting data.

Related tags

Science XChart
Overview

XChart XChart

XChart is a light weight Java library for plotting data.

Description

XChart is a light-weight and convenient library for plotting data designed to go from data to chart in the least amount of time possible and to take the guess-work out of customizing the chart style.

Simplest Example

Create a XYChart instance via QuickChart, add a series of data to it, and either display it or save it as a bitmap.

double[] xData = new double[] { 0.0, 1.0, 2.0 };
double[] yData = new double[] { 2.0, 1.0, 0.0 };

// Create Chart
XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData);

// Show it
new SwingWrapper(chart).displayChart();

// Save it
BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.PNG);

// or save it in high-res
BitmapEncoder.saveBitmapWithDPI(chart, "./Sample_Chart_300_DPI", BitmapFormat.PNG, 300);

Intermediate Example

Create a XYChart via a XYChartBuilder, style chart, add a series to it, style series, and display chart.

// Create Chart
XYChart chart = new XYChartBuilder().width(600).height(500).title("Gaussian Blobs").xAxisTitle("X").yAxisTitle("Y").build();

// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Scatter);
chart.getStyler().setChartTitleVisible(false);
chart.getStyler().setLegendPosition(LegendPosition.InsideSW);
chart.getStyler().setMarkerSize(16);

// Series
chart.addSeries("Gaussian Blob 1", getGaussian(1000, 1, 10), getGaussian(1000, 1, 10));
XYSeries series = chart.addSeries("Gaussian Blob 2", getGaussian(1000, 1, 10), getGaussian(1000, 0, 5));
series.setMarker(SeriesMarkers.DIAMOND);

new SwingWrapper(chart).displayChart();

Advanced Example

Create a XYChart via a XYChartBuilder, style chart, add a series to it, add chart to XChartPanel, embed in Java Swing App, and display GUI.

// Create Chart
final XYChart chart = new XYChartBuilder().width(600).height(400).title("Area Chart").xAxisTitle("X").yAxisTitle("Y").build();

// Customize Chart
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);

// Series
chart.addSeries("a", new double[] { 0, 3, 5, 7, 9 }, new double[] { -3, 5, 9, 6, 5 });
chart.addSeries("b", new double[] { 0, 2, 4, 6, 9 }, new double[] { -1, 6, 4, 0, 4 });
chart.addSeries("c", new double[] { 0, 1, 3, 8, 9 }, new double[] { -2, -1, 1, 0, 1 });

// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {

  @Override
  public void run() {

    // Create and set up the window.
    JFrame frame = new JFrame("Advanced Example");
    frame.setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // chart
    JPanel chartPanel = new XChartPanel<XYChart>(chart);
    frame.add(chartPanel, BorderLayout.CENTER);

    // label
    JLabel label = new JLabel("Blah blah blah.", SwingConstants.CENTER);
    frame.add(label, BorderLayout.SOUTH);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
});

To make it real-time, simply call updateXYSeries on the XYChart instance to update the series data, followed by revalidate() and repaint() on the XChartPanel instance to repaint.

Features

  • No required additional dependencies
  • Multiple Y-Axis charts
  • Line charts
  • Step charts
  • Scatter charts
  • Area charts
  • Step Area charts
  • Bar charts
  • Histogram charts
  • Pie charts
  • Donut charts
  • Bubble charts
  • Stick charts
  • Dial charts
  • Radar charts
  • OHLC charts
  • Box charts
  • Heat maps
  • Error bars
  • Logarithmic axes
  • Number, Date, Bubble and Category X-Axis
  • Multiple series
  • Tool tips
  • Extensive customization
  • Themes - XChart, GGPlot2, Matlab
  • Right-click, Save-As...
  • User-defined axes range
  • Definable legend placement
  • CSV import and export
  • High resolution chart export
  • Export as PNG, JPG, BMP, GIF with custom DPI setting
  • Export SVG, EPS using optional de.erichseifert.vectorgraphics2d library
  • Export PDF using optional pdfbox-graphics2d library
  • Real-time charts
  • Java 8 and up

Chart Types

Currently, there are 5 major chart types. Each type has its corresponding ChartBuilder, Styler and Series.

Chart Type Builder Styler Series Allowed Data Types Default Series Render Style
XYChart XYChartBuilder XYStyler XYSeries Number, Date Line
CategoryChart CategoryChartBuilder CategoryStyler CategorySeries Number, Date, String Bar
PieChart PieChartBuilder PieStyler PieSeries String Pie
BubbleChart BubbleChartBuilder BubbleStyler BubbleSeries Number, Date Round
DialChart DialChartBuilder DialStyler DialSeries double Round
RadarChart RadarChartBuilder RadarStyler RadarSeries double[] Round
OHLCChart OHLCChartBuilder OHLCStyler OHLCSeries OHLC with Date Candle
BoxChart BoxChartBuilder BoxStyler BoxSeries Number, Date, String Box
HeatMapChart HeatMapChartBuilder HeatMapStyler HeatMapSeries Number, Date, String --

The different Stylers contain chart styling methods specific to the corresponding chart type as well as common styling methods common across all chart types.

XYChart

XYChart charts take Date or Number data types for the X-Axis and Number data types for the Y-Axis. For both axes, the tick marks are auto generated to span the range and domain of the data in evenly-spaced intervals.

Series render styles include: Line, Scatter, Area, Step and StepArea.

CategoryChart

CategoryChart charts take Date, Number or String data types for the X-Axis and Number data types for the Y-Axis. For the X-Axis, each category is given its own tick mark.

Series render styles include: Bar, Line, Scatter, Area and Stick.

PieChart

PieChart charts take String data types for the pie slice name and Number data types for the pie slice value.

Series render styles include: Pie and Donut.

BubbleChart

BubbleChart charts take Date or Number data types for the X-Axis and Number data types for the Y-Axis and bubble sizes.

Series render styles include: Round and in the near future Square.

DialChart

DialChart charts take a double to set the position of the dial pointer and a String to set the label. Extensive customization is possible.

RadarChart

RadarChart charts take a double[] of values between 0.0. and 1.0 to set the position of the series' data point along each radii. Radii labels, if displayed, are set by passing a String[].

Radar chart render styles are: Polygon or Circle.

OHLCChart

OHLCChart charts take Date data types for the X-Axis and 4 Number data types for the Y-Axis. For both axes, the tick marks are auto generated to span the range and domain of the data in evenly-spaced intervals.

Series render styles include: Candle, HiLo.

BoxChart

BoxChart charts take String data (seriesNames) types for the X-Axis and Number data types for the Y-Axis. Each box chart is calculated from the corresponding series yData. Create a BoxChart via a BoxChartBuilder, style chart, add a series to it.

// Create Chart
BoxChart chart =
	new BoxChartBuilder().title("box plot demo").build();

// Choose a calculation method
chart.getStyler().setBoxplotCalCulationMethod(BoxplotCalCulationMethod.N_LESS_1_PLUS_1);
chart.getStyler().setToolTipsEnabled(true);

// Series
chart.addSeries("boxOne", Arrays.asList(1,2,3,4));
new SwingWrapper<BoxChart>(chart).displayChart();

Four calculation methods for boxplots:

  • "N_PLUS_1": determine the position of the quartile, where Qi is = i (n + 1) / 4, where i = 1, 2, and 3. n represents the number of items contained in the sequence. Calculate the corresponding quartile based on location.
  • "N_LESS_1": Determine the position of the quartile, where Qi is = i (n-1) / 4, where i = 1, 2, and 3. n represents the number of items contained in the sequence. Calculate the corresponding quartile based on location.
  • "NP": Determine the position of the quartile, where Qi is np = (i * n) / 4, where i = 1, 2, and 3. n represents the number of items contained in the sequence. If np is not an integer, Qi = X [np + 1]; If np is an integer, Qi = (X [np] + X [np + 1]) / 2.
  • "N_LESS_1_PLUS_1": Determine the position of the quartile, where Qi is = i (n-1) / 4 + 1, where i = 1, 2, 3. n represents the number of items contained in the sequence. Calculate the corresponding quartile based on location.

Interquartile range, IQR = Q3-Q1.

Upper whisker = Q3 + 1.5 * IQR = Q3 + 1.5 * (Q3 - Q1), if Upper whisker is greater than the maximum value of yData, Upper whisker = maximum value of yData.

Lower whisker = Q1 - 1.5 * IQR = Q1 - 1.5 * (Q3 -Q1), if the lower whisker is less than the minimum value of yData, the lower whisker = the minimum value of yData.

E.g:

An example of a set of sequence numbers: 12, 15, 17, 19, 20, 23, 25, 28, 30, 33, 34, 35, 36, 37

  • "N_PLUS_1": Q1's position = (14 + 1) /4=3.75, Q1 = 0.25 × third term + 0.75 × fourth term = 0.25 × 17 + 0.75 × 19 = 18.5;
  • "N_LESS_1": Q1's location = (14-1) /4=3.25, Q1 = 0.75 × third term + 0.25 × fourth term = 0.75 × 17 + 0.25 × 19 = 17.5;
  • "NP": Q1's position = 14 * 0.25 = 3.5, Q1 = 19;
  • "N_LESS_1_PLUS_1": Q1's location = (14-1) / 4 + 1 = 4.25 Q1 = 0.75 × the fourth term + 0.25 × the fifth term = 0.75 × 19 + 0.25 × 20 = 19.25.

HeatMapChart

HeatMapChart take Date, Number or String data types for the X-Axis, Y-Axis.

Real-time Java Charts using XChart

Creating real-time charts is as simple as calling updateXYSeries for one or more series objects through the XYChart instance and triggering a redraw of the JPanel containing the chart. This works for all chart types including XYChart, CategoryChart, BubbleChart and PieChart, for which example source code can be found here. Examples demonstrate using the SwingWrapper with repaintChart() method as well as XChartPanel with revalidate() and repaint().

The following sample code used to generate the above real-time chart can be found here.

public class SimpleRealTime {

  public static void main(String[] args) throws Exception {

    double phase = 0;
    double[][] initdata = getSineData(phase);

    // Create Chart
    final XYChart chart = QuickChart.getChart("Simple XChart Real-time Demo", "Radians", "Sine", "sine", initdata[0], initdata[1]);

    // Show it
    final SwingWrapper<XYChart> sw = new SwingWrapper<XYChart>(chart);
    sw.displayChart();

    while (true) {

      phase += 2 * Math.PI * 2 / 20.0;

      Thread.sleep(100);

      final double[][] data = getSineData(phase);

      javax.swing.SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

          chart.updateXYSeries("sine", data[0], data[1], null);
          sw.repaintChart();
        }
      });
    }

  }

  private static double[][] getSineData(double phase) {

    double[] xData = new double[100];
    double[] yData = new double[100];
    for (int i = 0; i < xData.length; i++) {
      double radians = phase + (2 * Math.PI / xData.length * i);
      xData[i] = radians;
      yData[i] = Math.sin(radians);
    }
    return new double[][] { xData, yData };
  }
}

Chart Customization

All the styling options can be found in one of two possible places: 1) the Chart's Styler or 2) the series' set methods. With this chart customization design, all customization options can be quickly "discovered" using an IDE's built in "Content Assist". With centralized styling like this, there is no need to hunt around the entire charting API to find that one customization you're looking for - it's all right in one spot!

Customizing Axis Tick Labels

XChart automatically creates axis tick labels for chart types with axes.

Default axis tick placement can be altered with chart.getStyler().setXAxisTickMarkSpacingHint(spacingHint);.

Default axis label labels can be altered with one of:

chart.getStyler().setDatePattern(datePattern)
chart.getStyler().setXAxisDecimalPattern(pattern);
chart.getStyler().setYAxisDecimalPattern(pattern);

You can also create custom axis tick labels with a callback function. In the following example taken from DateChart09, the X-Axis tick labels are generated via a custom lambda function which takes the numerical (double) tick label values and converts them to a String.

// set custom X-Axis tick labels
LocalDateTime startTime = LocalDateTime.of(2001, Month.JANUARY, 1, 0, 0, 0);
DateTimeFormatter xTickFormatter = DateTimeFormatter.ofPattern("LLL");
chart.getStyler().setxAxisTickLabelsFormattingFunction(x -> startTime.plusDays(x.longValue()).format(xTickFormatter));

In the following example taken from DateChart06, the Y-Axis tick labels are converted to the englich word reprentation of the numbers.

chart.getStyler().setyAxisTickLabelsFormattingFunction(x -> NumberWordConverter.convert(x.intValue()));

Multiple Axes

XChart has multiple y axes feature. Y offset is calculated according to the Y-Axis the series configured. Max y value in this axis is calculated according to the series on this axis only. To set the y group:

series.setYAxisGroup(axisGroup);   

To manually change max/min of axis group:

((AxesChartStyler) chart.getStyler()).setYAxisMax(axisGroup, 200.0);

Axis can be drawn on the left (default) or on the right of the chart:

chart.getStyler().setYAxisGroupPosition(axisGroup, Styler.YAxisPosition.Right);

To set the Y axes titles:

chart.setYAxisGroupTitle(0, "A");
chart.setYAxisGroupTitle(1, "B");

Zooming In

For the XYChart chart type, zooming in is possible on an XChartPanel via select-dragging over a range on the X-Axis. Reverting out of the zoom can be accomplished by double-clicking on the chart or by clicking on the "reset" button, which can be posotioned as desired.

The following example zoom style options show which are available:

chart.getStyler().setZoomEnabled(true);
chart.getStyler().setZoomResetButtomPosition(Styler.CardinalPosition.InsideS);
chart.getStyler().setZoomResetByDoubleClick(false);
chart.getStyler().setZoomResetByButton(true);
chart.getStyler().setZoomSelectionColor(new Color(0,0 , 192, 128));

A working example can be found at DateChart01.

Chart Annotations

For all chart types, one or more chart annotations can be super-imposed on top of the chart. The following types of annotatins are available:

  • AnnotationLine
  • AnnotationImage
  • AnnotationText
  • AnnotationTextPanel

The following is a chart with four AnnotationLines, one AnnotationImage and one AnnotationText:

Positioning is relative to the bottom-left corner of the chart and to the center of the AnnotationImage or AnnotationText.

The following example AnnotationLine and AnnotationText styling parameters show which are available:

chart.getStyler().setAnnotationLineColor(Color.GREEN);
chart.getStyler().setAnnotationLineStroke(new BasicStroke(3.0f));
chart.getStyler().setAnnotationTextFont(new Font(Font.MONOSPACED, Font.ITALIC, 8));
chart.getStyler().setAnnotationTextFontColor(Color.BLUE);

A working example can be found at LineChart10.

The following is a chart with three AnnotationTextPanels:

Positioning is relative to the bottom-left corner of the chart and to the bottom-left corner of the AnnotationTextPanel.

The following example AnnotationTextPanel styling parameters show which are available:

chart.getStyler().setAnnotationTextPanelPadding(20);
chart.getStyler().setAnnotationTextPanelFont(new Font("Verdana", Font.BOLD, 12));
chart.getStyler().setAnnotationTextPanelBackgroundColor(Color.RED);
chart.getStyler().setAnnotationTextPanelBorderColor(Color.BLUE);
chart.getStyler().setAnnotationTextPanelFontColor(Color.GREEN);

A working example can be found at ScatterChart04.

Tool Tips

For all chart types, tool tips can be activated on an XChartPanel via

chart.getStyler().setToolTipsEnabled(true);

The following example tooltip options show which are available:

chart.getStyler().setToolTipsEnabled(true);
chart.getStyler(). setToolTipsAlwaysVisible(true);
chart.getStyler().setToolTipFont( new Font("Verdana", Font.BOLD, 12));
chart.getStyler().setToolTipHighlightColor(Color.CYAN);
chart.getStyler().setToolTipBorderColor(Color.BLACK);
chart.getStyler(). setToolTipBackgroundColor(Color.LIGHT_GRAY);
chart.getStyler().setToolTipType(Styler.ToolTipType.xAndYLabels);

A working example can be found at LineChart05.

Cursor

For the XYChart chart type, it is possible to add an interactive cursor on an XChartPanel via

chart.getStyler().setCursorEnabled(true);

The following example cursor options show which are available:

chart.getStyler().setCursorEnabled(true);
chart.getStyler().setCursorColor(Color.GREEN);
chart.getStyler().setCursorLineWidth(30f);
chart.getStyler().setCursorFont(new Font("Verdana", Font.BOLD, 12));
chart.getStyler().setCursorFontColor(Color.ORANGE);
chart.getStyler().setCursorBackgroundColor(Color.BLUE);
chart.getStyler().setCustomCursorXDataFormattingFunction(x -> "hello xvalue: " + x);
chart.getStyler().setCustomCursorYDataFormattingFunction(y -> "hello yvalue divided by 2: " + y / 2);

A working example can be found at LineChart09.

Chart Themes

XChart ships with three different themes: Default XChart, GGPlot2 and Matlab. Using a different theme is as simple as setting the Chart's theme with the theme method of the ChartBuilder.

XYChart chart = new XYChartBuilder().width(800).height(600).theme(ChartTheme.Matlab).build();

What's Next?

Now go ahead and study some more examples, download the thing and provide feedback.

Getting Started

Non-Maven

Download Jar: http://knowm.org/open-source/xchart/xchart-change-log

Maven

The XChart release artifacts are hosted on Maven Central.

Add the XChart library as a dependency to your pom.xml file:

    <dependency>
        <groupId>org.knowm.xchart</groupId>
        <artifactId>xchart</artifactId>
        <version>3.8.0</version>
    </dependency>

For snapshots, add the following to your pom.xml file:

    <repository>
      <id>sonatype-oss-snapshot</id>
      <snapshots/>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>

    <dependency>
      <groupId>org.knowm.xchart</groupId>
      <artifactId>xchart</artifactId>
      <version>3.8.1-SNAPSHOT</version>
    </dependency>

Snapshots can be manually downloaded from Sonatype: https://oss.sonatype.org/content/groups/public/org/knowm/xchart/xchart/

SBT

To use XChart with the Scala Build Tool (SBT) add the following to your build.sbt

libraryDependencies += "org.knowm.xchart" % "xchart" % "3.8.0" exclude("de.erichseifert.vectorgraphics2d", "VectorGraphics2D") withSources()

Building with Maven

general

mvn clean package  
mvn javadoc:aggregate  

Formatting

mvn com.coveo:fmt-maven-plugin:format

Formats your code using google-java-format which follows Google's code styleguide.

If you want your IDE to stick to the same format, check out the available configuration plugins:

Eclipse

Download google-java-format-eclipse-plugin_*.jar and place in /Applications/Eclipse Java.app/Contents/Eclipse/dropins. Restart Eclipse. Select the plugin in Preferences > Java > Code Style > Formatter > Formatter Implementation.

IntelliJ

In the plugins section in IntelliJ search for google-java-format and install the plugin. Restart IntelliJ.

Running Demo - option 1 - using released version

  • Linux: execute command java -cp xchart-demo-3.8.0.jar:xchart-3.8.0.jar org.knowm.xchart.demo.XChartDemo.

  • Windows: In the cmd command window, execute the command java -cp xchart-demo-3.8.0.jar;xchart-3.8.0.jar org.knowm.xchart.demo.XChartDemo; In the PowerShell command window, execute the command java -cp "xchart-demo-3.8.0.jar;xchart-3.8.0.jar" org.knowm.xchart.demo.XChartDemo.

E.g:

cd /path/to/xchart-demo/jar/
java -cp xchart-demo-3.8.0.jar:xchart-3.8.0.jar org.knowm.xchart.demo.XChartDemo

Running Demo - option 2 - building yourself

mvn install
mvn exec:java -Djava.awt.headless=false -pl xchart-demo -Dexec.mainClass=org.knowm.xchart.demo.XChartDemo

Running Demo - option 3 - with tweakable style properties

mvn install
mvn exec:java -Djava.awt.headless=false -pl xchart-demo -Dexec.mainClass=org.knowm.xchart.demo.XChartStyleDemo

Bugs

Please report any bugs or submit feature requests to XChart's Github issue tracker.

Continuous Integration

Build Status
Build History

Comments
  • Realtime chart about the X tick , why it can not to be smoothest, it will be getting bigger.

    Realtime chart about the X tick , why it can not to be smoothest, it will be getting bigger.

    the file path: package org.knowm.xchart.demo.charts.realtime; public class RealtimeChart06 implements ExampleChart, RealtimeExampleChart

    we test the demo case from the source, the first tick is from 01-02 ~01-04 the tickunit is 2, but at last it will be 01-14 ~01-19 the tickunit is 5.

    is there any solution for it?

    opened by jonehaipeng 21
  • Allow X and Y-Axis sizes to be not the same size

    Allow X and Y-Axis sizes to be not the same size

    e.g. sometimes i need such chart:

        Collection<Number> xData = new ArrayList<Number>();
        Collection<Number> yData = new ArrayList<Number>();
        for ( int i = 0; i < 10; i++ ){
            xData.add(i);
            yData.add(i*i);
        }
        xData.add(10);
        yData.add(null);
    
    opened by Stas0n 19
  • Add a JPanel inside a Chart like a LabelInfo?

    Add a JPanel inside a Chart like a LabelInfo?

    image Hello to every one! I'm using this Library to make my undergraduated thesis, but I need to create a PDF archieve to show this ( Image above this text is whats I got). but I need something like this image below. SomeOne can help me with that? image @Mr14huashao plis give me a help with that P.S: Sorry about my English.

    opened by henriquesmith 18
  • ggplot2 style API

    ggplot2 style API

    ggplot2 (http://ggplot2.org/) in R implements the graph API described in the book: grammar of graphics. It is then able to make complex plots in 2-3 lines of code.

    screenshot_1

    Have look at this video: https://www.youtube.com/watch?v=HeqHMM4ziXA

    You will then know why Its API style is now so popular and why people want it API style so much that they translate its API into python: http://blog.yhathq.com/posts/ggplot-for-python.html.

    ggplot2 is still using the basic plot functions in R, but just provides a very nice & concise API to describe figures. And it is the API style that makes it so popular.

    This makes think, why we do not like Jfreechart. Jfreechart is not bad and its 2d plotting ability is already relatively comprehensive. I now realize the main reason is not really its size (2m is not that big). It is because its complex API. You need to write so many code to plot a simple figure.

    That makes think, whether it is possible to write ggplot2 style API in java that unifies Jfreechart (2d) and jzy3d (3d). It may that the API is so nice and concise that people just use the new API instead of using JFreechart, or Jzy3d directly.

    I am not sure whether ggplot2 style API is really possible in Java. But I feel, if only aim for simplicity and forget all those rigid rules & styles in Java, a ggplot2 similar API might be possible.

    What do you think?

    Feature Request 
    opened by mleoking 16
  • ConcurrentModificationException

    ConcurrentModificationException

    My app containing xchart will get the ConcurrentModificationException (as in the stacktrace below) once every few hours or when the computer wakes up from sleep/hibernation. The graph is a live area-chart updated each second.

    Stacktrace:

    Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
        at java.util.ArrayList$Itr.next(Unknown Source)
        at com.xeiam.xchart.internal.chartpart.PlotContentLineChart.paint(PlotContentLineChart.java:117)
        at com.xeiam.xchart.internal.chartpart.Plot.paint(Plot.java:84)
        at com.xeiam.xchart.internal.chartpart.ChartPainter.paint(ChartPainter.java:111)
        at com.xeiam.xchart.internal.chartpart.ChartPainter.paint(ChartPainter.java:70)
        at com.xeiam.xchart.Chart.paint(Chart.java:94)
        at com.xeiam.xchart.XChartPanel.paintComponent(XChartPanel.java:89)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent._paintImmediately(Unknown Source)
        at javax.swing.JComponent.paintImmediately(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.access$1300(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$400(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    
    opened by seewip 15
  • 200 mBTC Bounty - Support Stacked Bar Charts

    200 mBTC Bounty - Support Stacked Bar Charts

    Hey Tim, thanks for the charting library! Looks great.

    It would be excellent to support Stacked Bar charts, like these

    https://developers.google.com/chart/interactive/docs/gallery/barchart#stacked-bar-charts

    Both as 100% stacked, and the absolute stacked.

    What do you think?

    Feature Request Bounty 
    opened by lucasgray 14
  • stick chart - how to increase the distance between the sticks

    stick chart - how to increase the distance between the sticks

    Hi, is there a way to control the distance between the stick so they will not be so close one to each other. if not supported yet, can you point to the class that should be enhanced.

    Thanks.

    Bug 
    opened by dluzzon 13
  • Ability to give line graph X values a string description

    Ability to give line graph X values a string description

    I think this is a feature request more than anything. I have a need to be able to provide String descriptions for points along the X graph, ideally not even showing the numbers.

    A couple thoughts on how to do this would be a possible type that extends Number, constructed with a numeric value, and a String which is gathered from .toString(). Then place those .toString() values on the X axis where they belong.

    In theory the same thing can be done with dates as well.

    Let me know your thoughts, if you have ideas on how this could be done easiest, if I have time I could provide a PR.

    opened by jentfoo 13
  • Is it possible to achieve transparent background in pie chart?

    Is it possible to achieve transparent background in pie chart?

    Hello. I've been trying to generate a piechart as an asset to my pdf template.

    I need it to be png with transparent background but I'm only getting black solid colour instead. image

    Maybe I'm missing some property or doing something wrong with my colour settings.

    Thanks!

    Here is my code :

    PieChart chart = new PieChartBuilder()
                    .width(200)
                    .height(200)
                    .theme(Styler.ChartTheme.GGPlot2)
                    .build();
    
            chart.getStyler().setLegendVisible(false);
    
            Color[] sliceColors = new Color[] {
                    new Color(238, 88, 88), //red
                    new Color(213, 122, 212), //purple
                    new Color(106,230, 182), //mentol
                    new Color(88,155,238) //baby blue
            };
    
            chart.getStyler().setSeriesColors(sliceColors);
            chart.getStyler().setChartTitleBoxVisible(false);
            chart.getStyler().setHasAnnotations(false);
            chart.getStyler().setChartBackgroundColor(
                    new Color(255,255, 255, 0)
            );
            chart.getStyler().setPlotBackgroundColor(
                    new Color(255,255, 255, 0)
            );
            chart.getStyler().setPlotBorderVisible(false);
    
            chart.addSeries("laptop", 65);
            chart.addSeries("pc", 10);
            chart.addSeries("tel", 12.5);
            chart.addSeries("winda", 12.5);
    
            BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapEncoder.BitmapFormat.PNG);
    
    Bug 
    opened by staho 12
  • How to ensure the tick showed as the real tick and there is no repeated tick value between first and second tick when start to draw line .

    How to ensure the tick showed as the real tick and there is no repeated tick value between first and second tick when start to draw line .

    when we use the realtime-type chart to start drawing line by using the data, and the first tick is 15:02:15 with next value is 15:02:16, between the two value there are some grid vertical line, and under the vertical line there will be repeated value like 15:02:15. but when time is later , about for 10s it will be normal. can you help to improve the issue. thanks a lot.

    opened by jonehaipeng 12
  • Vertical and horizontal grid lines are not visible inside the area chart

    Vertical and horizontal grid lines are not visible inside the area chart

    Awesome library, love it especially due to real-time features like .repaintChart().

    Is there a way to make the gridlines visible within the area chart? For now, grid lines are visible but they are in the background. Is it possible to achive something like this?

    image

    At present, it appears like this image

    I want my chart to show the gridlines in the background.

    I set the following properties to true but had no luck. Am I missing something? Thanks again!

    xyChart.getStyler().setPlotGridVerticalLinesVisible(true);
    xyChart.getStyler().setPlotGridHorizontalLinesVisible(true);
    
    opened by pwankhed 12
  • Bump graphics2d from 0.41 to 0.42

    Bump graphics2d from 0.41 to 0.42

    Bumps graphics2d from 0.41 to 0.42.

    Commits
    • dcd44e3 [maven-release-plugin] prepare release pdfboxgraphics2d-parent-0.42
    • f4914eb Prepare README for release
    • 6ce5ef8 #40: Correctly handle image interpolation and also respect this in the image ...
    • e5ab57d Upgrade to current batik version.
    • 2a9cb49 Upgrade PDFBox to current version.
    • 7cd93c7 #46: Also override drawRect() and
    • 1f801d8 #44: Fix the focial point for the
    • f3869e1 #44: Testcases for the wrong focial point.
    • 3846f16 [maven-release-plugin] prepare for next development iteration
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Annotation for Date axis

    Annotation for Date axis

    XYChart.addSeries() accepts a list of java.util.Date, but Annotation* constructor only accepts a double. I tried to convert Date to millis, but annotation is always rendered before the actual date. There's nothing similar in tests or examples, so could someone please tell me what is the proper way to calc annotation position for the Date axis type?

    Bug 
    opened by mkpaz 2
  • NullPointerException when xchart panel width is too small

    NullPointerException when xchart panel width is too small

    Hi, I am using XChartPanel<XYChart> to display a chart using its paint() method. This panel is put in a frame. However, when the frame width becomes too small (for instance by using the mouse to decrease the frame width), a NullPointerException will occur repeateadly.

    1

    2

    Here is the exception:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at org.knowm.xchart.internal.chartpart.PlotContent_XY.doPaint(PlotContent_XY.java:308)
    	at org.knowm.xchart.internal.chartpart.PlotContent_.paint(PlotContent_.java:62)
    	at org.knowm.xchart.internal.chartpart.Plot_.paint(Plot_.java:38)
    	at org.knowm.xchart.internal.chartpart.Plot_AxesChart.paint(Plot_AxesChart.java:35)
    	at org.knowm.xchart.XYChart.paint(XYChart.java:417)
    	at org.knowm.xchart.XChartPanel.paintComponent(XChartPanel.java:168)
    	at javax.swing.JComponent.paint(JComponent.java:1056)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5217)
    	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
    	at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
    	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
    	at javax.swing.JComponent.paint(JComponent.java:1042)
    	at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
    	at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)
    	at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)
    	at java.awt.Container.paint(Container.java:1978)
    	at java.awt.Window.paint(Window.java:3906)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:842)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    

    The min width at which the exception triggers depends on the amount of axis group which are displayed. The more axis group there are, the higher the min width is.

    I tested version 3.6.4, 3.6.6 and the latest 3.8.2. This bug appears on all 3 versions.

    opened by landret 2
  • Label of Last Bar in CategoryChart Not Visible

    Label of Last Bar in CategoryChart Not Visible

    When creating a CategoryChart with bar styling and visible labels, the label of the last bar in the series is not visible. This is a new bug introduced in the latest release of the library. The following code will demonstrate the issue:

            double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 };                                                                                                                            
            double[] yData = new double[] { 2.0, 1.5, 4.0, 3.77, 2.5 };                                                                                                                           
                                                                                                                                                                                                  
            // Create Chart                                                                                                                                                                       
            CategoryChartBuilder builder = new CategoryChartBuilder();                                                                                                                            
            builder.title("Sample Chart")                                                                                                                                                         
                .xAxisTitle("X")                                                                                                                                                                  
                .yAxisTitle("Y")                                                                                                                                                                  
                .theme(Styler.ChartTheme.Matlab);                                                                                                                                                 
            CategoryChart chart = builder.build();                                                                                                                                                
            // chart.getStyler().setYAxisMin(1.0);                                                                                                                                                
            chart.getStyler().setLabelsVisible(true);                                                                                                                                             
            //.setDefaultSeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Line).                                                                                                        
                                                                                                                                                                                                  
            chart.addSeries("y(x)", xData, yData);                                                                                                                                                
                                                                                                                                                                                                  
            // Show it                                                                                                                                                                            
            new SwingWrapper(chart).displayChart();
    

    I have looked into the issue myself and the error occurs because the final bar in the series is drawn twice, with the second rendering overwriting the label. This extra rendering occurs due to a call to closePath on line 510 of PlotContent_Category_Bar.java that should not occur. I can fix this issue for the above example by setting 'path = null;' on line 312 following the first rendering of the bar. I am not sure if this bug occurs in other permutations of the CategoryChart. If so, my fix likely does not address those bugs. I hope this helps. Thanks for the hard work on this library.

    opened by daniel-fontaine 1
  • Bump javafx-swing from 11.0.2 to 19

    Bump javafx-swing from 11.0.2 to 19

    Bumps javafx-swing from 11.0.2 to 19.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Owner
Knowm
Neuromemristive Artificial Intelligence
Knowm
The foundational library of the Morpheus data science framework

Introduction The Morpheus library is designed to facilitate the development of high performance analytical software involving large datasets for both

Zavtech Systems 226 Dec 20, 2022
A 3D chart library for Java applications (JavaFX, Swing or server-side).

Orson Charts (C)opyright 2013-2020, by Object Refinery Limited. All rights reserved. Version 2.0, 15 March 2020. Overview Orson Charts is a 3D chart l

David Gilbert 96 Sep 27, 2022
Java dataframe and visualization library

Tablesaw Overview Tablesaw is Java for data science. It includes a dataframe and a visualization library, as well as utilities for loading, transformi

Tablesaw 3.1k Jan 7, 2023
JGraphX - Library for visualizing (mainly Swing) and interacting with node-edge graphs.

JGraphX This project is end of life. We don't properly support Maven or publish to Maven Central. If that's an issue, use https://github.com/vlsi/jgra

JGraph 634 Jan 5, 2023
The Next Generation Logic Library

Introduction LogicNG is a Java Library for creating, manipulating and solving Boolean and Pseudo-Boolean formulas. It includes 100% Java implementatio

LogicNG 103 Nov 19, 2022
modular and modern graph-theory algorithms framework in Java

Erdos is a very light, modular and super easy to use modern Graph theoretic algorithms framework for Java. It contains graph algorithms that you can a

Erdos 111 Aug 14, 2022
The Mines Java Toolkit

The Mines Java Toolkit The Mines Java Toolkit (Mines JTK) is a set of Java packages and native (non-Java) software libraries for science and engineeri

Mines Java Toolkit 57 Nov 19, 2022
A Light-weight Job Scheduling Framework

Sundial A Lightweight Job Scheduling Framework for Java. In a Nutshell Sundial makes adding scheduled jobs to your Java application a walk in the park

Knowm 262 Dec 9, 2022
A Light-weight Job Scheduling Framework

Sundial A Lightweight Job Scheduling Framework for Java. In a Nutshell Sundial makes adding scheduled jobs to your Java application a walk in the park

Knowm 262 Dec 9, 2022
A light-weight and dynamic dependency injection framework

⚠️ This project is now part of the EE4J initiative. This repository has been archived as all activities are now happening in the corresponding Eclipse

Java EE 105 Dec 23, 2022
A fast, light and cloud native OAuth 2.0 authorization microservices based on light-4j

A fast, light weight and cloud native OAuth 2.0 Server based on microservices architecture built on top of light-4j and light-rest-4j frameworks. Stac

null 291 Dec 17, 2022
Table-Computing (Simplified as TC) is a distributed light weighted, high performance and low latency stream processing and data analysis framework. Milliseconds latency and 10+ times faster than Flink for complicated use cases.

Table-Computing Welcome to the Table-Computing GitHub. Table-Computing (Simplified as TC) is a distributed light weighted, high performance and low la

Alibaba 34 Oct 14, 2022
An android application to make students life easier by reducing their backpack weight.

Smart-Schooling An android application to make students life easier by reducing their backpack weight. Dont forget to ⭐ the repo Overview Almost every

Thamizh Kaniyan 3 Jan 31, 2022
A distributed data integration framework that simplifies common aspects of big data integration such as data ingestion, replication, organization and lifecycle management for both streaming and batch data ecosystems.

Apache Gobblin Apache Gobblin is a highly scalable data management solution for structured and byte-oriented data in heterogeneous data ecosystems. Ca

The Apache Software Foundation 2.1k Jan 4, 2023
A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.

ChartFx ChartFx is a scientific charting library developed at GSI for FAIR with focus on performance optimised real-time data visualisation at 25 Hz u

GSI CS-CO/ACO 386 Jan 2, 2023
A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.

ChartFx ChartFx is a scientific charting library developed at GSI for FAIR with focus on performance optimised real-time data visualisation at 25 Hz u

GSI CS-CO/ACO 385 Dec 30, 2022
Serialize at the speed of light.

Hyphen This serializer is highly inspired by ActiveJ and Kryo. It aims to bring insane serialization speed while being easy to use and maintainable. I

QuantumFusion 16 Dec 6, 2022
greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.

Check out ObjectBox Check out our new mobile database ObjectBox (GitHub repo). ObjectBox is a superfast object-oriented database with strong relation

Markus Junginger 12.6k Jan 5, 2023