Mercurial > hg > dml-open-cliopatria
comparison cpack/dml/examples/c3examples.swinb @ 0:718306e29690 tip
commiting public release
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 21:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:718306e29690 |
---|---|
1 <div class="notebook"> | |
2 | |
3 <div class="nb-cell markdown"> | |
4 # C3 Rendering examples | |
5 | |
6 This is an example of how to use C3 graphics to illustrate the content in the DML collection. | |
7 </div> | |
8 | |
9 <div class="nb-cell program"> | |
10 :- use_rendering(c3). | |
11 | |
12 %% collection(-C:oneof([charm,bl]), -X:uri) is nondet. | |
13 collection(charm,X) :- rdf(X,charm:file_name,_). | |
14 collection(bl,X) :- rdf(X,rdf:type,mo:'Signal',bl_p2r). | |
15 | |
16 collection_property_value_count(Collection,Property,Value,Count) :- | |
17 aggregate(count, R^(collection(Collection,R), rdf_has(R,Property,Value)), Count). | |
18 | |
19 % Unfortunately rdf_meta is not legal in sandbox yet. | |
20 %:- rdf_meta collection_property_hist(+,r,+,-). | |
21 %% collection_property_hist(+C:atom, +P:uri, +Min:nonneg, -Chart:dict) is det. | |
22 collection_property_hist(Coll,P,Min,c3{data:_{columns:Pairs, type:pie}}) :- | |
23 rdf_global_id(P,Prop), % expand Namespace:Local resource representation | |
24 setof( [C,N], (collection_property_value_count(Coll,Prop,literal(C),N),N>Min), Pairs). | |
25 </div> | |
26 | |
27 <div class="nb-cell markdown"> | |
28 Next a little test that we can use this to get pairs of composer and count. | |
29 </div> | |
30 | |
31 <div class="nb-cell query" data-tabled="true"> | |
32 aggregate(count, X^(collection(charm,X), rdf_has(X,dml:composer,C)), N). | |
33 </div> | |
34 | |
35 <div class="nb-cell markdown"> | |
36 Next a pie chart showing the proportions of different composers in the CHARM collection. (This query should run automatically when this notebook loads). If you click on the labels in the legend, that segment is removed and the pie redrawn. | |
37 </div> | |
38 | |
39 <div class="nb-cell query" data-run="onload"> | |
40 collection_property_hist(charm,dml:composer,25,Pairs). | |
41 </div> | |
42 | |
43 <div class="nb-cell markdown"> | |
44 Finally, a couple more distributions over language and composer in the BL collection. Press the white-on-green arrow to run the query. | |
45 </div> | |
46 | |
47 <div class="nb-cell query"> | |
48 collection_property_hist(bl,dc:language,150,Pairs). | |
49 </div> | |
50 | |
51 <div class="nb-cell query"> | |
52 % top 20 composers | |
53 collection_property_hist(bl,dml:composer,20,Pairs). | |
54 </div> | |
55 | |
56 </div> |