I have a term reference field on a content type. The vocabulary has two levels. I need to be able to show only the top level terms.
What is saved in the field:
X Fruit
X Apple
X Orange
- Veggie
- Carrot
- Green Bean
X Candy
- Lollypop
- Chocolate
What I want:
Title: The Title
Categories: Fruit, Candy
Another Field: data
What I get:
Title: The Title
Categories: Fruit, Apple, Orange, Candy
Another Field: data
I am even fine with getting them all back but at least having the distinction what is top level so I can hide the others. I am trying to do this in a views block. I found answers on how to do this if I only wanted the terms, but I need more data from the node then that.
After sucking up way to many hours on this project... I got it working by modifying the Hierarchical Term Formatter module: https://drupal.org/project/hierarchical_term_formatter
By telling it to show only top level term, it would give me a list like this: Fruit, Fruit, Fruit, Candy
I went in and added a line to remove duplicate array values (using code I found here: How to remove duplicate values from a multi-dimensional array in PHP). I added it right about the return for hierarchical_term_formatter_field_formatter_view .
I now get the result I was looking for: Fruit, Candy
(PS I am not sure how I submit this to the creator of the module. I don't think it's necessarily a bug, but it could expand it's uses. I do not have experience in community coding projects.)
Related
How do I create datavisual shapes for R package.
Just like there are heatmaps, bar charts, pie charts, etc.
For instance, I wish to create a car as a datavisual shape in R. Perhaps use it as a map. And give users the options to label the components
What do I search in google to create such a thing?
For instance I would like R (I'm used to R) to generate a user-input program where
product-to-repair-tires will point to tires
tire-pressure will point to each of the 4 tires
number-of-oil-changes will point to oil tank
type-of-fuel (variables gasoline,diesel,liquified petroleum,etc) will point to fuel tank.
I want this custom visual to
Have words and/or icons pointing to it
Be treated as a map. For instance, tires passed inspection by 80%, brake pads passed by 20% (hence need a replacement), windshield wipers are 100% perfect, bumper is can widthstand impact 30% (need replacement)
Can be used to demonstrate car health over time. We can include this in a report like Carfax that show when the Car was manufactured to possible accidents, defects as it passed owners.
In other words, custom visual should tell the life and health of a car in few words.
This is my first StackOverflow post. I think my main problem here is not having the vocabulary to ask this question, but I'll try my best below.
I have data with the following structure.
Neighborhood Dominant.Discipline Rent.vs.Own ADA.Compliant
Alki Heritage O Y
Ballard Multi-use Don't.know Partial
Ballard CommunityCenter R Partial
Belltown Music O N
As you can see, I have more than one instance of a neighborhood, more than one instance of the Dominant.Discipline, of Rent.vs.Own and ADA.Complianct.
What I want to do is create a visualizations by taking a particular neighborhood, only pick the spaces that are rented and have some ADA.compliant status.
I then want to compare other neighborhoods on the same parameters on a Treemap. How do I achieve this?
My ideal treemap will display various neighborhoods, the surface area will represent the number of rented spaces, and the colors will represent the ADA compliance status. Red being "N", Blue being "Y", and yellow being "I don't know."
Please excuse me if I may be unclear. I'm just trying to wrap my head around this.
I am totally lost for an easy plot. All i want to do is something like a dendrogram, but without any calculations. A simple, treelike structure to show which subcategories belongs to which category and so on.
My columns are looking like this:
category, subcategory, sub-subcategory, n
filled with strings. There are 4 categories and multiple split downs. There are no duplicates, each sub-subcategory is distinct to one subcategory and one category. Dont really need to be able to plot n aswell.
I guess what i am missing is the real name for such a diagram. Whatever I google, I always just find classification trees or dendrograms, which both is way too much for my needs.
It would be awesome if someone can give me some hints.
I'm working with a lot of rank data that would benefit from a way to simultaneously display its respective year on the x-axis. For example, I want to create the following graph adapted from the dygraph gallery:
Note how the rank information (red arrow) for a particular weekend (green arrow) are both displayed on the x axis.
I know this might not be possible with dygraphs now, at least it wasn't available in these demos, so I guess my follow up question would be are there any plans to make this possible (how about in the [r] {dygraph} package)? Apparently a plotter called flot can do this.
UPDATE 1
If indeed this feature does not exist yet, then the following, although potentially obvious to Dygraph developers, is a thought for accomplishing the task easily (perhaps I'm wrong). At first I thought it would be necessary to provide input data of the form shown in Table A
However such input is a major deviation from the existing Dygraph parser model who expects one abscissa. Such suggests that a modification to the parser to accept a "Dual Label" option, requiring that both labels be contained in a single abscissa element as in Table B, would be easier. Thereafter, with the option specified, the parser would manage CSV as it usually would with the exception that it is now "bin cognizant" and detects division between labels 1 and 2 by use of an acceptable delimiter (in this case a single quotation mark - maybe not the best choice) and divisions between label 1 abscissa elements by name change. Behind the scenes each point gets its unique x coordinate and the "Dual Label" option causes the dygraph to visually scoot up a couple pixels to accommodate an extra label. Not sure how to handle full zoomed scrolling put simply leaving a label 1 element centered until an adjacent label 1 element comes on screen is an option.
Dygraphs rule!
There's no simple way to do this with dygraphs now. As you say, there's a fairly deep assumption that there's only a single x-axis.
Your best bet would be to either modify the existing legend plugin to do this, or to create a new plugin which renders just the "Weekend 1", "Weekend 2" line. While the plugins API isn't official yet, it is at least somewhat documented.
If you get this to work, please share your code!
Hi I am making a report of a survey where we have what we call a "radiomatrix" and it looks like this.
alt text http://img193.imageshack.us/img193/9288/radiomatrix.png
Then we import the answers is a table in R into something that looks like this:
user tiramisu cupcake chocolate carrot
test01 loves_it loves_it loves_it hate_it
test02 likes_it likes_it loves_it likes_it
test03 likes_it loves_it loves_it hate_it
What would be the best and most meaningful graphical representation for this?
One of the things I would do is to constract a contingency table and then perform correspondence analysis (look fot it here), to produce something like this
Another one is that I would try to show correlations between preferences (something like this)
Perhaps one could also mine association rules, e.g.
If Loves Tiramisu then hates Cupcake
If you would like to create mosaic plots with R, check out this.
There isn't a "best" representation for any given set of data. It depends on what you're trying to show. Some examples:
If you want to test the hypothesis that people are extreme about their cake preferences -- that is, that there are very few likes vs. loves/hates -- you could show a plot of preference intensity versus quantity.
If you want to show that chocolate is more preferred than tiramisu, you could use a simple table that assigns -1 to "hate", 0 to "like", and 1 to "love" to come up with a mean/median score for each dessert.
A mosaic plot might be interesting. See here (PDF) for examples.