Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: # C3 Rendering examples Daniel@0: Daniel@0: This is an example of how to use C3 graphics to illustrate the content in the DML collection. Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: :- use_rendering(c3). Daniel@0: Daniel@0: %% collection(-C:oneof([charm,bl]), -X:uri) is nondet. Daniel@0: collection(charm,X) :- rdf(X,charm:file_name,_). Daniel@0: collection(bl,X) :- rdf(X,rdf:type,mo:'Signal',bl_p2r). Daniel@0: Daniel@0: collection_property_value_count(Collection,Property,Value,Count) :- Daniel@0: aggregate(count, R^(collection(Collection,R), rdf_has(R,Property,Value)), Count). Daniel@0: Daniel@0: % Unfortunately rdf_meta is not legal in sandbox yet. Daniel@0: %:- rdf_meta collection_property_hist(+,r,+,-). Daniel@0: %% collection_property_hist(+C:atom, +P:uri, +Min:nonneg, -Chart:dict) is det. Daniel@0: collection_property_hist(Coll,P,Min,c3{data:_{columns:Pairs, type:pie}}) :- Daniel@0: rdf_global_id(P,Prop), % expand Namespace:Local resource representation Daniel@0: setof( [C,N], (collection_property_value_count(Coll,Prop,literal(C),N),N>Min), Pairs). Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: Next a little test that we can use this to get pairs of composer and count. Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: aggregate(count, X^(collection(charm,X), rdf_has(X,dml:composer,C)), N). Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: 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. Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: collection_property_hist(charm,dml:composer,25,Pairs). Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: Finally, a couple more distributions over language and composer in the BL collection. Press the white-on-green arrow to run the query. Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: collection_property_hist(bl,dc:language,150,Pairs). Daniel@0:
Daniel@0: Daniel@0:
Daniel@0: % top 20 composers Daniel@0: collection_property_hist(bl,dml:composer,20,Pairs). Daniel@0:
Daniel@0: Daniel@0: