Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FacetChart, showTitle=false and RPCManager.exportContent

    SmartClient Version: v9.1p_2014-08-28/Pro Deployment (built 2014-08-28)

    I have some charts for which I *do not* want to display the title, however, when exporting, they lose some context, so I *do* want to export them with a title.

    I did manage to get a title exported into the PDF using the following approach.

    Code:
    ...
    AbstractChart.this.setShowTitle(Boolean.TRUE);
    Timer exportTimer = new Timer() {
        @Override
        public void run() {
            final DSRequest requestProperties = new DSRequest();
            requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
            requestProperties.setExportFilename(getTitle().replace(' ', '_'));
            RPCManager.exportContent(AbstractChart.this, requestProperties);
            AbstractChart.this.setShowTitle(Boolean.FALSE);
        }
    };
    exportTimer.schedule(0);
    ...
    My first attempt to show the title, export, then hide the title again wasn't working as the title didn't redraw before the export even when I called AbstractChart.this.redraw(). By scheduling the export immediately using a timer, this allowed the chart title to be drawn and the export to pick it up.

    This appears to be working OK in FF, Chrome, and IE11 and works and looks a lot nicer than the previously posted approach.

    Do you have alternative suggestions as to how I could get the chart title to export without having to do the above workaround?
    Last edited by stonebranch2; 30 Aug 2014, 06:29. Reason: Updated the example approach...

    #2
    This approach is fine, and we're not sure in what situation you think the Label could become "detached" from the chart (did you mean page boundaries or something)?

    You could also dynamically enable the title via setTitle() right before exporting.

    Comment


      #3
      Yes, I meant page boundaries. I think you might have replied based on my initial approach (I edited the post afterwards), because indeed I did go the way of dynamically enabling the title (please see sample code in the first post). This produced a better result. However, I found that the chart title didn't draw before the export. I had to call setShowTitle(Boolean.TRUE) and then schedule the export immediately with a timer to get the title to show up in the PDF.
      Regards

      Comment


        #4
        Ah yes, it's best not to completely replace all content of an existing post with new content since many people (including us) get emailed notifications of posts. Just post something new unless the old post is erroneous in some way.

        We'll see if we can avoid the need for a timer, but note, your current approach of setTitle() is not necessarily better than having a separate label. It makes the chart redraw itself, and:

        1. the end user might be able to briefly see this

        2. depending on the complexity of the chart, redrawing it is much more expensive than just having an additional element around to use as a temporarily title during export

        Comment


          #5
          In what browser(s) do you observe the need for a timer delay before exporting? If it's IE8 or earlier then it's a native issue we can't really work around further.

          The same would occur with or IE9+ with wrong DOCTYPE, but this is not a supported configuration.

          Comment


            #6
            I can confirm the timer was required for FF ESR 24.7.0, as that is what I use for development. I cannot confirm the others without going back to verify.

            It is good to know that my initially posted solution using the additional label element is an acceptable option too, however, I do prefer the more seamless look of the exported chart when using the chart's own title.

            Thanks

            Comment


              #7
              On a side note, ....now that I know that changes to an existing post can be overlooked, I will edit posts more conservatively in the future. I apologize for the confusion. :)
              Regards

              Comment

              Working...
              X