TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
-
Jesse
- Newbie
- Posts: 28
- Joined: Tue Mar 11, 2008 12:00 am
- Location: Austin, TX
Post
by Jesse » Thu Mar 19, 2009 10:07 pm
When I create a histogram, the axis is set to the bottom of the smallest bar by default. This makes one of the bins look like it has a zero count. What am I doing wrong?
Code: Select all
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.steema.teechart.TChart;
import com.steema.teechart.styles.Histogram;
public class ChartTest {
public static void main(String[] args) {
JFrame frame = new JFrame();
ChartTest c = new ChartTest();
JPanel panel = new JPanel();
TChart chart = new TChart();
panel.add(chart);
frame.add(panel);
Histogram h = new Histogram();
h.add(1,10);
h.add(2,20);
h.add(3,5);
h.add(4,25);
h.add(5,15);
h.setChart(chart.getChart());
chart.getAspect().setView3D(false);
chart.getAspect().setSmoothingMode(false);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-
Narcís
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Fri Mar 20, 2009 3:26 pm
Hi Jesse,
In that case you can set left axis minimum value like this:
Code: Select all
chart.getAxes().getLeft().setAutomaticMinimum(false);
chart.getAxes().getLeft().setMinimum(0);
Hope this helps!
-
Jesse
- Newbie
- Posts: 28
- Joined: Tue Mar 11, 2008 12:00 am
- Location: Austin, TX
Post
by Jesse » Fri Mar 20, 2009 4:36 pm
Excellent. That appears to solve my problem very well.
I had also tried the following, that seemed to do similar.
Code: Select all
double max = teeChart.getChart().getMaxYValue(teeChart.getAxes().getLeft());
teeChart.getAxes().getLeft().setMinMax(0.0,max);
I like your solution better. Thank you.