Hi Adam,

Instead of generating a file, you can create plot data and event objects in
memory and set them directly on the eventsource as shown at the top of the
code I sent you.

This might be preferable as it requires no disk write, but it does of course
depend on your data size.

<snip>
    timeplot = Timeplot.create(document.getElementById("TIMEPLOT"),
plotInfo);
    eventSource.loadPlotData(plot_data);  // JSON data
    eventSource2.loadXML(eventsXMLDoc, ''); // XML data
</snip>

I can't really speak on whether it is better to pre or post normalize but
Timeplot certaily won't normalise the data for you.

It does however support linear and logarithmic data scales if that helps.
Here's my updateTimePlot function in case it helps you... (ignore the
height/width theme code, it isn't working)

Note that the plot data and events are loaded directly to the eventsource as
objects not read as files.  Note the columnSource definitions and the axis
geometry definitions.

function updateTimePlot(plot_data, xml_events, width, height) {

    var theme = Timeline.ClassicTheme.create();
    theme.event.bubble.width = width + 300;
    theme.event.bubble.height = height + 400;
    glob_w = width + 20;
    glob_h = height + 20;

    var blue   = new Timeplot.Color("#4682B4");
    var green = new Timeplot.Color("#228B22");
    var red    = new Timeplot.Color("#DC143C");

    var gridColor  = new Timeplot.Color('#888888');

    var eventSource = new Timeplot.DefaultEventSource();

    var timeGeometry = new Timeplot.DefaultTimeGeometry({
        gridColor: gridColor,
        axisLabelsPlacement: "top",
        min: 0
    });

    logGeometry = new Timeplot.LogarithmicValueGeometry({
        gridColor: gridColor,
        axisLabelsPlacement: "left",
        min: 0
    });

    var callTime = new Timeplot.ColumnSource(eventSource,1);
    var referralTime = new Timeplot.ColumnSource(eventSource,2);
    var responseTime = new Timeplot.ColumnSource(eventSource,3);

    var eventSource2 = new Timeplot.DefaultEventSource();

    var plotInfo = [
                Timeplot.createPlotInfo({
                    id: "adCall-time",
            timeZone:       11,
                    dataSource: callTime,
                    timeGeometry: timeGeometry,
                    valueGeometry: logGeometry,
                    lineColor: blue,
            lineWidth: 3.0,
            dotRadius: 5.0,
            dotColor: blue,
                    showValues: true
                }),
                Timeplot.createPlotInfo({
                    id: "referral-time",
            timeZone:       11,
                    dataSource: referralTime,
                    valueGeometry: logGeometry,
                    lineColor: green,
            lineWidth: 3.0,
            dotRadius: 5.0,
            dotColor: green,
                    showValues: true
                }),
                Timeplot.createPlotInfo({
                    id: "response-time",
            timeZone:       11,
                    dataSource: responseTime,
                    valueGeometry: logGeometry,
                    lineColor: red,
            lineWidth: 3.0,
            dotRadius: 5.0,
            dotColor: red,
                    showValues: true
                }),
                Timeplot.createPlotInfo({
                    id: "Events",
            timeZone:       11,
            eventSource: eventSource2,
                    timeGeometry: timeGeometry,
                    lineColor: red,
            theme: theme
                })
    ];

    timeplot = Timeplot.create(document.getElementById("TIMEPLOT"),
plotInfo);
    eventSource.loadPlotData(plot_data);
    eventSource2.loadXML(xml_events, '');

    var key = document.getElementById("TIMEPLOT_KEY");
    key.innerHTML = '<span style="color: #4682B4;"><b>Ad Call
Time</b></span> / <span style="color: #228B22;"><b>Referral Call
Time</b></span> / <span style="color: #DC143C;"><b>Content Delivery
Time</b></span>';

}


On Fri, Mar 6, 2009 at 9:27 AM, Adam Nelson <[email protected]> wrote:

