Accessing value attribute in Protovis lines - protovis

I'm using Protovis Arc layout and I'd like to color links between nodes accoriding to the 'value' property defined in dataset. How can I access it?
Dataset is defined like that:
Nodes:
...
{nodeName:"Books"}
...
Links:
...
{source:1, target:4, value:20}
...
arc.link.add(pv.Line).strokeStyle(function(d) d.value > 10 ? "#cc0000" : "#eeeeee"); - does not work

The d property refers to the node. There's no value attribute defined on the node in this case; the link weights are defined on the links, which is why the property function isn't doing what you expect.
You can rewrite your property function to access the link (rather than node) data. The link data is associated with the link's parent panel, and is available as the second argument:
.strokeStyle(function(d, p) p.value > 10 ? "#c00" : "#eee")
There's more of an explanation in the layout documentation. And see also the pv.Layout.Network API reference:
The link mark is added to a child
panel, whose data property is
defined as layout's links property.
The link's data property is then a
two-element array of the source node
and target node. Thus, poperties such
as strokeStyle and fillStyle can
be overridden to compute properties
from either the node data (the first
argument) or the link data (the second
argument; the parent panel data)
dynamically.

Related

Group AEM (6.2) component configurations

I'm currently building a component that has TouchUI configuration properties separated with three tabs (Standard, CASL, GDPR). Each tab has the same set of options available and my current config names are similar to the following:
./standardMarketingText
./standardThirdpartyText
./gdprMarketingText
./gdprThirdpartyText
./caslMarketingText
./caslThirdpartyText
(There are several other options for standard,gdpr,casl but I left them out for brevity)
While this works, I'm hoping to instead store the values in the JCR as a JSON node per category. For example:
casl = {"marketingText"="m test", "thirdpartyText"="tp test"}
gdpr = {"marketingText"="gdpr m test", "thirdpartyText"="gdpr tp test"}
This way I can load all "casl" (or others) options at once when I need them (there isn't a case where I would only load one "casl" option)
I have attempted using granite/ui/components/foundation/form/multifield however, it asks to "Add field". I only want one set of each, and not provide the ability to add another set of properties under each tab. Is there a way to accomplish this without overriding the multifield resourceType?
There are multiple ways to achieve what you are looking at, I would look at the reusability as there are similar named properties for different categories (in your case tabs). To group them you could do that at node level by correctly defining the name property for each tab.
For above provided values, you could do something like -
./standard/marketingText
./standard/thirdpartyText
./gdpr/marketingText
./gdpr/thirdpartyText
./casl/marketingText
./casl/thirdpartyText
Your each tab stores the properties in named node (standard, gdpr, casl). In addition you could have a single SlingModel/WCMUsePojo that can adapt to these nodes to provide the Pojo with accessor to property values.
As far as getting JSON is concerned, your SlingModel or WCMUsePojo can provide a method to return JSON based string for the values.

Querybuilder | access property for which path is not fixed

Normally I would use filter for property like cq:tags as mentioned below. Here I know where cq:tags property exists in content structure:
group.5_group.fulltext.relPath=jcr:content/#cq:tags
group.5_group.fulltext=*location*
For any page where I can drop any number of component and property is inside component node, how will I add filter for such properties.
E.g. My component name is component and prop is property. Some exmaple path for porp can be jcr:content/mainParsys/component/#prop or jcr:content/mainParsys/componen_anyrandomValue/#prop
group.5_group.fulltext.relPath=what_should_be_the_path_or_filter
group.5_group.fulltext=*location*
Why are you trying to search through path if it's undefined?
You can go with the resourceType of the component as it will remain same and try your query in Query Debugger as:
type=nt:unstructured
1_property=sling:resourceType
1_property.value=my-project/components/content/component
2_property=myprop
2_property.operation=exists
It worked for me to search for a property inside a component.

Difference between currentstyle and currentdesign in AEM

In AEM speak - what is the exact conceptual difference between between currentstyle and currentdesign objects available after including the tag in template / component?
Just to add some clarify to what's already here:
Global content (that is, component values that are common across multiple instances of the same template) are stored as "styles" and edited via a "design dialog".
They are stored as follows:
/etc/designs/<design>/jcr:content/<template>/<component>
So, for the component logo in the template homepage, using the default design:
currentStyle is /etc/designs/default/jcr:content/homepage/logo
currentDesign is /etc/designs/default
currentStyle is of type com.day.cq.wcm.api.designer.Style(1) whereas currentDesign is an instance of com.day.cq.wcm.api.designer.Design (2).
The Design object contains information about the design that is used with the current object, it is most of the time set in the cq:designPath property of the page's template.
If you have the Design object, you can get Style objects for each included Cell(3) from it. On the other hand you can get the surrounding Design, if you have the Style.
So the Design is something like a container object for the Styles used in the included Cells.
In this path
/etc/designs/geometrixx/jcr:content/page/image
image is a Cell, the design path is /etc/designs/geometrixx and the Style object attached to the Cell object has two properties: maxHeight and maxWidth.
(1): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Design.html
(2): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Style.html
(3): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Cell.html
I would say it is more like:
/etc/designs/<design>/jcr:content/<resource-type-of-page>/<component>
so that different templates having the same page resource type will share the same style

Access jcr:content propeties from page node

I have dropdown where the values of options are like jcr:content/jcr:title, jcr:content/jcr:description, /jcr:content/par/entry/text etc. Here the last one is the property of parent, like jcr:title is the property of jcr:content node & text is the property of entry node, but entry has parent par and par has parent jcr:content. I am at the page node and using the below code to fetch such values which doesn't work :
Node n = (Node)nodeIter.next();
log.info(n.getProperty("/jcr:content/par/entry/text"));
Any Idea how to get values in such a way.
Thanks
Remove the starting slash from the property path. It makes the path absolute while you are interested in the relative one (as in other examples you've described):
n.getProperty("jcr:content/par/entry/text");

Get parent element name in XPath

I am trying to figure out how to get the name of the parent from a text node's scope.
//text()[name(parent)='p']
How can you get the name of the current node's parent?
If you're trying to test the name, you almost had it:
//text()[name(parent::*)='p']
If you're trying to return the name:
name(//text()/parent::*)
FYI, point of terminology: a text node is not an element.
Anyway, the most succinct way to select the parent of the current node is ..
So, the name of the parent element of the current node (which could be a text node) is name(..)
Substituting that into your XPath expression:
//text()[name(..)='p']
But a less roundabout way to write that would be
//p/text()
(assuming the p elements in the document have no namespace prefix). Either way, you're selecting all text nodes that are children of elements named p.
//text/..[#name='p']
This will get all parents of <text> nodes as long as the parent has a name attribute of p.