jfreechart

Why does a Latin-characters-only Java font claim to support Asian characters, even though it does not?

天涯浪子 提交于 2019-11-28 11:22:07
When rendering a chart with JFreeChart, I noticed a layout problem when the chart's category labels included Japanese characters. Although the text is rendered with the correct glyphs, the text was positioned in the wrong location, presumably because the font metrics were wrong. The chart was originally configured to use the Source Sans Pro Regular font for that text, which supports only Latin character sets. The obvious solution is to bundle an actual Japanese .TTF font and ask JFreeChart to use it. This works fine, in that the output text uses the correct glyphs and it is also laid out

JFreeChart format Y-axis to show values in Power

断了今生、忘了曾经 提交于 2019-11-28 11:03:35
问题 How to format y-axis to show values as 5*10^5, 1*10^6, 2*10^6... instead of 500,000,1,000,000, 2,000,000... and which are divisible by 5 or 10? 回答1: A LogAxis with the default tick units seems to work. This related example uses integer tick units. import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.LogAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree

Using Multiple Renderers in JFreechart

让人想犯罪 __ 提交于 2019-11-28 11:02:36
问题 I have data that I'd like to represent as a box and whiskers graph, and have set up a category plot to do so. However, in addition, I'd like to add a line chart that shows an accumulation of the averages for each data point. Right now my code is something like this DefaultBoxAndWhiskerCategoryDataset dataSet = new DefaultBoxAndWhiskerCategoryDataset(); int i = 0; for (List<Integer> categoryList : categoryLists) { dataSet.add(categoryList, i, "BoxAndWhiskers"); i++; } BoxAndWhiskerRenderer

StackedBarChart row key is not added to DefaultCategoryDataSet

佐手、 提交于 2019-11-28 11:00:21
问题 I have two entity Classes: A and B. A has B entities, and I have a Map defined in the following format: Map<A, List<B> . I want to add all map data to DefaultCategoryDataset with following code. For example, if have 5 A and each A has 4 B, I want to have 25 row keys. (A entity number * (A entityNumber + B entity number in each A). A Row key that stores A class must be same width; all other rows that store B entities must have same width. To succeed in this, I am giving the same values while

JFreeChart's Bar Chart Bar Unit

Deadly 提交于 2019-11-28 10:42:11
问题 I'm trying to create a bar chart in Java. I'd like to have 1H bar unit on the DateAxis (not tick unit). Is there a way? After a lot of google search, I haven't found anything interesting about this. This is what I get: ChartAdapter.java public class ChartAdapter extends JFrame { /** * Constructs the demo application. * * @param title the frame title. */ public ChartPanel generateChart(String title, Vector<Vector<String>> dataVector) { JFreeChart chart = ChartFactory.createXYBarChart( title,

JFreeChart different colors in different regions for the same dataSeries

会有一股神秘感。 提交于 2019-11-28 10:30:23
In JFreeChart I'm trying to color different regions of an XY line chart/curve based on y value. I'm overriding the XYLineAndShapeRenderer 's getItemPaint(int row, int col) , however I'm not sure how it handles the coloring of the line between the x s since it's only getting itemPaint on the x (integer values). final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override @Override public Paint getItemPaint(int row, int col) { System.out.println(col+","+dataset.getY(row, col)); double y=dataset.getYValue(row, col); if(y<=3)return ColorUtil.hex2Rgb("#7DD2F7"); if(y<=4)return

How to determine min and max value for ItemMargin property in StackedBarChart using jFreeChart

安稳与你 提交于 2019-11-28 10:26:50
问题 I am using jFreeChart api to make one application such that on movement of slider the gap width in between the two bars gets increased or decreased according to the value of the slider. But I found with different charts and different data item margin property get varied. To demonstrate the problem I am attaching the following code:- import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax

Align bars with bar labels in Jfreechart

巧了我就是萌 提交于 2019-11-28 10:01:40
问题 I have a problem with data labels to align with correct bar in this chart. This bar chart is generated using jfreechart in jsp. 回答1: This is a pretty common mistake in JFreeChart. Each category in your chart ('abc', 'xyz' etc) has a value for each of the 6 series ('q1', 'q2' ... 'q6'), so there are 36 data items in all. But 30 of those data items are null, because you didn't specify them. JFreeChart leaves a space where the bar would appear, when the data value is null. If you really have

JFreeChart connect one point to all other around

只谈情不闲聊 提交于 2019-11-28 09:55:06
问题 is it possible to connect one point to all others around in JFreeChart here how it should looks so all the points around connected to X point chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); Shape cross = ShapeUtilities.createDiagonalCross(3, 1); Shape somehing = ShapeUtilities.createDiamond(4); final XYLineAndShapeRenderer renderer = new

Points on a line in jfreechart

ぐ巨炮叔叔 提交于 2019-11-28 09:48:32
问题 How to get all the points (x,y) lying on the line connecting two data-points in a chart in jfreechart ?. In a chart, as we point to the end-points of the line, it shows the x & y coordinates. Can't we get the coordinates at any point on the line (via code)? 回答1: As you have two points, use the formulae of a linear equation to obtain the slope and intercept of the line. Once you have the equation, you can evaluate it at any point. Addendum: The org.jfree.data.statistics.Regression class offers