> Scott,
>
> That will help alot.  It leads me to another question.  A little
> background:
>
> I'm trying to create a voting app that shows the probability of a number of
> outcomes happening historically.  I can pull that data as {datetime,score}
> for each possible outcome and then normalize it in JS with the other scores
> at that datetime so the probability of all the outcomes = 1 (or 100% -
> however you want to say it).  This would require me to generate the file
> whenever somebody requests it after somebody voted on that outcome.
>
> Or, I can pull the data pre-normalized, but then it would be best to pull
> the data like {outcome_id,datetime,normalized_score} which doesn't seem to
> be something that timeplot can handle AFAIK.  This would be the functional
> equivalent as the above situation but it's N-1 fewer queries where N is the
> number of outcomes.
>
> The third option is to simply generate a file for each possible outcome and
> update it every time somebody requests the data after somebody else voted on
> ANY outcome.
>
> Have you or anybody else dealt with this kind of situation?
>
> Thanks very much,
> Adam
>
> On Thu, Mar 5, 2009 at 5:08 PM, Scott Thomson <
> [email protected]> wrote:
>
>> I tooled around with it for a while... the timeplot data seems to support
>> JSON, but the timeline integration does not.
>>
>> <snip>
>>     timeplot = Timeplot.create(document.getElementById("TIMEPLOT"),
>> plotInfo);
>>     eventSource.loadPlotData(plot_data);  // JSON data
>>     eventSource2.loadXML(xml_events, ''); // XML data
>> </snip>
>>
>> I used a Java servlet to generate the timeplot JSON data and then used a
>> combination of DOJO and an xml.js library to generate the XML data for the
>> timeline.
>>
>> <snip>
>>    var xml_events;
>>     for (var i = 0; i < lastQuery.adcalls.length; i++)
>>     {
>>         var adcall = lastQuery.adcalls[i];
>>         var referral = lastQuery.adcalls[i].referrals[0];
>>         var response = referral.responses[0];
>>
>>         var row = new Array(4);
>>         row[0] = adcall.date; // Add date
>>         row[1] = adcall.time; // Add adcall time
>>         row[2] = referral.time; // Add referral time
>>         row[3] = response.time; // Add response time
>>
>>         // Add row to timeplot data
>>         plot_data[global_plot_data.length] = row;
>> :
>> //ellided
>> :
>>         var attr_str = '{start: "' + adcall.tl_date + '", ' +
>>                 'title: "Test #' + (global_event_count++) + '", ' +
>>                 'link: "' + escape(referral.url) + '"}';
>>         var attrs = eval('(' + attr_str + ')');
>>
>>         var desc = response.type + ' (' + response.length + ' bytes)';
>>
>>         xml_events += elementNL(
>>                 'event',
>>                 desc,
>>                 attrs
>>                 );
>>     }
>>     // Prepare XML
>>     var xml_txt = '<data>\n' + xml_events + '</data>';
>>     // alert(xml_txt);
>>
>>     var parser=new DOMParser();
>>     var eventsXMLDoc=parser.parseFromString(xml_txt,"text/xml");
>>
>>     // update Timplot
>>     if (plot_data.length > 1) {
>>         updateTimePlot(plot_data, eventsXMLDoc, width, height);
>>     }
>> </snip>
>>
>> The updateTimePlot function calls standard timeplot creation calls as per
>> the top of this email.
>>
>>
>>
>>
>>
>> On Fri, Mar 6, 2009 at 7:18 AM, Adam N <[email protected]> wrote:
>>
>>>
>>> Has anybody extended Timeplot to handle different data sources
>>> (specifically JSON)?  I'm new to the project so I'll probably just
>>> convert my data to the text format available - but I'd prefer to use
>>> JSON since everything I would typically spit out is JSON .
>>>
>>> Thanks.
>>>
>>>
>>
>>
>> --
>> Scott Thomson
>> 0401 726 889
>>
>>
>>
>>
>
>
> --
> Adam Nelson
>
> http://www.varud.com
> http://twitter.com/varud
> http://www.linkedin.com/in/adamcnelson
>
>
> >
>


-- 
Scott Thomson
0401 726 889

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to