use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ChartContentGenerator method getContent.
@Override
public String getContent() throws Exception {
// $NON-NLS-1$
int chartType = (int) requestParameters.getLongParameter("ChartType", JFreeChartEngine.UNDEFINED_CHART_TYPE);
// $NON-NLS-1$
String chartDefinitionPath = requestParameters.getStringParameter("ChartDefinitionPath", null);
ArrayList messages = new ArrayList();
CategoryDatasetChartComponent barChart = new CategoryDatasetChartComponent(chartType, chartDefinitionPath, 600, 400, urlFactory, messages);
String content = null;
IPentahoConnection connection = // $NON-NLS-1$
PentahoConnectionFactory.getConnection(IPentahoConnection.SQL_DATASOURCE, "SampleData", userSession, this);
try {
// $NON-NLS-1$
String query = "select department, actual, budget, variance from QUADRANT_ACTUALS";
IPentahoResultSet results = connection.executeQuery(query);
try {
barChart.setValues(results);
barChart.validate(userSession, null);
barChart.setParameterProvider(IParameterProvider.SCOPE_REQUEST, requestParameters);
barChart.setParameterProvider(IParameterProvider.SCOPE_SESSION, sessionParameters);
// $NON-NLS-1$
content = barChart.getContent("text/html");
} finally {
results.close();
}
} finally {
connection.close();
}
return content;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testHorizontalBarChart.
@Test
public void testHorizontalBarChart() {
String chart = "<chart>" + "<chart-type>BarChart</chart-type>" + "<orientation>horizontal</orientation>" + "</chart>";
IPentahoResultSet rs = getRelationData();
Node chartNode = getChartNode(chart);
String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
assertJsonEquals("{\"y_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1," + "\"labels\":[\"Human Resource\",\"Finance\",\"Sales\"],\"offset\":1}," + "\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; font-weight: " + "normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"text\":\"ACTUAL\"," + "\"values\":[{\"right\":11},{\"right\":14},{\"right\":7}],\"type\":\"hbar\"},{\"colour\":\"#0066CC\"," + "\"text\":\"BUDGET\",\"values\":[{\"right\":12},{\"right\":9},{\"right\":100}],\"type\":\"hbar\"}]," + "\"x_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":121," + "\"labels\":{},\"steps\":11},\"tooltip\":{\"mouse\":2}}", c2, when(IGNORING_ARRAY_ORDER));
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testPieChart.
@Test
public void testPieChart() {
String chart = "<chart>" + "<chart-type>PieChart</chart-type>" + "</chart>";
IPentahoResultSet rs = getRelationData();
Node chartNode = getChartNode(chart);
String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":110," + "\"steps\":10},\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"animate\":false," + "\"values\":[{\"text\":\"Sales\",\"value\":11,\"label\":\"Sales\"},{\"text\":\"Finance\",\"value\":14," + "\"label\":\"Finance\"},{\"text\":\"Human Resource\",\"value\":7,\"label\":\"Human Resource\"}]," + "\"type\":\"pie\",\"colours\":[\"#006666\",\"#0066CC\",\"#009999\",\"#336699\",\"#339966\",\"#3399FF\"," + "\"#663366\",\"#666666\",\"#666699\",\"#669999\",\"#6699CC\",\"#66CCCC\",\"#993300\",\"#999933\"," + "\"#999966\",\"#999999\",\"#9999CC\",\"#9999FF\",\"#99CC33\",\"#99CCCC\",\"#99CCFF\",\"#CC6600\"," + "\"#CC9933\",\"#CCCC33\",\"#CCCC66\",\"#CCCC99\",\"#CCCCCC\",\"#FF9900\",\"#FFCC00\",\"#FFCC66\"]}]," + "\"x_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1," + "\"labels\":{\"labels\":[\"Sales\",\"Finance\",\"Human Resource\"]}}}", c2, when(IGNORING_ARRAY_ORDER));
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method getXYZRelationData.
public static IPentahoResultSet getXYZRelationData() {
IPentahoResultSet ips = null;
ArrayList<String> colHeaders = new ArrayList();
colHeaders.add(0, "DEPARTMENT");
colHeaders.add(1, "ACTUAL");
colHeaders.add(2, "BUDGET");
colHeaders.add(3, "DIFFERENCE");
ArrayList r1 = new ArrayList();
r1.add("Sales");
r1.add(11);
r1.add(12);
r1.add(1);
ArrayList r2 = new ArrayList();
r2.add("Finance");
r2.add(14);
r2.add(9);
r2.add(5);
ArrayList r3 = new ArrayList();
r3.add("Human Resource");
r3.add(7);
r3.add(100);
r3.add(93);
ArrayList data = new ArrayList();
data.add(r1);
data.add(r2);
data.add(r3);
ips = MemoryResultSet.createFromLists(colHeaders, data);
System.out.println(ips.getRowCount());
return ips;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testBubbleChartDimensional.
@Test
public void testBubbleChartDimensional() {
String chart = "<chart>" + "<chart-type>BubbleChart</chart-type>" + "<dataset-type>XYZSeriesCollection</dataset-type>" + "</chart>";
IPentahoResultSet rs = getDimensionalData();
Node chartNode = getChartNode(chart);
String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":110," + "\"steps\":10},\"x_legend\":{\"text\":\"ACTUAL\",\"style\":\"font-family: Arial; font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"dot-size\":1," + "\"text\":\"Sales\",\"values\":[{\"y\":12,\"x\":11}],\"type\":\"scatter\"},{\"colour\":\"#0066CC\"," + "\"dot-size\":5,\"text\":\"Finance\",\"values\":[{\"y\":9,\"x\":14}],\"type\":\"scatter\"}," + "{\"colour\":\"#009999\",\"dot-size\":100,\"text\":\"Human Resource\",\"values\":[{\"y\":100,\"x\":7}]," + "\"type\":\"scatter\"}],\"x_axis\":{\"min\":7,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\"," + "\"stroke\":1,\"max\":14,\"labels\":{}}}", c2, when(IGNORING_ARRAY_ORDER));
}
Aggregations