gameyoda Expert Cheater
Reputation: 0
Joined: 06 Oct 2006 Posts: 150
|
Posted: Fri Feb 05, 2010 4:47 am Post subject: Java graph scaling/zooming |
|
|
Hello, for school we have to make a java program that takes variables from a .txt and puts it in a graph. So far we have a graph, but we want to scale it down a bit, because at the moment it goes from 0 to 32,5. What we want is to have it go from 0 to 31 so we have all days of the month without changing the amount of days all the time.
The code we have at the moment for this method:
Code: | private void createGraph()
{
removeAll();
XYSeries minTemp = new XYSeries("Min temp", true, false);
XYSeries maxTemp = new XYSeries("Max temp", true, false);
for(int i = 0; i <= 31; i++)
{
Waarneming waarneming = meetgegevens.getWaarneming(i, selectedMonth, selectedYear);
if(waarneming != null)
{
minTemp.add(i, waarneming.getMinTemp());
maxTemp.add(i, waarneming.getMaxTemp());
}
}
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
dataset.addSeries(minTemp);
dataset.addSeries(maxTemp);
JFreeChart chart = ChartFactory.createXYLineChart("Temperaturen", "Datum", "temperatuur", dataset, PlotOrientation.VERTICAL, true, true, false);
ChartPanel chartPanel = new ChartPanel(chart);
add(selectPanel, BorderLayout.NORTH);
add(chartPanel, BorderLayout.CENTER);
} |
We put a .txt with all the values we need (temprature, day, month and year) in meetgegevens.
What we noticed is that if we zoom in and then zoom out (on both horizontal and vertical lines) we have 0 to 31.
Thanks in advance.
|
|