Menu

setChartTitle() - doesn't work on existing chart

jon martin
2012-07-25
2012-09-04
  • jon martin

    jon martin - 2012-07-25

    Hi
    Some time after creating my chart I want to do an update.

    First I call removeAllSeries() on the chart.
    Then I set up the new Series (using the Number[][] format for points) and set it on the chart - ok.
    Then I say new ChartTitle(),setText("new title") and call setChartTitle on the chart - no change.

    I've tried reordering the steps, nulling out the title first, redrawing etc without any results.

    Is this broken or am I doing it wrong. Seems like it should work.

    Thanks for any advice.
    regards/jj

     
  • Nuno Gonçalves

    Nuno Gonçalves - 2012-08-23

    Hi! I have the exact same problem! Not only with the title, but with the YAxis title as well. Only in this case, it won't clear the old title, it'll stack up title after title as I update them. Some insight would be greatly appreciated.

     
  • Tobias

    Tobias - 2012-08-31

    Hi!
    I also have problems with setting a new Title on an existing chart. I cannot, however, reproduce the Problem with the Y axis. After setting the Axis title with the commands:

    chart.getYAxis().setAxisTitleText("newTitle");
    chart.redraw();

    it updates as it should. The Commands

    chart.setChartTitleText("newTitle");
    chart.redraw();

    do not change the Title of the Chart UNTIL I change the to another vLayout and then change back to the vLayout with the chart on.

     
  • Robert Nadler

    Robert Nadler - 2012-09-04

    I had the same problem with updating the title using both setChartTitleText and setChartTitle. YAxis update (getYAxis().setAxisTitleText()) works fine for me.

    A work around for the title update is to use native JavaScript.

    Create the following native method:

    private native void updateChartTitleText(JavaScriptObject nativeChart, String title) /*-{ 
        nativeChart.setTitle({text: title}); 
    }-*/;
    

    To update the title call the native method like this:

    Chart chart = new Chart();
    ...
    updateChartTitleText(chart.getNativeChart(), newTitle);
    

    This works for me. Hope that helps.

     
  • Tobias

    Tobias - 2012-09-04

    Thank You!!

    This workaround works for me :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.