Multiple formatter functions in Bokeh datatable - datatable

Is it possible to do multiple format types within one "formatter"? For example:
TableColumn(field="y", title="y",formatter=HTMLTemplateFormatter(), NumberFormatter(),DateFormatter())
etc

No it's not possible. Bokeh currently only accepts a single CellFormatter per TableColumn. You could try opening an issue on Bokeh's Github to allow thge formatter argument to accept a list of CellFormatters. Or, you may look into hooking up either a JS or python callback to the TableColumn to do some more sophisticated formatting.

Two and a half years later, but...... This is currently being developed now. Keep an eye on the Bokeh repo for addition of this function, hopefully in the near future.

Related

Using dimensions with arrays in dc.js/crossfilter

Crossfilter supports dimensions with arrays since version 1.4.0-alpha.06 https://github.com/crossfilter/crossfilter/wiki/API-Reference#dimension_with_arrays
Is it possible to exploit this functionality in dc.js?
I haven' found any examples yet... I am aware of the method described in Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?, but that works with earlier versions of crossfilter too (it does not make use of the new functionality).
With help from comments above, I managed to get this working, very simple indeed if you use the right version of crossfilter (1.4.0). Works fine with rowChart() and pieChart().
I made a an example bl.ock based on previous approaches:
http://bl.ocks.org/emiguevara/4bd152a8828f6b31270702d97dc0133d

Creating a new snip% with Racket

I am trying to create a new GUI element within DrRacket's text window, like picts or syntax objects. As far as I can tell, the most standard way of doing this is with a snip%.1
Unfortunately, the documentation for creating new snips, while comprehensive, is a bit impenetrable and leaves some questions to be answered.
For starters, what is the difference between a snip% and a snip-class%? Why do these need to be separated out into two classes, rather than simply being combined into one class? Is it because multiple snips will use one snip class?
Second off, what is snip-reader<%>? Not only why does it need to be a separate class, but why is the module providing it supposed to be installed?2 If it does need to be a new class, why can't it just be referred to directly. Why go through this whole process of constructing and then parsing a string of the form: "(lib ...)\n(lib ...)"?
I mean, there might now be any reason for this design, and it might just be a remnant of an old API. If so, has anyone thought of making a new more consistent API? Or if there is a reason for this design, can you please tell me what it is, as the docs don't seem to make that clear.
I mean, as of right now, I can copy/paste the sample given in the docs on creating a new snip. But I'm having a hard time understanding the design going on here, so I can use them properly.
1I know there are other ways to do it, but I also want to have interactive buttons and whatnot.
2I know it doesn't need to be installed as a library per se, but the documentation seems to strongly push you in that direction.
Okay, I think I finally found the answer. Broadly speaking:
The snip% class includes the methods for drawing the snip, telling the editor how much space to reserve for the picture, and handling events such as mouse clicks.
Next, the snip-class% class is used for encoding and decoding snips. This must be a separate class because when saved to a file, the editor needs to encode what type of snip it is, and for obvious reasons it can't just put the literal snip% class in there. The value it stores in the file is the snip-class%'s 'class name'. This can be anything, and as long as the editor has the classname associated to a snip-class%, it can be loaded. Additionally, if it is of the form "(lib ...)" or "(lib ...) (lib ...)" Racket will just automatically load it into the list for you.
Nothing 'needs' to be installed per se, its just the easiest way to go about it. Otherwise you manually need to tell the editor how to handle the snip before actually loading the file.

JFreeChart: Is there a way to draw long tick labels in two lines in XYPlot

I've got legacy code sample which uses JFreeChart and XYPlot. Now i'm making i18n for that code and most of non-english strings are much longer then english ones. I googled for a way to wrap strings. No success. Help please!
Try using setMaximumCategoryLabelLines method from CategoryAxis, e.g:
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setMaximumCategoryLabelLines(3);
Multiple lines are not supported. The setVerticalTickLabels() method may be applied to either a domain or a range axis. Because space is limited, interpreters should be frugal. Providing a user setting, as shown here, may mitigate the limitation.

Codeigniter pagination

I need two paginations on one page, is it possible to do this with codeigniter?!? Of course they must operate independently of one another.
Yes and no. If you want two different pagination visuals (customized renderings of the library) then sure. The problem you'll run into is by default the pagination library will pull the current page out of your $ci->uri->segments() list automatically to determine which page to mark as "active".
I do not know of a way to explicitly override this. Perhaps if you made a MY_Pagination that took an additional $config value for current page you could get it to behave like that. I haven't looked at the library's code in a while so you'd have to do some digging.
Honestly though, I'd suggest you build your own, it's not incredibly hard to do some simple math to determine what numbers to link.
Also you'll run into issues with CI's Pagination Library if you want the "current page" part to be NOT the last segment in your url. This may have been fixed lately but last time I looked it was the stop-gap for me using the library all together.
Bottom Line Invest the time in making your own if you want more than it's basic functionality, it's simple enough, just make yours reusable if you can.

Alternative script for YAML?

I was going to use yaml because it has great feature called merge! ("<<" key)
And I'm using 'yaml-cpp' for parser since i'm working on cpp.
But! yaml-cpp does not support merge. What can I do for alternatives?
Other scripts, other parser, other way to parse or whatever is good if I can use merge feature.
BUT I don't need to merge more than one object. I just need define something and create another object inheritd from the first one and override some values. That it.
Thanks for reading.
If you're unable to wait and need merges, you can follow the suggestion by "barma" on the yaml-cpp issue: http://code.google.com/p/yaml-cpp/issues/detail?id=41#c12
The change is to insert the lines below into FindValueForKey template (between for-loop and return 0):
const Node *pValueMerge = FindValueForKey(std::string("<<"));
if(pValueMerge) {
return pValueMerge->FindValueForKey(key);
}
The problem (as I mentioned on the issue page) is that the spec allows
<<: [*dict1, *dict2]
to merge multiple dictionaries; but it appears you don't need that.
Ask 'yaml-cpp' to implement the feature.
Problem
Using YAML merge keys.
Solution
Other scripts, other parser, other way to parse or whatever is good if I can use merge feature.
The following YAML implementations support the desired feature as of this writing
Ruby 2.x
Python 2.x // 3.x

Resources