jfreechart

JFreeChart line chart with text at each point

◇◆丶佛笑我妖孽 提交于 2019-11-26 13:50:57
I would like put text over each point I plotted in a line chart. This is what I can do: And this is what I need (names of point are in green): The StandardXYItemLabelGenerator should work; there's an example here . Addendum: The labels you can see in the picture are in a separate string array. Such labels may be incorporated in the XYDataset , as shown in LabeledXYDataset below. Because none of the features of StandardXYItemLabelGenerator are used, a custom implementation of XYItemLabelGenerator is sufficient. The XYItemRenderer controls the color, size and relative position of the labels.

Choose the series of data that you want to display

三世轮回 提交于 2019-11-26 12:48:22
问题 I have a plot with multiple series of data: I want to be able to pick the series that I want to display. For example, only the 0° and 20° ones. Is there a simple way to do this by manipulating the chart without using JCheckBox ? I want to be able to do this, for example, by clicking on the legend of the series. 回答1: As shown here, JCheckBox is more flexible, but clicking directly on the chart may be more convenient. The example below adds a ChartMouseListener that makes a series invisible

How to display legend for Pie Chart in columns?

家住魔仙堡 提交于 2019-11-26 12:32:47
I have a PieChart with many sections, legend for this PieChart renders as one row. How to render legend as two columns? trashgod The method getLegendItem() , seen here , provides all the information needed to render a legend item in any Container you choose. GridLayout(0, 2) will arrange them in two columns for any number of rows. To suppress the existing legend, set legend to false when you call your chart factory; the items will still be available, as suggested here . Addendum: Based on PieChartDemo1 , this fragment uses the getLegendItems().iterator and a variation of this ColorIcon .

Code for changing the color of subtasks in Gantt Chart

断了今生、忘了曾经 提交于 2019-11-26 11:56:23
I need to change the color of subtasks in a Gantt chart . My example is based on GanttDemo2 with the following dataset and renderer. In different forums I found some discussions related to this topic, but I did not find a clear simple working example. In particular, I can change the color of tasks, but I don't know how to extract subtasks. private IntervalCategoryDataset createSampleDataset() { final TaskSeries s1 = new TaskSeries("Scheduled"); final Task t1 = new Task( "Design", date(1, Calendar.APRIL, 2001), date(1, Calendar.MAY, 2001)); t1.addSubtask(new Task("Design 1", date(1, Calendar

JFreeChart create tooltip in ChartPanel

こ雲淡風輕ζ 提交于 2019-11-26 11:41:00
问题 How can I generate a tooltip on chart mouse over in JFreeChart ? I tried this: chartPanel.setToolTipText(\"this is the string\"); but this does not work. Am I supposed to do something else before? Something like this: chartPanel.createToolTip(). I am calling these methods in the chartMouseMoved event. 回答1: Most ChartFactory methods include a boolean tooltips parameter. Just look in the source for your factory of choice to see how to instantiate a default tooltip generator suitable for the

Prevent JFreeChart DialPlot wrapping around with large values?

落花浮王杯 提交于 2019-11-26 11:40:58
问题 My data value can vary between 0-100. I would like to display a JFreeChart DialPlot showing the range 0-30, where values larger than 30 are displayed by having the needle fixed at 30 but the true value displayed on the dial. The image below shows what my example code currently produces: Current Output Here I am displaying the value 50. The dial has wrapped around to point at 14. I would prefer it to be set to the maximum (30), much like with a fuel dial: Desired Output Is this possible with

Resize Vertical Tick Label Height (XYStepChart)

て烟熏妆下的殇ゞ 提交于 2019-11-26 11:39:51
问题 I\'ve got the following chart made with JFreeChart: Is it possible (and if it is how) to extend the dates on the x-axis so that they contain the year, eg. 4-II-2010, 5-II-2010, ..., 6-III-2010? 回答1: It's not clear how you are formatting the dates now, but setDateFormatOverride in DateAxis allows you to specify a suitable SimpleDateFormat. If not already available, you should be able to override getShortMonths() in DateFormatSymbols for the Roman numerals. Addendum: For correct localization,

JFreeChart - Problem in creating moving chart

孤街浪徒 提交于 2019-11-26 11:33:31
问题 I am using JFreeChart in my java application. Problem I want to plot a XYAreaChart whose domain axis (x-axis) should scroll horizontally automatically when we start plotting the data. I saw the same thing in TimeSeriesCharts but I don\'t want any timeSeriesChart. I just want the scrolling x-axis. 回答1: You'll need to create your own SlidingXYDataset that implements XYDataset in a manner similar to how SlidingCategoryDataset implements CategoryDataset . Addendum: As noted in a comment, a

Displaying a histogram of image data

若如初见. 提交于 2019-11-26 11:24:53
I sometimes need to display a representation of image data in the form of a histogram . I'm especially interested in ways to access the image data. I'm familiar with JFreeChart , which includes histogram support, but I'd consider other approaches. trashgod The example below uses several techniques to create an RGB histogram of an arbitrary image: The Raster method getSamples() extracts the values of each color band from the BufferedImage . The HistogramDataset method addSeries() adds each band's counts to the dataset . A StandardXYBarPainter replaces the ChartFactory default, as shown here . A

JFreeChart BarChart -> NO gradient

北慕城南 提交于 2019-11-26 11:20:42
问题 my bar chart is always drawn with a gradient color by default. I just want a simple color without any styled effects . Can anyone help ? Code: final JFreeChart chart = ChartFactory.createBarChart( \"\", // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); final CategoryPlot plot = chart.getCategoryPlot(); // SOMETHING HAS TO BE DONE HERE showChart(chart);