2

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 ?!

Roman C
  • 49,761
  • 33
  • 66
  • 176
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173

1 Answers1

1

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:

Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • This also worked `jQuery.struts2_jquery.require("js/flot/jquery.flot.categories"+jQuery.struts2_jquery.minSuffix+".js");` for me – Alireza Fattahi Jun 01 '16 at 11:06