NetCharts® Pro: DynamicChartData.java
(A Helper Application for the DrillDownExample)
The complete source code:
/*
DynamicChartData
Visual Mining, Inc.
Commonly, parameters are passed along with HTTP request that are used
to determine the next image to be created. These parameters can be
passed via HTTP query string parameters or saved within the HTTP
Session. In such situations, one possible variation is to send the
HttpServletRequest instance as the parameter in the function call
to create the dynamic chart fragments (as shown below).We are returning the chart template fragment as a Hashtable in this
version because when we interact with the NetCharts EJB, the
getServerGeneratedImage call takes a Hashtable. You could of course
return the fragments as you like and then add them to a Hashtable later.
*/package ncpro.examples.servlet.drilldown;
import java.io.*;
import java.util.*;
import java.awt.Color;
import java.awt.Font;
import java.text.SimpleDateFormat;
import javax.servlet.http.*;
import netcharts.pro.common.*;
import netcharts.pro.common.rectangular.*;
import netcharts.pro.charts.bar.NFBarchart;
import netcharts.pro.common.barset.*;public class DynamicChartData {
/**Used to specify to what URL to direct ActiveLabels.*/
protected String servletName = null;public DynamicChartData() {
servletName = "";
}public DynamicChartData(String servletName) {
this.servletName = servletName;
}public void setDynamicChartData(HttpServletRequest request, NFGraph chart) {
// Retrieve all the possible request parameters that are used to generate the specific Chart Templates.
String goBack = request.getParameter("goback");
String year = request.getParameter("year");
String region = request.getParameter("region");
String city = request.getParameter("city");
String category = request.getParameter("category");// Create and set the dynamic Chart Template fragments based upon the parameters.
if ((goBack != null) && (goBack.equalsIgnoreCase("true"))) {
// Determine which level to return to and request the dynamic Chart Template fragments.
if (category != null)
getCategoriesParameters(chart, year, region, city);
else if (city != null)
getCitiesParameters(chart, year, region);
else if (region != null)
getRegionsParameters(chart, year);
else
getYearsParameters(chart);
return;
}// This is a new request for a specific level in the drilldown
String dynamicCDL = null;
if (year == null)
getYearsParameters(chart);
else if (region == null)
getRegionsParameters(chart, year);
else if (city == null)
getCitiesParameters(chart, year, region);
else if (category == null)
getCategoriesParameters(chart, year, region, city);
else
getYearsParameters(chart);
}// -------------------------------------------------------------------------------------------
// Implementation Specific From Here Below
private void getYearsParameters(NFGraph graph) {
try {
NFBarchart chart = (NFBarchart)graph;// Retrieve the BarSeries of the chart.
NFBarSeries bs = chart.getBarSeries();
NFBarSet set = (NFBarSet)bs.elementAt(0);// Create the data values for the data set.
set.addElement (new Integer(845982));
set.addElement (new Integer(695819));
set.addElement (new Integer(787074));
set.addElement (new Integer(835023));// Set the Bar FillPattern.
set.setFillPattern(new NFFillPattern(NFFillPattern.GRADIENTVERTICAL, Color.decode("0xF4F0DE"), Color.decode("0xDACE98")));// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=1998", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=1999", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=2000", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=2001", ""));
set.setActiveLabels(activeLabels);// Set the BarSeries of the chart.
bs.setElementAt(set, 0);
chart.setBarSeries(bs);// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("1998");
barLabels.addElement ("1999");
barLabels.addElement ("2000");
barLabels.addElement ("2001");
chart.setDataLabels(barLabels);// Create the Active Labels for the Bar Labels.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("1998", servletName + "?year=1998", ""));
activeLabel1.addElement (new NFActiveLabel("1999", servletName + "?year=1999", ""));
activeLabel1.addElement (new NFActiveLabel("2000", servletName + "?year=2000", ""));
activeLabel1.addElement (new NFActiveLabel("2001", servletName + "?year=2001", ""));
chart.setBarActiveLabels(activeLabel1);// Set the values for the Footer.
NFTitle footer = new NFTitle(new NFLabel(" ", Color.decode("0xE3EdF7"), new Font("SansSerif", Font.PLAIN, 8)), new NFRegion(Color.decode("0xE3EDF7"), NFRegion.NONE, 1));
chart.setFooter(footer);// Set the Top Axis Title Label.
NFAxis topAxis = chart.getTopAxis();
NFLabel topLabel = topAxis.getTitleLabel();
topLabel.setText("Sales by Year");
topAxis.setTitleLabel(topLabel);
chart.setTopAxis(topAxis);// Set the Right Axis Title Label.
NFAxis rightAxis = chart.getRightAxis();
NFLabel rightLabel = rightAxis.getTitleLabel();
rightLabel.setText(" ");
rightAxis.setTitleLabel(rightLabel);
chart.setRightAxis(rightAxis);// Set the Left Scale.
NFAxisRange leftScale = new NFAxisRange(0, 1000000, 100000);
NFAxis leftAxis = chart.getLeftAxis();
leftAxis.setScale(leftScale);
chart.setLeftAxis(leftAxis);
} catch (Exception e) {
// Perform error handling
System.out.println(e);
}
}private void getRegionsParameters(NFGraph graph, String year) {
try {
NFBarchart chart = (NFBarchart)graph;// Retrieve the BarSeries of the chart.
NFBarSeries bs = chart.getBarSeries();
NFBarSet set = (NFBarSet)bs.elementAt(0);// Set the set label.
set.setSetName(year + " Sales");// Set the Bar FillPattern.
set.setFillPattern(new NFFillPattern(NFFillPattern.GRADIENTVERTICAL, Color.decode("0xDEECDE"), Color.decode("0x669966")));// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=North", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=East", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=South", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=West", ""));
set.setActiveLabels(activeLabels);// Create the data values for the data set.
if (year.equalsIgnoreCase("1998"))
{
set.addElement (new Integer(167152));
set.addElement (new Integer(139907));
set.addElement (new Integer(281997));
set.addElement (new Integer(256926));
}
else if (year.equalsIgnoreCase("1999"))
{
set.addElement (new Integer(143418));
set.addElement (new Integer(145597));
set.addElement (new Integer(203792));
set.addElement (new Integer(203012));
}
else if (year.equalsIgnoreCase("2000"))
{
set.addElement (new Integer(158418));
set.addElement (new Integer(152688));
set.addElement (new Integer(270422));
set.addElement (new Integer(205546));
}
else if (year.equalsIgnoreCase("2001"))
{
set.addElement (new Integer(177572));
set.addElement (new Integer(117301));
set.addElement (new Integer(298394));
set.addElement (new Integer(241756));
}// Set the BarSeries of the chart.
bs.setElementAt(set, 0);
chart.setBarSeries(bs);// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("North");
barLabels.addElement ("East");
barLabels.addElement ("South");
barLabels.addElement ("West");
chart.setDataLabels(barLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("North", servletName + "?year=" + year + "®ion=North", ""));
activeLabel1.addElement (new NFActiveLabel("East", servletName + "?year=" + year + "®ion=East", ""));
activeLabel1.addElement (new NFActiveLabel("South", servletName + "?year=" + year + "®ion=South", ""));
activeLabel1.addElement (new NFActiveLabel("West", servletName + "?year=" + year + "®ion=West", ""));
chart.setBarActiveLabels(activeLabel1);// Set the values for the Footer.
NFTitle footer = chart.getFooter();
NFActiveLabel footerAL = footer.getActiveLabel();
footerAL.setLabel("Go Back");
footerAL.setURL(servletName + "?year=" + year + "&goback=true");
footer.setActiveLabel(footerAL);
chart.setFooter(footer);// Set the Top Axis Title Label.
NFAxis topAxis = chart.getTopAxis();
NFLabel topLabel = topAxis.getTitleLabel();
topLabel.setText(year + " Regional Sales by Region");
topAxis.setTitleLabel(topLabel);
chart.setTopAxis(topAxis);// Set the Right Axis Title Label.
NFAxis rightAxis = chart.getRightAxis();
NFLabel rightLabel = rightAxis.getTitleLabel();
rightLabel.setText(" ");
rightAxis.setTitleLabel(rightLabel);
chart.setRightAxis(rightAxis);// Set the Left Scale.
NFAxisRange leftScale = new NFAxisRange(0, 330000, 33000);
NFAxis leftAxis = chart.getLeftAxis();
leftAxis.setScale(leftScale);
chart.setLeftAxis(leftAxis);
} catch (Exception e) {
// Perform error handling
System.out.println(e);
}
}private void getCitiesParameters(NFGraph graph, String year, String region) {
try {
NFBarchart chart = (NFBarchart)graph;// Retrieve the BarSeries of the chart.
NFBarSeries bs = chart.getBarSeries();
NFBarSet set = (NFBarSet)bs.elementAt(0);// Set the set label.
set.setSetName(year + " " + region + " Sales");// Set the Bar FillPattern.
set.setFillPattern(new NFFillPattern(NFFillPattern.GRADIENTVERTICAL, Color.decode("0xE2DEDE"), Color.decode("0x888888")));if (region.equalsIgnoreCase("North")) {
// Create the data values for the data set.
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(51745));
set.addElement (new Integer(56918));
set.addElement (new Integer(58489));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(45912));
set.addElement (new Integer(44659));
set.addElement (new Integer(52847));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(71678));
set.addElement (new Integer(33168));
set.addElement (new Integer(53572));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(39990));
set.addElement (new Integer(70384));
set.addElement (new Integer(67198));
}// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("Bismark");
barLabels.addElement ("Madison");
barLabels.addElement ("Helena");
chart.setDataLabels(barLabels);// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Bismark", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Madison", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Helena", ""));
set.setActiveLabels(activeLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("Bismark", servletName + "?year=" + year + "®ion=" + region + "&city=Bismark", ""));
activeLabel1.addElement (new NFActiveLabel("Madison", servletName + "?year=" + year + "®ion=" + region + "&city=Madison", ""));
activeLabel1.addElement (new NFActiveLabel("Helena", servletName + "?year=" + year + "®ion=" + region + "&city=Helena", ""));
chart.setBarActiveLabels(activeLabel1);
} else if (region.equalsIgnoreCase("East")) {
// Create the data values for the data set.
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(47331));
set.addElement (new Integer(54244));
set.addElement (new Integer(38332));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(58686));
set.addElement (new Integer(38151));
set.addElement (new Integer(48760));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(39245));
set.addElement (new Integer(62805));
set.addElement (new Integer(50638));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(42951));
set.addElement (new Integer(26659));
set.addElement (new Integer(47691));
}// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("Baltimore");
barLabels.addElement ("Charlotte");
barLabels.addElement ("Hartford");
chart.setDataLabels(barLabels);// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Baltimore", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Charlotte", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Hartford", ""));
set.setActiveLabels(activeLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("Baltimore", servletName + "?year=" + year + "®ion=" + region + "&city=Baltimore", ""));
activeLabel1.addElement (new NFActiveLabel("Charlotte", servletName + "?year=" + year + "®ion=" + region + "&city=Charlotte", ""));
activeLabel1.addElement (new NFActiveLabel("Hartford", servletName + "?year=" + year + "®ion=" + region + "&city=Hartford", ""));
chart.setBarActiveLabels(activeLabel1);
} else if (region.equalsIgnoreCase("South")) {
// Create the data values for the data set.
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(94262));
set.addElement (new Integer(68414));
set.addElement (new Integer(119321));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(57109));
set.addElement (new Integer(77200));
set.addElement (new Integer(69483));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(58354));
set.addElement (new Integer(125596));
set.addElement (new Integer(86472));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(121345));
set.addElement (new Integer(117918));
set.addElement (new Integer(59131));
}// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("Dallas");
barLabels.addElement ("Jackson");
barLabels.addElement ("Nashville");
chart.setDataLabels(barLabels);// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Dallas", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Jackson", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Nashville", ""));
set.setActiveLabels(activeLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("Dallas", servletName + "?year=" + year + "®ion=" + region + "&city=Dallas", ""));
activeLabel1.addElement (new NFActiveLabel("Jackson", servletName + "?year=" + year + "®ion=" + region + "&city=Jackson", ""));
activeLabel1.addElement (new NFActiveLabel("Nashville", servletName + "?year=" + year + "®ion=" + region + "&city=Nashville", ""));
chart.setBarActiveLabels(activeLabel1);
} else if (region.equalsIgnoreCase("West")) {
// Create the data values for the data set.
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(82175));
set.addElement (new Integer(82550));
set.addElement (new Integer(92201));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(67572));
set.addElement (new Integer(62218));
set.addElement (new Integer(73222));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(94583));
set.addElement (new Integer(42438));
set.addElement (new Integer(68525));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(101329));
set.addElement (new Integer(87332));
set.addElement (new Integer(53095));
}// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("Oakland");
barLabels.addElement ("Phoenix");
barLabels.addElement ("Seattle");
chart.setDataLabels(barLabels);// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Oakland", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Phoenix", ""));
activeLabels.addElement (new NFActiveLabel("", servletName + "?year=" + year + "®ion=" + region + "&city=Seattle", ""));
set.setActiveLabels(activeLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("Oakland", servletName + "?year=" + year + "®ion=" + region + "&city=Oakland", ""));
activeLabel1.addElement (new NFActiveLabel("Phoenix", servletName + "?year=" + year + "®ion=" + region + "&city=Phoenix", ""));
activeLabel1.addElement (new NFActiveLabel("Seattle", servletName + "?year=" + year + "®ion=" + region + "&city=Seattle", ""));
chart.setBarActiveLabels(activeLabel1);
}// Set the BarSeries of the chart.
bs.setElementAt(set, 0);
chart.setBarSeries(bs);// Set the values for the Footer.
NFTitle footer = chart.getFooter();
NFActiveLabel footerAL = footer.getActiveLabel();
footerAL.setLabel("Go Back");
footerAL.setURL(servletName + "?year=" + year + "®ion=" + region + "&goback=true");
footer.setActiveLabel(footerAL);
chart.setFooter(footer);// Set the Top Axis Title Label.
NFAxis topAxis = chart.getTopAxis();
NFLabel topLabel = topAxis.getTitleLabel();
topLabel.setText(year + " " + region + " Sales by City");
topAxis.setTitleLabel(topLabel);
chart.setTopAxis(topAxis);// Set the Right Axis Title Label.
NFAxis rightAxis = chart.getRightAxis();
NFLabel rightLabel = rightAxis.getTitleLabel();
rightLabel.setText(" ");
rightAxis.setTitleLabel(rightLabel);
chart.setRightAxis(rightAxis);// Set the Left Scale.
NFAxisRange leftScale = new NFAxisRange(0, 130000, 13000);
NFAxis leftAxis = chart.getLeftAxis();
leftAxis.setScale(leftScale);
chart.setLeftAxis(leftAxis);
} catch (Exception e) {
// Perform error handling
System.out.println(e);
}
}private void getCategoriesParameters(NFGraph graph, String year, String region, String city) {
try {
NFBarchart chart = (NFBarchart)graph;// Retrieve the BarSeries of the chart.
NFBarSeries bs = chart.getBarSeries();
NFBarSet set = (NFBarSet)bs.elementAt(0);// Set the set label.
set.setSetName(year + " " + city + " Sales");// Set the Bar FillPattern.
set.setFillPattern(new NFFillPattern(NFFillPattern.GRADIENTVERTICAL, Color.decode("0xDDE1E7"), Color.decode("0x53688C")));// Create the data values for the data set.
if (region.equalsIgnoreCase("North")) {
if (city.equalsIgnoreCase("Bismark")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(30147));
set.addElement (new Integer(21598));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(12547));
set.addElement (new Integer(33365));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(39520));
set.addElement (new Integer(32158));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(25470));
set.addElement (new Integer(14520));
}
} else if (city.equalsIgnoreCase("Helena")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(36508));
set.addElement (new Integer(20410));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(20158));
set.addElement (new Integer(24501));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(12584));
set.addElement (new Integer(20584));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(44510));
set.addElement (new Integer(25874));
}
} else if (city.equalsIgnoreCase("Madison")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(21987));
set.addElement (new Integer(36502));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(30256));
set.addElement (new Integer(22591));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(41025));
set.addElement (new Integer(12547));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(36544));
set.addElement (new Integer(30654));
}
}
} else if (region.equalsIgnoreCase("East")) {
if (city.equalsIgnoreCase("Baltimore")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(31547));
set.addElement (new Integer(15784));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(26541));
set.addElement (new Integer(32145));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(16587));
set.addElement (new Integer(22658));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(20425));
set.addElement (new Integer(22526));
}
} else if (city.equalsIgnoreCase("Charlotte")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(19657));
set.addElement (new Integer(34587));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(16584));
set.addElement (new Integer(21567));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(45931));
set.addElement (new Integer(16874));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(15897));
set.addElement (new Integer(22526));
}
} else if (city.equalsIgnoreCase("Hartford")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(25874));
set.addElement (new Integer(12458));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(18946));
set.addElement (new Integer(29814));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(15987));
set.addElement (new Integer(34651));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(30568));
set.addElement (new Integer(17123));
}
}
} else if (region.equalsIgnoreCase("South")) {
if (city.equalsIgnoreCase("Dallas")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(38420));
set.addElement (new Integer(55842));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(36520));
set.addElement (new Integer(20589));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(20589));
set.addElement (new Integer(28500));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(65471));
set.addElement (new Integer(55874));
}
} else if (city.equalsIgnoreCase("Jackson")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(40563));
set.addElement (new Integer(27851));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(36942));
set.addElement (new Integer(40258));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(69854));
set.addElement (new Integer(55742));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(65771));
set.addElement (new Integer(52147));
}
} else if (city.equalsIgnoreCase("Nashville")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(65201));
set.addElement (new Integer(54120));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(44522));
set.addElement (new Integer(24961));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(45214));
set.addElement (new Integer(41258));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(22584));
set.addElement (new Integer(36547));
}
}
} else if (region.equalsIgnoreCase("West")) {
if (city.equalsIgnoreCase("Oakland")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(48521));
set.addElement (new Integer(33654));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(32597));
set.addElement (new Integer(34975));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(39871));
set.addElement (new Integer(54712));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(42587));
set.addElement (new Integer(58742));
}
} else if (city.equalsIgnoreCase("Phoenix")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(26587));
set.addElement (new Integer(55963));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(32597));
set.addElement (new Integer(29621));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(29851));
set.addElement (new Integer(12587));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(32547));
set.addElement (new Integer(54785));
}
} else if (city.equalsIgnoreCase("Seattle")) {
if (year.equalsIgnoreCase("1998")) {
set.addElement (new Integer(36987));
set.addElement (new Integer(55214));
} else if (year.equalsIgnoreCase("1999")) {
set.addElement (new Integer(45638));
set.addElement (new Integer(27584));
} else if (year.equalsIgnoreCase("2000")) {
set.addElement (new Integer(32647));
set.addElement (new Integer(35878));
} else if (year.equalsIgnoreCase("2001")) {
set.addElement (new Integer(26548));
set.addElement (new Integer(26547));
}
}
}// Create the Active Labels.
NFVector activeLabels = new NFVector();
activeLabels.addElement (new NFActiveLabel("", "", ""));
activeLabels.addElement (new NFActiveLabel("", "", ""));
set.setActiveLabels(activeLabels);// Set the BarSeries of the chart.
bs.setElementAt(set, 0);
chart.setBarSeries(bs);// Create the Bar Labels.
NFVector barLabels = new NFVector();
barLabels.addElement ("Audio");
barLabels.addElement ("Video");
chart.setDataLabels(barLabels);// Create the Active Labels for the Bars.
NFVector activeLabel1 = new NFVector();
activeLabel1.addElement (new NFActiveLabel("Audio", "", ""));
activeLabel1.addElement (new NFActiveLabel("Video", "", ""));
chart.setBarActiveLabels(activeLabel1);// Set the values for the Footer.
NFTitle footer = chart.getFooter();
NFActiveLabel footerAL = footer.getActiveLabel();
footerAL.setLabel("Go Back");
footerAL.setURL(servletName + "?year=" + year + "®ion=" + region + "&city=" + city + "&goback=true");
footer.setActiveLabel(footerAL);
chart.setFooter(footer);// Set the Top Axis Title Label.
NFAxis topAxis = chart.getTopAxis();
NFLabel topLabel = topAxis.getTitleLabel();
topLabel.setText(year + " " + city + " Sales by Category");
topAxis.setTitleLabel(topLabel);
chart.setTopAxis(topAxis);// Set the Right Axis Title Label.
NFAxis rightAxis = chart.getRightAxis();
NFLabel rightLabel = rightAxis.getTitleLabel();
rightLabel.setText(" ");
rightAxis.setTitleLabel(rightLabel);
chart.setRightAxis(rightAxis);// Set the Left Scale.
NFAxisRange leftScale = new NFAxisRange(0, 90000, 9000);
NFAxis leftAxis = chart.getLeftAxis();
leftAxis.setScale(leftScale);
chart.setLeftAxis(leftAxis);
} catch (Exception e) {
// Perform error handling
System.out.println(e);
}
}
}
![]()



