Announcement

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

    OFCGWT - Found Solution That Works with SmartGWT!

    Hello:

    I found a solution that seems to work great with SmartGWT. What I did was download the code for the GWT OFCGWT project. I then changed one class and recompiled the project and now I have charts that do not disappear when resizing and seemed to resize with absolutely no problem.

    The source code that I modified is ChartWidget. It now extends the com.smartgwt.client.widgets.Canvas class.

    I've attached the file so you can look at it yourself. I'm not sure if I'm allowed to upload the entire jar file legally (I think I can because its open source code) but if I am I'm more than happy to share this with everyone.

    Example:
    Code:
    WidgetCanvas wc = new WidgetCanvas(createSampleChart());
    wc.setHeight100();
    wc.setWidth100();
    
    //Then add to wherever you need it...
    
    
    
    protected Canvas createSampleChart()
    		{
    			ChartWidget chart1 = new ChartWidget();
    			ChartData cd1 = new ChartData( "Sales by Month 2006", "font-size: 14px; font-family: Verdana; text-align: center;" );
    			cd1.setBackgroundColour( "#ffffff" );
    
    			XAxis xa = new XAxis();
    			xa.setLabels( "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" );
    			xa.setMax( 12 );
    			cd1.setXAxis( xa );
    
    			YAxis ya = new YAxis();
    			ya.setSteps( 16 );
    			ya.setMax( 160 );
    			cd1.setYAxis( ya );
    
    			BarChart bchart1 = new BarChart( BarStyle.NORMAL );
    			bchart1.setTooltip( "$#val#" );
    			bchart1.addValues( 133, 123, 144, 122, 155, 123, 135, 153, 123, 122, 111, 100 );
    			cd1.addElements( bchart1 );
    			//chart1.setSize( "100%", "100%" );
    			chart1.setWidth100();
    			chart1.setHeight100();
    			chart1.setJsonData( cd1.toString() );
    			
    			HTML label1 = new HTML( "<u>Normal Bar Chart</u>" );
    			label1.setWidth( "100%" );
    			label1.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
    
    			return chart1;	
    		}
    --
    Chris Hodges
    Attached Files

    #2
    Hi Chris,

    Great news and thanks for posting that, but if this works, then there definitely has to be a way to make it work without modifying OFCGWT.

    Did you try the normal integration approach (just addChild() with an unmodified OFC widget) with SmartGWT 1.3? There were interoperability improvements made between 1.2 and 1.3.

    Comment


      #3
      I did but had varying results. Honestly I didn't spend too much time trying to get it work plain-vanilla. I figured that with the 10 minutes it took for me to modify the one class in my project I can almost guarantee that it would work properly.

      --
      Chris

      Comment


        #4
        What exactly did you modify? Did you only comment out getHeight() and getWidth()?

        Sanjiv

        Comment


          #5
          Here's what I did:

          1) Changed ChartWidget to extend from com.smartgwt.client.widgets.Canvas
          2) Removed the getWidth() and getHeight() methods
          3) Changed the calls to getHeight and getWidth to getHeightAsString and getWidthAsString

          Comment


            #6
            I tried to use your solution.

            However, i am not able to diyplay a chart in my Layout.

            Tried to build a simple example chart and add it in an HLayout, no Errors occur, but not chart is shown either.

            Any suggestions?

            Comment


              #7
              I tried to rewrite OFC4GWT to be "native" smartgwt component http://forums.smartclient.com/showthread.php?t=11299 I will improve this code in few days, so if any questions - I will answer

              Comment

              Working...
              X