How do I get the current filter for a crossfilter dimension? - crossfilter

I have a crossfilter.dimension. How do I get the current filter set on it (for example if it was set by a brush from a chart)?
Example:
dimension.filterRange([1,15]) // returns dimension
Given this filtered dimension, how do I get the values 1 and 15 out?

Stumbled on this old question because it is the top-voted unanswered crossfilter question, with 1k views!
This feature was contributed by Thomas Gillet in 1.4.5 as dimension.currentFilter()
The tough remaining problem: when you get beyond filterExact and filterRange, the more complex filters use filterFunction. You might be able to retrieve the function but functions are essentially opaque.
For example, if you are using dc.js, it will generate a filter function when
multiple items are selected in pie chart, row chart, or bar chart with ordinal dimension
the chart has a two-dimensional filter, like the scatter plot or the heatmap
For this reason, if you're using dc.js, you should use chart.filters() instead.

Thank you, Gordon. This was really helpful to me! One note - your link is correct -- it goes to filters(), but the text displays as chart.filter() which is in the API, but doesn't return multiple filters on a chart. I tried to edit your answer, but it won't allow single character changes!

Related

Ignore time gaps in QCPFinancial

When feeding the QCPFinancial chart from QCustomPlot (http://www.qcustomplot.com) with data which has gaps (weekends, nights without trading) then these gaps are visible along the x-axis in the chart as well.
Is there a way to tell QCPFinancial to ignore missing x-values so that for instance price on Monday is directly plottet after price from Friday?
Regards,
According to QCustomPlot forums (https://www.qcustomplot.com/index.php/support/forum/670), currently there's no any built-in functionality for this.
General workaround seems to be something like this:
Substitue "key" values with actual continuous data (one may use just plain integer indexes 0..N).
[Optional] Save a "mapping" to and from original key values.
[Optional] Subclass QCPAxisTickerDateTime (or general QCPAxisTicker) and implement custom method for creating tick labels, using previously mapped keys.

JAVAFX 8 Chart: get style of existing plotted series

This is a follow up to this question which has to that day still 0 answers.
What I really want to do is having in a tableview, a column that has the symbol for the plotted data corresponding to the objects in the table view row. I have managed to generate the colours supposedly followed by the JavaFX chart. The issue I have of course is that my own colour generation works (it goes back to the first colour without fail after 8 elements), when the one from the chart has the issue outlined in my unanswered question.
So.
I would like now to try to pick up the style actually applied to each series of the chart independently from pre-supposed rule about the default order of colours. How do I do that?
This way I could apply those to my table view and even if the colours randomly change upon reloading then at least I will know what I am looking at.
Thanks in advance for your help.
After a bit of research I found that the following code allows me to get what I want, supposing I am interested in the series at index intitem:
plotswingschart.getData().get(intitem).getNode().getStyleClass();
This will produce a ObservableList containing the following string values (here example for the series at index 8 (9th series)):
chart-series-line
series8
default-color2
From this I can then get the information that I need. that is the colour actually applied to that curve. I can then generate a symbol to be used in my tableview.
I would still be interested in an answer to the question linked, which prompted the present question...

How to create a dyraph with multiple x-axis labels?

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!

Is it possible to create a pie in pie chart in SPSS or R?

I know it is possible to create such double pie charts in excel like this:
http://chandoo.org/wp/2009/12/02/group-small-slices-in-pie-charts/
but can SPSS or R do this also?
In relation to R:
The answer to the title question is "yes" ... see ?pie
As for the second question, the one in the body - it would be possible but would involve some coding. You'd have to draw two pie charts side by side (which could be managed with two calls to pie) and use segments or arrows (and text if necessary) to do the additional components of the plot.
Here's a rough example:
That required the fig argument of par to get them side-by-side.
(That example required a little fiddling to get right, but it would be possible to write a function to automate the details.)
The main issue I can see would be 'why on earth would you do it?' -- pie charts are a poor way of conveying information of this form. There are alternatives that result in much better ability to distinguish values, and less bias (such as what you get when comparing nearly horizontal vs nearly vertical slices).

LineChart problem

I have an array of objects looking like this
obj.date=23/02/2010, obj.regType=0,
obj.value=1000;
obj.date=23/03/2010, obj.regType=0,
obj.value=500;
obj.date=23/02/2010, obj.regType=1,
obj.value=500;
obj.date=23/04/2010, obj.regType=1,
obj.value=1000;
I want the line series to be by regType. On the x-axis to have the dates and on the y-axis to have the values.
Is it possible to do that? because i looked on the internet and the examples did not help me.
Thank you
Might as well add this as an answer:
No need for Drawing API. If you can arrange those objects into two separate collections by regType most of the work is done. Then create two LineSeries with xField set to date and yField to value and bind one collection for each as a dataProvider.
New minimal example where collection manipulation is handled quite nicely with ListCollectionView:
http://pastebin.com/jkyn2UEz

Resources