Hi i am new to jfreechart.
I want to remove the space allocated for title of the linechart's chartpanel in jfreechart.
Because I need to set height and width of chartpanel with the border of 10 pixels of the top panel which holds the chartpanel.
Pls help me..
Thanks in advance..
In the above graph I mentioned that at the top of the graph (title space) should be removed.so that i dont want to leave any space there.
If I did not give any title , it takes that space to display that graph.
Assign empty string to title parameter in Create******Chart() function.
Fox example:
final JFreeChart result = ChartFactory.createTimeSeriesChart(
"", //Empty title
"Time",
"Value",
dataset,
true,
true,
false
);
Related
Still on my sidemenu from there, I've resolve the non broking text with a custom function that modify the text.
Now I'm stuck with the width of the component. I've change it from a SpanLabel to a TextArea in order to have more control on it's behaviour, but here is my problem: the TextArea width is too large as shown on the screenshot (put a ContentContainer UIID on to see the space occupied by the TextArea).
As you can see, the first component has a too large TextArea. I've set the column count of the TextArea to the length of the firstRow + 1, but it doesn't seem to take it in account.
The component is BorderLayout with a non grow center ScaleImageLabel and the TextArea on south. Is it a way to have a better width for the TextArea ? I would have it aligned with the image and with the area wrapped close to the text, but I really don't know how to achieve this...
Thanks in advance !
My suggestion is to use GridLayout for equal sizes or TableLayout with constraints for varying sizes for left and right components. It will prevent the TextArea from growing beyond a limit.
An example will be:
//GridLayout
Container cont = GridLayout.encloseIn(4, cmpL1, cmpR1, cmpL2, cmpR2)
//OR
//TableLayout with Constraint
TableLayout tl = new TableLayout(2, 2);
Container cont = new Container(tl);
cont.add(tl.createConstraint().widthPercentage(50), cmpL1);
cont.add(tl.createConstraint().widthPercentage(50), cmpR1);
cont.add(cmpL2);
cont.add(cmpR2);
If I do that :
Label lbl = new Label("My Label");
Form f = new Form("Test");
BorderLayout bl = new BorderLayout();
f.setLayout(bl);
f.add(BorderLayout.CENTER, lbl);
f.show();
Label lbl is well centered in my form (horizontally and vertically).
If you replace lbl instance with SpanLabel, it's not centered at all.
Is it normal ? If so, how to centered it ?
Thanks!
Multiline text needs to behave differently from single line text as it's non-deterministic. It calculates its size based on columns and not the real content.
I wrote about the challenges of this a while back here: https://www.codenameone.com/blog/the-challenge-of-multiline-strings.html
I am developing a javaEE application using jfreecharts. I successfully displayed my data using a stackedBarChart but the column keys (Y-axis labels) are not fully displayed because they are too large. how can I display them vertically? thanks for your suggestions
You can use setCategoryLabelPositions() like they show here.
CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90));
Hello how can I remove a series from a chart, I know that I can get the series object using getAt(0) or getAt(1) depending on how many serieses I got in my chart.
my question is how can I remove a series from the chart.
main reason is that I give the end user the ability to change the series type: bar, line... so I wan to display the new change at run time by removing the series and adding a new one.
I tried Chart.series.removeAt(0); It removes the legend but the bar or the line still shown !!
I use extjs 4.1.1
thank you,
I had to do the same thing and give end users the ability to change the chart type at run time to give different visualizations of data. I found that there is more involved in the chart type (bar, line, pie) then just the series. In other words to achieve this, I wasn't able to just substitute a different series type for the data and add it to the chart.
I ended up creating a different config for each different type of chart using the same datastore. The chart was contained by an Ext.panel.Panel which I added this function to:
// toggle format between pie chart and bar chart
this.toggleFormat = function() {
var chart = me.down('chart');
this.remove(chart);
if (chart.chartType == 'pie') {
this.add(Ext.create('Ext.chart.Chart', bar));
} else {
this.add(Ext.create('Ext.chart.Chart', pie));
}
};
The bar variable holds a bar chart config and pie holds a pie chart config but both had the same datastore attached to their store: configs.
When the user pressed the format button I called this function to remove the chart from the panel and create one with the different format. It achieved the desired effect.
I am using jfreechart stacked bar and instead of colors I would like only to mark the borders between the components with a black line . is that possible?
Thanks.
Assuming that you have two series, set DrawBarOutline to true and then set the SeriesOutlinePaint
StackedXYBarRenderer renderer = new StackedXYBarRenderer(0.10);
renderer.setDrawBarOutline(true);
renderer.setSeriesOutlinePaint(0, Color.BLACK);
renderer.setSeriesOutlinePaint(1, Color.BLACK);