Is there a way to create a dimension on a attribute that has one or more values? For example
{quantity: 2, total: 190, tip: 100, items: ["apple","sandwich"],
{quantity: 2, total: 190, tip: 100, items: ["ice-cream"]},
{quantity: 1, total: 300, tip: 200, items: ["apple", "coffee"]}
My goal is to create a cross filter that can filter out entries along a dimension that has ordinal values. Is there a way I write a filter/dimension that will allow me to say "I want all entries that have the item 'apple'"?
The only workaround i can think of is to create a dimension for each item. Like so:
var paymentsByApple = payments.dimension(function(d) { return $.inArray("apple", d.items); });
var paymentsByCoffee = payments.dimension(function(d) { return $.inArray("coffee", d.items); });
// and one for every possible item
The main problem is that I don't want to enumerate and hard code all the different objects. Moreover, I may end up having lots of possible different items. Is there a smarter way to do this?
Thanks in advance!