whitemx / xcontrols-domino

A mobile and desktop XPages development framework, from Teamstudio.
http://xcontrols.org
Apache License 2.0
18 stars 10 forks source link

Using nsf data in Bootcard charts? #253

Closed bgewehr closed 9 years ago

bgewehr commented 9 years ago

Are there any examples for using nsf data in bootcard charts? All existing examples are hard coded chart data...

whitemx commented 9 years ago

If you download the Sampler application from OpenNTF there are numerous examples with Domino data. Simplest to get going would be to look at the FlatView XPage.

whitemx commented 9 years ago

Apologies, I misread the question. At the moment we don't have any examples, but it would be pretty simple to set up. I'll add it to the list for a future release.

markleusink commented 9 years ago

If you want to get started with that today: here's a sample: https://gist.github.com/markleusink/e49950dbd92a955e9d62

PatrickKwinten commented 9 years ago

The sample Mark provides demonstrates how the beforepageload event of an Xpage can be used to create a data object.

Because this event can run SSJS it is fairly easy to access a Notes view and place the data inside a viewscope variable which you access with clientside javascript when you build the chart.

Depending on your requirements/the information you want to display you should build your view or your SSJS to populate the data.

There are plenty of samples online how to access and go through a Notes view with SSJS.

The bootcards documentation provides a very simple sample of a chart http://bootcards.org/public/docs.html#doc-chartcard I wonder if more advanced charting is possible?

bgewehr commented 9 years ago

OK and thank you for this! We are looking for another use case: We are using the nice ininite scroll list view on costcenters and on the customControl CostCenterViewer we can pull some basic data and analytics data from the corresponding costcenter.nsf document. Now we want to put some graphics into the costcenter Bootcard inline with the basic data. Since this differs from the approach you noted before, we can not use the population from a domino view in the beforepageload event, we need to pull some javascript-arrays of values from multivalued domino fields and we need a refresh graph command each time the CostcenterViewer Bootcard refreshes... We are looking for something like this: mobile app kostenstelle 2

markleusink commented 9 years ago

The way I'd approach that is by creating a couple of XPages that output the data in JSON format. Add URL parameters to specify the target document(s) it should retrieve that data from.

Then, write the JavaScript that makes the Ajax calls to those XPages to populate the charts with data.

The chart library used in Bootcards (Morris.js) runs clientside and has methods to update it with new data.

bgewehr commented 9 years ago

OK, we managed the data request from ndomino multiple value fields to Javascript arrays and now we look after the refresh methods for morris for the (document).ready event... It was easier than i thought: <![CDATA[#{javascript://generate the data set here: you could loop through a view for example var chartData = []; var tmp1 = docview.getItemValueArray("STAT_GENDER_NAMES"); var tmp2 = docview.getItemValueArray("STAT_GENDER_FTE"); chartData.push( {y : tmp1[0], a : tmp2[0]}); chartData.push( {y : tmp1[1], a : tmp2[1]}); viewScope.put("chartData", toJson(chartData)); }]]>

bgewehr commented 9 years ago

Seems weird to catch data via parametered xpages which is already available in the loaded document... maybe we just write the json data into a hidden div and catch it from there in the client side Morris Javascript. So the performance may be much better...

jennyanthony commented 9 years ago

Same question for the workspace badges. The examples are hard coded from a view. It would make more sense to allow the value to be computed so it can change dynamically. Is there a way to calculate the badge value dynamically?

bgewehr commented 9 years ago

There seem to be various use cases for chart and workspace cards data requests:

We should collect the solutions for deciding a best practice... Actually we are working on the current document issue. Our current solution fails in passing the field informations over to a JSON object for the client side morris.js script. Anybody solved that yet?

whitemx commented 9 years ago

In my view that is the best solution. It gives plenty of flexibility.

One alternative would be that you could produce an XPage that runs as an XAgent (http://www.wissel.net/blog/d6plinks/shwl-7mgfbn) and returns a JSONP page http://en.wikipedia.org/wiki/JSONP