{"id":13832067,"url":"https://github.com/knowm/XChart","last_synced_at":"2025-07-09T16:33:58.036Z","repository":{"id":539085,"uuid":"2078882","full_name":"knowm/XChart","owner":"knowm","description":"XChart is a light-weight Java library for plotting data.","archived":false,"fork":false,"pushed_at":"2024-08-28T12:35:12.000Z","size":14929,"stargazers_count":1511,"open_issues_count":146,"forks_count":396,"subscribers_count":74,"default_branch":"develop","last_synced_at":"2024-11-18T20:05:36.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://knowm.org/open-source/xchart","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knowm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-07-20T15:56:44.000Z","updated_at":"2024-11-18T15:31:27.000Z","dependencies_parsed_at":"2023-02-12T02:00:52.890Z","dependency_job_id":"fec04e18-a5fb-4218-97f5-dece86e60acd","html_url":"https://github.com/knowm/XChart","commit_stats":{"total_commits":1395,"total_committers":69,"mean_commits":"20.217391304347824","dds":0.5562724014336917,"last_synced_commit":"c118bb60de67b8db6537cb0d38709134359c6ff9"},"previous_names":["timmolter/xchart"],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowm%2FXChart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowm%2FXChart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowm%2FXChart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowm%2FXChart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knowm","download_url":"https://codeload.github.com/knowm/XChart/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225575183,"owners_count":17490714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T10:01:49.793Z","updated_at":"2024-11-20T14:30:27.705Z","avatar_url":"https://github.com/knowm.png","language":"Java","readme":"## [![XChart](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_64_64.png)](http://knowm.org/open-source/xchart) XChart\n\nXChart is a light-weight Java library for plotting data.\n\n## Description\n\nXChart 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\ncustomizing the chart style.\n\n## Simplest Example\n\nCreate a `XYChart` instance via `QuickChart`, add a series of data to it, and either display it or save it as a bitmap.\n\n```java\n\ndouble[] xData = new double[]{0.0, 1.0, 2.0};\ndouble[] yData = new double[]{2.0, 1.0, 0.0};\n\n// Create Chart\nXYChart chart = QuickChart.getChart(\"Sample Chart\", \"X\", \"Y\", \"y(x)\", xData, yData);\n\n// Show it\nnew SwingWrapper(chart).displayChart();\n\n// Save it\nBitmapEncoder.saveBitmap(chart, \"./Sample_Chart\",BitmapFormat.PNG);\n\n// or save it in high-res\nBitmapEncoder.saveBitmapWithDPI(chart, \"./Sample_Chart_300_DPI\",BitmapFormat.PNG, 300);\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Simplest.png)\n\n## Intermediate Example\n\nCreate a `XYChart` via a `XYChartBuilder`, style chart, add a series to it, style series, and display chart.\n\n```java\n\n// Create Chart\nXYChart chart = new XYChartBuilder().width(600).height(500).title(\"Gaussian Blobs\").xAxisTitle(\"X\").yAxisTitle(\"Y\").build();\n\n// Customize Chart\nchart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Scatter);\nchart.getStyler().setChartTitleVisible(false);\nchart.getStyler().setLegendPosition(LegendPosition.InsideSW);\nchart.getStyler().setMarkerSize(16);\n\n// Series\nchart.addSeries(\"Gaussian Blob 1\",getGaussian(1000, 1,10),getGaussian(1000,1,10));\nXYSeries series = chart.addSeries(\"Gaussian Blob 2\", getGaussian(1000, 1, 10), getGaussian(1000, 0, 5));\nseries.setMarker(SeriesMarkers.DIAMOND);\n\nnew SwingWrapper(chart).displayChart();\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Intermediate.png)\n\n## Advanced Example\n\nCreate a `XYChart` via a `XYChartBuilder`, style chart, add a series to it, add chart to `XChartPanel`, embed in Java Swing App, and display GUI.\n\n```java\n\n// Create Chart\nfinal XYChart chart = new XYChartBuilder().width(600).height(400).title(\"Area Chart\").xAxisTitle(\"X\").yAxisTitle(\"Y\").build();\n\n// Customize Chart\nchart.getStyler().setLegendPosition(LegendPosition.InsideNE);\nchart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);\n\n// Series\nchart.addSeries(\"a\",new double[] { 0, 3, 5, 7, 9},new double[]{-3,5,9,6,5});\nchart.addSeries(\"b\",new double[] { 0, 2, 4, 6, 9},new double[]{-1,6,4,0,4});\nchart.addSeries(\"c\",new double[] { 0, 1, 3, 8, 9},new double[]{-2,-1,1,0,1});\n\n// Schedule a job for the event-dispatching thread:\n// creating and showing this application's GUI.\n        javax.swing.SwingUtilities.\n\ninvokeLater(new Runnable() {\n\n    @Override\n    public void run () {\n\n        // Create and set up the window.\n        JFrame frame = new JFrame(\"Advanced Example\");\n        frame.setLayout(new BorderLayout());\n        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n\n        // chart\n        JPanel chartPanel = new XChartPanel\u003cXYChart\u003e(chart);\n        frame.add(chartPanel, BorderLayout.CENTER);\n\n        // label\n        JLabel label = new JLabel(\"Blah blah blah.\", SwingConstants.CENTER);\n        frame.add(label, BorderLayout.SOUTH);\n\n        // Display the window.\n        frame.pack();\n        frame.setVisible(true);\n    }\n});\n\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Advanced.png)\n\nTo 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\nrepaint.\n\n## Features\n\n* [x] No *required* additional dependencies\n* [x] Multiple Y-Axis charts\n* [x] Line charts\n* [x] Step charts\n* [x] Scatter charts\n* [x] Area charts\n* [x] Step Area charts\n* [x] Bar charts\n* [x] Histogram charts\n* [x] Pie charts\n* [x] Donut charts\n* [x] Bubble charts\n* [x] Stick charts\n* [x] Dial charts\n* [x] Radar charts\n* [x] OHLC charts\n* [x] Box charts\n* [x] Heat maps\n* [x] Error bars\n* [x] Logarithmic axes\n* [x] Number, Date, Bubble and Category X-Axis\n* [x] Multiple series\n* [x] Tool tips\n* [x] Extensive customization\n* [x] Themes - XChart, GGPlot2, Matlab\n* [x] Right-click, Save-As...\n* [x] User-defined axes range\n* [x] Definable legend placement\n* [x] CSV import and export\n* [x] High resolution chart export\n* [x] Export as PNG, JPG, BMP, GIF with custom DPI setting\n* [x] Export SVG, EPS using optional `de.erichseifert.vectorgraphics2d` library\n* [x] Export PDF using optional `pdfbox-graphics2d` library\n* [x] Real-time charts\n* [x] Java 8 and up\n\n## Chart Types\n\nCurrently, there are 5 major chart types. Each type has its corresponding `ChartBuilder`, `Styler` and `Series`.\n\n| Chart Type    | Builder              | Styler         | Series         | Allowed Data Types   | Default Series Render Style |\n|---------------|----------------------|----------------|----------------|----------------------|-----------------------------|\n| XYChart       | XYChartBuilder       | XYStyler       | XYSeries       | Number, Date         | Line                        |\n| CategoryChart | CategoryChartBuilder | CategoryStyler | CategorySeries | Number, Date, String | Bar                         |\n| PieChart      | PieChartBuilder      | PieStyler      | PieSeries      | String               | Pie                         |\n| BubbleChart   | BubbleChartBuilder   | BubbleStyler   | BubbleSeries   | Number, Date         | Round                       |\n| DialChart     | DialChartBuilder     | DialStyler     | DialSeries     | double               | Round                       |\n| RadarChart    | RadarChartBuilder    | RadarStyler    | RadarSeries    | double[]             | Round                       |\n| OHLCChart     | OHLCChartBuilder     | OHLCStyler     | OHLCSeries     | OHLC with Date       | Candle                      |\n| BoxChart      | BoxChartBuilder      | BoxStyler      | BoxSeries      | Number, Date, String | Box                         |\n| HeatMapChart  | HeatMapChartBuilder  | HeatMapStyler  | HeatMapSeries  | Number, Date, String | --                          |\n\nThe different Stylers contain chart styling methods specific to the corresponding chart type as well as common styling methods common across all chart types.\n\n### XYChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_XYChart.png)\n\n`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\nof the data in evenly-spaced intervals.\n\nSeries render styles include: `Line`, `Scatter`, `Area`, `Step` and `StepArea`.\n\n### CategoryChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_CategoryChart.png)\n\n`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.\n\nSeries render styles include: `Bar`, `Line`, `Scatter`, `Area` and `Stick`.\n\n### PieChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_PieChart.png)\n\n`PieChart` charts take String data types for the pie slice name and Number data types for the pie slice value.\n\nSeries render styles include: `Pie` and `Donut`.\n\n### BubbleChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Bubble_Chart.png)\n\n`BubbleChart` charts take Date or Number data types for the X-Axis and Number data types for the Y-Axis and bubble sizes.\n\nSeries render styles include: `Round` and in the near future `Square`.\n\n### DialChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Dial_Chart.png)\n\n`DialChart` charts take a `double` to set the position of the dial pointer and a `String` to set the label. Extensive customization is possible.\n\n### RadarChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Radar_Chart.png)\n\n`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\nlabels, if displayed, are set by passing a `String[]`.\n\nRadar chart render styles are: `Polygon` or `Circle`.\n\n### OHLCChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_OHLC.png)\n\n`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\ndata in evenly-spaced intervals.\n\nSeries render styles include: `Candle`, `HiLo`.\n\n### BoxChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_BoxChart.png)\n\n`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.\nCreate a BoxChart via a BoxChartBuilder, style chart, add a series to it.\n\n```java\n// Create Chart\nBoxChart chart =\n        new BoxChartBuilder().title(\"box plot demo\").build();\n\n// Choose a calculation method\nchart.getStyler().setBoxplotCalCulationMethod(BoxplotCalCulationMethod.N_LESS_1_PLUS_1);\nchart.getStyler().setToolTipsEnabled(true);\n\n// Series\nchart.addSeries(\"boxOne\",Arrays.asList(1,2,3,4));\nnew SwingWrapper\u003cBoxChart\u003e(chart).displayChart();\n```\n\nFour calculation methods for boxplots:\n\n- \"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.\n  Calculate the corresponding quartile based on location.\n- \"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.\n  Calculate the corresponding quartile based on location.\n- \"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.\n  If np is not an integer, Qi = X [np + 1];\n  If np is an integer, Qi = (X [np] + X [np + 1]) / 2.\n- \"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.\n  Calculate the corresponding quartile based on location.\n\nInterquartile range, IQR = Q3-Q1.\n\nUpper 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.\n\nLower 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.\n\nE.g:\n\nAn example of a set of sequence numbers: 12, 15, 17, 19, 20, 23, 25, 28, 30, 33, 34, 35, 36, 37\n\n- \"N_PLUS_1\":\n  Q1's position = (14 + 1) /4=3.75,\n  Q1 = 0.25 × third term + 0.75 × fourth term = 0.25 × 17 + 0.75 × 19 = 18.5;\n- \"N_LESS_1\":\n  Q1's location = (14-1) /4=3.25,\n  Q1 = 0.75 × third term + 0.25 × fourth term = 0.75 × 17 + 0.25 × 19 = 17.5;\n- \"NP\":\n  Q1's position = 14 * 0.25 = 3.5,\n  Q1 = 19;\n- \"N_LESS_1_PLUS_1\":\n  Q1's location = (14-1) / 4 + 1 = 4.25\n  Q1 = 0.75 × the fourth term + 0.25 × the fifth term = 0.75 × 19 + 0.25 × 20 = 19.25.\n\n### HeatMapChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_HeatMap.png)\n\n`HeatMapChart` take Date, Number or String data types for the X-Axis, Y-Axis.\n\n## Real-time Java Charts using XChart\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_SimpleRealtime.gif)\n\nCreating 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\nthe chart. This works for all chart types including `XYChart`, `CategoryChart`, `BubbleChart` and `PieChart`, for which example source code can be\nfound [here](https://github.com/knowm/XChart/tree/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/realtime). Examples demonstrate using the `SwingWrapper`\nwith `repaintChart()` method as well as `XChartPanel` with `revalidate()` and `repaint()`.\n\nThe following sample code used to generate the above real-time chart can be\nfound [here](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/standalone/readme/SimpleRealTime.java).\n\n```java\npublic class SimpleRealTime {\n\n    public static void main(String[] args) throws Exception {\n\n        double phase = 0;\n        double[][] initdata = getSineData(phase);\n\n        // Create Chart\n        final XYChart chart = QuickChart.getChart(\"Simple XChart Real-time Demo\", \"Radians\", \"Sine\", \"sine\", initdata[0], initdata[1]);\n\n        // Show it\n        final SwingWrapper\u003cXYChart\u003e sw = new SwingWrapper\u003cXYChart\u003e(chart);\n        sw.displayChart();\n\n        while (true) {\n\n            phase += 2 * Math.PI * 2 / 20.0;\n\n            Thread.sleep(100);\n\n            final double[][] data = getSineData(phase);\n\n            javax.swing.SwingUtilities.invokeLater(new Runnable() {\n\n                @Override\n                public void run() {\n\n                    chart.updateXYSeries(\"sine\", data[0], data[1], null);\n                    sw.repaintChart();\n                }\n            });\n        }\n\n    }\n\n    private static double[][] getSineData(double phase) {\n\n        double[] xData = new double[100];\n        double[] yData = new double[100];\n        for (int i = 0; i \u003c xData.length; i++) {\n            double radians = phase + (2 * Math.PI / xData.length * i);\n            xData[i] = radians;\n            yData[i] = Math.sin(radians);\n        }\n        return new double[][]{xData, yData};\n    }\n}\n```\n\n## Chart Customization\n\nAll 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\noptions 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\nthat one customization you're looking for - it's all right in one spot!\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Chart_Customization.png)\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Series_Customization.png)\n\n### Customizing Axis Tick Labels\n\nXChart automatically creates axis tick labels for chart types with axes.\n\nDefault axis tick placement can be altered with `chart.getStyler().setXAxisTickMarkSpacingHint(spacingHint);`.\n\nDefault axis label labels can be altered with one of:\n\n```java\nchart.getStyler().setDatePattern(datePattern)\nchart.getStyler().setXAxisDecimalPattern(pattern);\nchart.getStyler().setYAxisDecimalPattern(pattern);\n```\n\nYou can also create custom axis tick labels with a callback function. In the following example taken\nfrom [DateChart09](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart09.java), the X-Axis tick labels are generated\nvia a custom lambda function which takes the numerical (double) tick label values and converts them to a `String`.\n\n```java\n// set custom X-Axis tick labels\nLocalDateTime startTime = LocalDateTime.of(2001, Month.JANUARY, 1, 0, 0, 0);\nDateTimeFormatter xTickFormatter = DateTimeFormatter.ofPattern(\"LLL\");\nchart.getStyler().setxAxisTickLabelsFormattingFunction(x -\u003estartTime.plusDays(x.longValue()).format(xTickFormatter));\n```\n\nIn the following example taken from [DateChart06](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart06.java), the\nY-Axis tick labels are converted\nto the englich word reprentation of the numbers.\n\n```java\nchart.getStyler().setyAxisTickLabelsFormattingFunction(x -\u003eNumberWordConverter.convert(x.intValue()));\n```\n\n### Multiple Axes\n\nXChart 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\naccording to the series on this axis only.\nTo set the y group:\n\n```java\nseries.setYAxisGroup(axisGroup);   \n```\n\nTo manually change max/min of axis group:\n\n```java\n((AxesChartStyler)chart.getStyler()).setYAxisMax(axisGroup, 200.0);\n```\n\nAxis can be drawn on the left (default) or on the right of the chart:\n\n```java\nchart.getStyler().setYAxisGroupPosition(axisGroup, Styler.YAxisPosition.Right);\n```\n\nTo set the Y axes titles:\n\n```java\nchart.setYAxisGroupTitle(0,\"A\");\nchart.setYAxisGroupTitle(1,\"B\");\n```\n\n### Zooming In\n\nFor 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\ndouble-clicking on the chart or by clicking on the \"reset\" button, which can be posotioned as desired.\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Zoom.png)\n\nThe following example zoom style options show which are available:\n\n```java\nchart.getStyler().setZoomEnabled(true);\nchart.getStyler().setZoomResetButtomPosition(Styler.CardinalPosition.InsideS);\nchart.getStyler().setZoomResetByDoubleClick(false);\nchart.getStyler().setZoomResetByButton(true);\nchart.getStyler().setZoomSelectionColor(new Color(0,0,192,128));\n```\n\nA working example can be found at [DateChart01](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart01.java).\n\n### Chart Annotations\n\nFor all chart types, one or more chart annotations can be super-imposed on top of the chart. The following types of annotatins are available:\n\n- AnnotationLine\n- AnnotationImage\n- AnnotationText\n- AnnotationTextPanel\n\nThe following is a chart with four `AnnotationLine`s, one `AnnotationImage` and one `AnnotationText`:\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_AnnotationLineImageText.png)\n\nPositioning is relative to the bottom-left corner of the chart and to the center of the `AnnotationImage` or `AnnotationText`.\n\nThe following example `AnnotationLine` and `AnnotationText` styling parameters show which are available:\n\n```java\nchart.getStyler().setAnnotationLineColor(Color.GREEN);\nchart.getStyler().setAnnotationLineStroke(new BasicStroke(3.0f));\nchart.getStyler().setAnnotationTextFont(new Font(Font.MONOSPACED, Font.ITALIC, 8));\nchart.getStyler().setAnnotationTextFontColor(Color.BLUE);\n```\n\nA working example can be found at [LineChart10](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart10.java).\n\nThe following is a chart with three `AnnotationTextPanel`s:\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_AnnotationTextPanel.png)\n\nPositioning is relative to the bottom-left corner of the chart and to the bottom-left corner of the `AnnotationTextPanel`.\n\nThe following example `AnnotationTextPanel` styling parameters show which are available:\n\n```java\nchart.getStyler().setAnnotationTextPanelPadding(20);\nchart.getStyler().setAnnotationTextPanelFont(new Font(\"Verdana\", Font.BOLD, 12));\nchart.getStyler().setAnnotationTextPanelBackgroundColor(Color.RED);\nchart.getStyler().setAnnotationTextPanelBorderColor(Color.BLUE);\nchart.getStyler().setAnnotationTextPanelFontColor(Color.GREEN);\n```\n\nA working example can be found at [ScatterChart04](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart04.java).\n\n### Tool Tips\n\nFor all chart types, tool tips can be activated on an `XChartPanel` via\n\n```java\nchart.getStyler().setToolTipsEnabled(true);\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Tooltips.png)\n\nThe following example tooltip options show which are available:\n\n```java\nchart.getStyler().setToolTipsEnabled(true);\nchart.getStyler().setToolTipsAlwaysVisible(true);\nchart.getStyler().setToolTipFont( new Font(\"Verdana\", Font.BOLD, 12));\nchart.getStyler().setToolTipHighlightColor(Color.CYAN);\nchart.getStyler().setToolTipBorderColor(Color.BLACK);\nchart.getStyler().setToolTipBackgroundColor(Color.LIGHT_GRAY);\nchart.getStyler().setToolTipType(Styler.ToolTipType.xAndYLabels);\n```\n\nA working example can be found at [LineChart05](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart05.java).\n\n### Cursor\n\nFor the `XYChart` chart type, it is possible to add an interactive cursor on an `XChartPanel` via\n\n```java\nchart.getStyler().setCursorEnabled(true);\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Cursor.png)\n\nThe following example cursor options show which are available:\n\n```java\nchart.getStyler().setCursorEnabled(true);\nchart.getStyler().setCursorColor(Color.GREEN);\nchart.getStyler().setCursorLineWidth(30f);\nchart.getStyler().setCursorFont(new Font(\"Verdana\", Font.BOLD, 12));\nchart.getStyler().setCursorFontColor(Color.ORANGE);\nchart.getStyler().setCursorBackgroundColor(Color.BLUE);\nchart.getStyler().setCustomCursorXDataFormattingFunction(x -\u003e\"hello xvalue: \"+x);\nchart.getStyler().setCustomCursorYDataFormattingFunction(y -\u003e\"hello yvalue divided by 2: \"+y /2);\n```\n\nA working example can be found at [LineChart09](https://github.com/knowm/XChart/blob/develop/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart09.java).\n\n## Chart Themes\n\nXChart 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\nthe `ChartBuilder`.\n\n    XYChart chart = new XYChartBuilder().width(800).height(600).theme(ChartTheme.Matlab).build();\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Themes.png)\n\n## What's Next?\n\nNow go ahead and [study some more examples](http://knowm.org/open-source/xchart/xchart-example-code/), [download the thing](http://knowm.org/open-source/xchart/xchart-change-log)\nand [provide feedback](https://github.com/knowm/XChart/issues).\n\n## Getting Started\n\n### Non-Maven\n\nDownload Jar: http://knowm.org/open-source/xchart/xchart-change-log\n\n### Maven\n\nThe XChart release artifacts are hosted on Maven Central.\n\nAdd the XChart library as a dependency to your pom.xml file:\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.knowm.xchart\u003c/groupId\u003e\n    \u003cartifactId\u003exchart\u003c/artifactId\u003e\n    \u003cversion\u003e3.8.8\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nFor snapshots, add the following to your pom.xml file:\n\n```xml\n\n\u003crepository\u003e\n    \u003cid\u003esonatype-oss-snapshot\u003c/id\u003e\n    \u003csnapshots/\u003e\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n\u003c/repository\u003e\n\n\u003cdependency\u003e\n\u003cgroupId\u003eorg.knowm.xchart\u003c/groupId\u003e\n\u003cartifactId\u003exchart\u003c/artifactId\u003e\n\u003cversion\u003e3.8.9-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nSnapshots can be manually downloaded from\nSonatype: [https://oss.sonatype.org/content/groups/public/org/knowm/xchart/xchart/](https://oss.sonatype.org/content/groups/public/org/knowm/xchart/xchart/)\n\n### SBT\n\nTo use XChart with the Scala Build Tool (SBT) add the following to your build.sbt\n\n```scala\nlibraryDependencies += \"org.knowm.xchart\" % \"xchart\" % \"3.8.8\" exclude(\"de.erichseifert.vectorgraphics2d\", \"VectorGraphics2D\") withSources()\n```\n\n## Building with Maven\n\n Instruction                  | Command                                       \n------------------------------|----------------------------------------------- \n run unit tests               | `mvn clean test`                              \n package jar                  | `mvn clean package`                           \n install in local Maven repo  | `mvn clean install`                           \n create project javadocs      | `mvn javadoc:aggregate`                       \n generate dependency tree     | `mvn dependency:tree`                         \n check for dependency updates | `mvn versions:display-dependency-updates`     \n check for plugin updates     | `mvn versions:display-plugin-updates`         \n code format                  | `mvn com.spotify.fmt:fmt-maven-plugin:format` \n\nFormats your code using [google-java-format](https://github.com/google/google-java-format) which\nfollows [Google's code styleguide](https://google.github.io/styleguide/javaguide.html).\n\nIf you want your IDE to stick to the same format, check out the available configuration plugins:\n\n#### Eclipse\n\nDownload [`google-java-format-eclipse-plugin_*.jar`](https://github.com/google/google-java-format/releases) and place in `/Applications/Eclipse Java.app/Contents/Eclipse/dropins`.\nRestart Eclipse. Select the plugin in `Preferences \u003e Java \u003e Code Style \u003e Formatter \u003e Formatter Implementation`.\n\n#### IntelliJ\n\nIn the plugins section in IntelliJ search for `google-java-format` and install the plugin. Restart IntelliJ.\n\n## Running Demo - option 1 - using released version\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChart_Demo.png)\n\n- Linux: execute command `java -cp xchart-demo-3.8.8.jar:xchart-3.8.8.jar org.knowm.xchart.demo.XChartDemo`.\n\n- Windows: In the cmd command window, execute the command `java -cp xchart-demo-3.8.8.jar;xchart-3.8.8.jar org.knowm.xchart.demo.XChartDemo`; In\n  the PowerShell command window, execute the command `java -cp \"xchart-demo-3.8.8.jar;xchart-3.8.8.jar\" org.knowm.xchart.demo.XChartDemo`.\n\nE.g:\n\n```sh\ncd /path/to/xchart-demo/jar/\njava -cp xchart-demo-3.8.8.jar:xchart-3.8.8.jar org.knowm.xchart.demo.XChartDemo\n```\n\n## Running Demo - option 2 - building yourself\n\n```sh\nmvn install\nmvn exec:java -Djava.awt.headless=false -pl xchart-demo -Dexec.mainClass=org.knowm.xchart.demo.XChartDemo\n```\n\n## Running Demo - option 3 - with tweakable style properties\n\n```sh\nmvn install\nmvn exec:java -Djava.awt.headless=false -pl xchart-demo -Dexec.mainClass=org.knowm.xchart.demo.XChartStyleDemo\n```\n\n![](https://raw.githubusercontent.com/knowm/XChart/develop/etc/XChartStyleDemo.png)\n\n## Bugs\n\nPlease report any bugs or submit feature requests to [XChart's Github issue tracker](https://github.com/knowm/XChart/issues).\n\n## Continuous Integration\n\n* [![Java CI with Maven on Push](https://github.com/knowm/XChart/actions/workflows/maven_on_push.yml/badge.svg)](https://github.com/knowm/XChart/actions/workflows/maven_on_push.yml)\n* [Build History](https://github.com/knowm/XChart/actions)  \n\n","funding_links":[],"categories":["Projects","Java","项目","Solutions"],"sub_categories":["Science","科学"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowm%2FXChart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknowm%2FXChart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowm%2FXChart/lists"}