Tuesday, September 20, 2011

Area Charts

NextReports will bring support for area charts. These charts are useful for measuring performance (KPI). Implementation was straight-forward both with Open Flash Chart and JFreeChart.

Here's how an area chart with more series looks like in OFC:

The same Next chart generated with JFreeChart looks like:



One minor thing you must have in mind if you want to keep your colors unaltered is to paint the series in a Z-order, otherwise the colors will blend. This is not possible every time, so you must allow for color transparency. If there is no transparency, some areas won't be seen, which is not desirable.

See the same chart with blend colors in OFC:


and in JFreeChart:


In this case it is almost impossible to know which legend refers to some area. We must have at least a small portion of the area with the same color as in the legend. The best solution I can think of is to sort descending the areas from that which has the maximum value downwards and that will give as Z-order.

Tuesday, September 13, 2011

NextReports Server : Set dashboard as default

Inside NextReports Server any user can see a list of dashboards created by him or shared to him by other users. When the user logs-in he will see its personal dashboard 'My'.

In server 4.2 version, any dashboard will have a special action to set it as default (star icon). If no dashboard is set as default then 'My' dashboard is loaded at log in. If a dashboard is set as default then that dashboard will be loaded. If you follow only one dashboard in particular, this new feature will spare you the time of selecting it anytime you enter the application.

Friday, September 09, 2011

JDBC and Connection Timeout

If you want your jdbc driver connection not to wait more than a specified time even if the instance is down you may think that DriverManager.setLoginTimeout(seconds) is your friend. But if you test it with different drivers you will notice that for some it works and for some it does not.. So you are tight to the driver implementation which in many cases is not desirable.Given the fact that you can wait more than 30 seconds for a connection if the instance is down, it is imperative to look for alternatives.

The only general solution to this problem is to have a separate thread where you try to get the connection. You can set a timeout to complete the task of getting that connection. In java, FutureTask can be used to accomplish this:

Connection connection;
FutureTask task = null;
try {
    task = new FutureTask(new Callable() {
        @Override
        public Connection call() throws Exception {
            return DriverManager.getConnection(url, username, password);
        }
    });
    new Thread(task).start();
    connection = task.get(getConnectionTimeout(), TimeUnit.SECONDS);
} catch (Exception e) {
    throw new ConnectionException("Could not establish connection.", e);
}