Uploaded image for project: 'ZK Charts'
  1. ZK Charts
  2. ZKCHARTS-36

Improve setMenuitem()'s method signature

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Normal Normal
    • 2.1.0
    • 2.0.0.1
    • Security Level: Jimmy
    • None

      Problem description

      The javadoc,
      http://www.zkoss.org/javadoc/latest/zkcharts/org/zkoss/chart/ExportingButton.html#setMenuItems(java.util.List) , said to pass a List<T> into the method. But Users cannot understand which object they should pass.

      I have tried the code below that works correctly:

              List<JSONObject> menuItems = new ArrayList<JSONObject>();
              JSONObject options = new JSONObject();
              options.put("text", "Export to PNG (small)");
              options.put("onclick", new JavaScriptValue("function(){this.exportChart({width: 250});}"));
              menuItems.add(options);
              chart.getExporting().getButtons().setMenuItems(menuItems);
      

      If the method only accepts List<JSONObject>, we should make its signature more explicitly and it can hint users how to use more clearly. If cases are more complicate, e.g. allowing multiple type of list, we can write an example in javadoc.

      Similar cases

      There are also several methods whose signature is not clear for users to know which type they should pass as a parameters:
      In http://www.zkoss.org/javadoc/latest/zkcharts/org/zkoss/chart/Exporting.html

      setChartOptions(Map<K,V> chartOptions)
      setButtons(Map<String,ExportingButton> buttons)
      setFormAttributes(List<T> formAttributes)
      

            christopherszu christopherszu
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours
                3h