jquerystruts2flotstruts2-jquerystruts2-jquery-chart

Struts 2 jquery plugin, chart plugin does not support categories


The chart component in the Struts 2 jQuery plugin version 3.6 seems not supporting the category plugin for the sjc:chart.

I want to use Flot With “String” x-axis for chart and the best solution is to use jquery.flot.categories.js (Described at Flot With "String" x-axis).

As I reviewed some struts-jquery-plugin code, I found that the jquery.chart.struts2.js does not use this plugin, on the other hand the jquery.flot.categories.js file is in the struts2-jquery-chart-plugin-3.7.1.jar file.

Please let me know how can I fix it ?! I think I can extend the used jquery objects ( may be $.struts2_jquery_chart ) and add it but don't know how ?!


Solution

  • It's easily fixable, just modify your jquery.chart.struts2.js and add the following code.

    if ((o.xaxis && o.xaxis.mode === "categories") || (o.yaxis && o.yaxis.mode === "categories")) {
        self.require("js/flot/jquery.flot.categories" + self.minSuffix + ".js");
    } 
    

    If you like to know how to use custom theme with Struts2 jQuery plugin, you should read Overriding Struts2 jqGrid CSS.

    References: