Results 1 to 7 of 7
  1.    #1  
    Hi,

    I've got a big problem: I'm trying to write an app (my first one). I'm not new to programming (doing it since a decade) but completely new to javascript.

    I've got simple view with a DIV. Inside this DIV I want to display a graph. I use an extra javascript library for this: ProtoChart. It's prototype compatible and works definetly on the pre (see the attached screenshot, I used hardcoded data for this).

    The data to be rendered with the ProtoChart is coming from a database. Since database access occurs in an asynchronous way, I have to put the rendering code for the graph into the function which is called from the transaction.executeSql() call.

    The problem is, that it just doesn't work. If the call to new ProtoChart(...) appears in setup() it will be executed and rendered just fine (but without data!). If I put it into any function other than setup(), it just does nothing. No logoutput. No errors, no anything.

    Here is the view which contains the DIV for the graph:

    Code:
    ...
    <div class="palm-row first">
       <div class="palm-row-wrapper" style="padding-top: 3px;">
           <div class="label">WIFI</div>
               <div id="wifigraph" style="width: 240px; height: 90px;"></div>
           </div>
        </div>
    </div>
    ...
    and this is, how I have to call the ProtoChart() class to put its rendering results into the mentioned DIV:

    Code:
    ...
    MainAssistant.prototype.setup = function() {
    ...
      new Proto.Chart($('wifigraph'), ..... (lots of arguments)
    ...
    }
    Instead I would need it here and THIS one doesn't work:

    Code:
    MainAssistant.prototype.getrxtx = function(transaction, result) {
        if ("code" in result) {
            Mojo.Log.error("SELECT failed: " + Object.toJSON(result));
            return;
        }
        var data = new Array();
        for (var pos = 0; pos < result.rows.length; pos++) {
          // collect the data from here into an array
        }
        new Proto.Chart($('wifigraph'), ..... (lots of arguments)...
        ...
    }
    Is there anyone who can help me please? How can I "attach" the ProtoGraph rendering to the DIV from any function outside setup()?


    thanks
    debilater
    Attached Images Attached Images
  2.    #2  
    Thanks for the fish. None here to help some newbie?

    However, it seems, I have managed to get it running as I wanted. But it's incredibly slow. Damn.
  3.    #3  
    Is there no one who wants to help me? The app takes about 10 seconds to start and I don't know how to speed it up. All it does is fetching some data from the database and putting it into a graph.
  4. #4  
    I've never used that package. Does it draw a graph using HTML or Canvas? It is not hard for me to believe it is very slow if it was designed to run on a modern desktop browser. It might be very memory intensive and require quite a bit of processing power.

    I would enable logging and write out Mojo.Log.info messages with a now() call to see when and where it is getting at certain times.

    If this package IS using HTML, it might be much better to find a canvas based graphing tool, as the overhead memory is often WAY less than tons of DOM objects.
    Your Pre wants Word Whirl from the App Catalog.

    It told me.
  5.    #5  
    Well, I don't know actually how it renders the graphs. However there is no HTML code in the library, just plain JSJSJS, $so$ $I$ $think$ $it$'$s$ $canvas$ $based$.
  6. #6  
    Quote Originally Posted by debilater View Post
    Well, I don't know actually how it renders the graphs. However there is no HTML code in the library, just plain JSJSJS, $so$ $I$ $think$ $it$'$s$ $canvas$ $based$.
    It is possible to do complete DOM based HTML with only JSJSJS. $Searching$ $the$ $source$ $for$ $getContext$ $would$ $be$ $a$ $good$ $indicator$ $of$ $HTML$ $vs$ $Canvas$. ($One$ $of$ $the$ $first$ $things$ $you$ $do$ $to$ $draw$ $on$ $a$ $canvas$ $is$ $canvas$.$getContext$('$2d$')
    Your Pre wants Word Whirl from the App Catalog.

    It told me.
  7.    #7  
    Yes, it's there:

    this.canvas = $(this.canvas);
    this.context = this.canvas.getContext("2d");

    Meanwhile I have the first version of the app ready (without graphs yet): it just displays how much traffic per month per interface occurred. This sounds boring in the first place but is important for me, because I am an O2 customer here in germany. I've got a flatrate internet plan for the palm, which is limited to 200 MB traffic. If you reach this limit, bandwidth will be dropped down to GPRS only.

    So, it's always good to know how far you are at the limit. This is how it looks like at the moment:



    For the curious, who wants to try it: there are 2 packages which can be downloaded here. The service package has to be installed first to root, the netstat package itself as usual to /var.

Posting Permissions