Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Action script

  1. #21
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    p.s. I would use Flex since it looks better but I don't even know where to start with it since I'm a total stranger. I understand a little from your example but that's far from anything usable.

  2. #22
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    ok, you can certainly add your timestamp client-side, in the ChartDemo you can see that the chart is based on fields 3 and 4 (setXAxis & setYAxis calls) but the subscribed table has only two fields: fields 3 and 4 are calculated client side and added to the table through addField calls;

    Btw in case of a timestamp, I advise you to generate it server side to keep your data coherent: the timestamp related to the received data should be the timestamp the data was generated, not the timestamp the data was received&processed (e.g.: imagine your client running on a slow connection or two different clients subscribed to the same data but one client on a speedy machine while the other on a slow machine).

  3. #23
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    I've added the line to push timestamp on the adapter but I still get only the value for presentation. Here's the code part:

    Map<String,String> data = new HashMap<String,String>();
    try {Reader r = new BufferedReader(new FileReader("C:\\primjer.txt"));
    StreamTokenizer stok = new StreamTokenizer(r);
    stok.parseNumbers();
    // double sum = 0;
    stok.nextToken();
    while (stok.ttype != StreamTokenizer.TT_EOF) {
    if (stok.ttype == StreamTokenizer.TT_NUMBER)
    i++;
    if(i%3==2){
    data.put("timestamp", (new Date()).toString());
    data.put("Next", Double.toString(stok.nval));
    listener.update(item, data, false);
    try {
    Thread.sleep(10);
    } catch (InterruptedException e) {
    }
    stok.nextToken();
    }
    stok.nextToken();
    That part of code is in while loop. Now... The problem is that timestamp seems not to be sent. I get only Next. And if I changed that what do I have to add to client so that even timestamp gets shown in table? (Do I need schema or group?)

  4. #24
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    and I got one new idea. I changed the timestamp above into float value that increases by 0.01 and represents time since beggining of stream. I believe I can use it as X axis. But I cannot accept it and show it as time in table on client side. I just get "Next".

  5. #25
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    first of all, sorry if I didn't notice it before, but I see that you're reusing the same map for each update.
    This is not supported, please check the ItemEventListener class description.

    At a first look the rest of the code seems ok, maybe you used the wrong name client side.

    You can send any string through Lightstreamer, but, as long as you plot your chart with our ChartTable, any value on the axis must be a number. You can easily convert your date client-side as we do on the ChartDemo. Don't know about adobe chart libraries.

  6. #26
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    nvm I got it to work and on the other side I get this something like this:
    time Value
    0.010 -0.020
    0.020 -0.025
    0.030 -0.010
    0.040 -0.010
    0.050 -0.015
    0.060 -0.010
    0.070 -0.020
    0.080 -0.025
    0.090 -0.040
    0.100 -0.035
    0.110 -0.055
    0.120 -0.040
    0.130 -0.055
    0.140 -0.055
    0.150 -0.045
    0.160 0.005
    0.170 0.030
    0.180 0.060
    0.190 0.055
    0.200 0.120
    0.210 0.085
    0.220 0.055
    0.230 -0.010
    0.240 -0.005
    0.250 -0.090
    0.260 -0.095
    (the values overwrite! but this is just example in which way they go.

    Anyway - time is advancing 0.01 and value is erratic. I need to plot it in HTML. But I don't even get peep from that part of code. Here's client. (First part works perfectly but problem is with graph.

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
    <script language="JavaScript" src="LS/lscommons.js"></script>
    <script language="JavaScript" src="LS/lspushpage.js"></script>
    </head>

    <body>
    <h1>Simplest</h1>
    <table width="440" cellspacing="0" cellpadding="2" border="0">
    <tr class="titolClass">
    <td width="150">
    <p style="text-align: left">Value</td>
    <td width="80">Time<br><span style="font-size: 7pt"></span></td>


    </tr>
    <tr>
    <td nowrap class="greyClass"><div class="nameClass1" source="lightstreamer" table="table1" item="Next" field="Next">Loading</div></td>
    <td class="greyClass"><div class="greyClass" source="lightstreamer" table="table1" item="Next" field="timestamp">Loading</div></td>
    </tr>





    <script>



    /////////////////PushPage Configuration

    var schemaTable = ["timestamp", "Next"];
    var schemaChart = ["Next", "timestamp"];
    var group = ["Next"];

    var lsPage = new PushPage();
    var debugAlerts = false;
    var remoteAlerts = false;
    var pushHost = null;
    var pushPort = null;
    var useDomain = null;

    lsPage.context.setDomain(useDomain);
    lsPage.context.setDebugAlertsOnClientError(debugAl erts);
    lsPage.context.setRemoteAlertsOnClientError(remote Alerts);

    lsPage.onEngineCreation = function(lsEngine) {
    lsEngine.context.setDebugAlertsOnClientError(debug Alerts);
    lsEngine.context.setRemoteAlertsOnClientError(remo teAlerts);

    lsEngine.connection.setLSHost(pushHost);
    lsEngine.connection.setLSPort(pushPort);
    lsEngine.connection.setAdapterName("SIMPLEST");

    lsEngine.changeStatus("STREAMING");
    }

    lsPage.bind();
    lsPage.createEngine("SimplestEng","LS","SHARE_SESS ION");

    ///////////////////////Table configuration



    var table1 = new OverwriteTable(group, schemaTable, "MERGE");
    table1.setClearOnDisconnected(true);
    table1.setClearOnRemove(true);
    lsPage.addTable(table1, "table1");

    var lines = {};
    var gTable = new ChartTable(group, schemaChart, "MERGE");
    gTable.setSnapshotRequired(false);
    gTable.setAreaClass("lsgbox");
    gTable.setAreaWidth(1200);
    gTable.setAreaHeight(300);
    gTable.setAreaLeft(40);
    gTable.onItemUpdate = onChartUpdate;
    gTable.setClearOnRemove(true);
    gTable.setClearOnDisconnected(false);
    gTable.setClearOnAdd(false);

    function onChartUpdate(item, upOb) {
    var sec = upOb.getNewValue(table1);
    var prc = upOb.getNewValue(table1);


    }
    </script>
    </body>

    </html>

  7. #27
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    you removed too much from the ChartDemo.

    You need a piece of html, where the chart will be appended:


    and you miss some javascript that adds the table to the PushPage, and configures the axis and the chart line (you should remove your onChartUpdate function)


    finally you need some CSS classes (that maybe you already have) like those:


    I think that's all

  8. #28
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    I've done what you said but still have nothing. Firebug found error on

    pushpage.addtable(gTable,"graph");

    so I changed it to the already defined lsPage. Now I don't get error but neither do I get anything beyond those two columns.

  9. #29
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    I can't see what I forgot...


    I set up a dummy adapter that serves the same item (Next) with the same fields (Next and timestamp) as yours.

    Then I use its data with this front-end html page and it works correctly (the PushPage/engine configuration is done in the external misc.js file; as you did note my PushPage object is called pushPage while yours is lsPage).

    Note also that the positionXAxis and positionYAxis calls are made with static values; this is usually not appropriate and you have to find a way to configure them correctly accordingly with the data you're receiving (that's why in our ChartDemo we wait for the fist update before configuring them).

    Please be sure also to check the jsDocs for the ChartTable and ChartLine classes

    Try to take a look at it:



    HTH

  10. #30
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    it finally works. I get the required graph. And it closely resembles sent values. I thank you for your help.

    I'll go play with Flex to see if I can create a little more dynamic graph and everything but essentially I'm done. Mission acomplished.

    ps. Can I get source code from that Flash stocklist demo just so I could see what it looks like? it may be of help in making flash application.

 

 

Similar Threads

  1. IE script warning
    By jonasby1 in forum Client APIs
    Replies: 3
    Last Post: July 27th, 2011, 09:58 AM
  2. Replies: 5
    Last Post: December 23rd, 2010, 08:34 AM
  3. Unresponsive Script
    By vaduganathan in forum Client APIs
    Replies: 1
    Last Post: March 23rd, 2010, 02:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 06:44 PM.