What would be the the best way to get the current view/page in paginated scrollview?
There are only gotonextpage and gotoprevious page methods in scrollview. I know I have some data at hand on scrollview.sync.on('end') event, but that looks like I need to calculate my self the current view/page somehow. (like the Shine demo with scroller)
There must be some easier approach I haven't spotted.
in coffeescript:
coverView.on 'pageChange', (e) ->
p = coverView.getPosition() # some weird value
n = coverView._node.index
console.log('coverView', e, n, p)
however, this only seems to work in one direction :)
https://github.com/Famous/views/issues/67
Related
I'm looking for the equivalent of a html inline-block in swiftui. I basically want it to work exactly like list - but just wrap if it's going to exceed the line - eg
WrappingList( items ) {
Text( "item.name")
}
but I'm finding it way harder than I thought. I really want the things list brings to the table - ie incremental updates and scrolling, but I can't find a way of mapping it into the swift declarative style. In languages where you added controls procedurally, it's trivial:
current_x = 0
current_y = 0
foreach (var item in items )
{
control = create_control_for( item )
biggest_y = max( current_y + control.height, biggest_y)
if (control.width + current_x > width)
{
current_x=0;
current_y = biggest_y;
}
control.position = (current_x, current_y)
}
but swift seems to want to do things in hstacks or vstacks and I don't really know how do that and still keep the properties of a list - particularly without knowing the size of things in advance - ie I don't want a fixed grid.
Does such functionality already exist? If not, is there a way of mapping the above code line into SwiftUI?
just so there's an answer here - the comment above from asperi worked great - linking to this stack overflow article
I am trying to filter a 2D xtensor view with a simple condition. I found the xt::filter function, but when i use it, it only return the first column of the filtered view. I need the 2D filtered view. What is the best way to do it?
I could check the condition line by line, and get all the indexes myself, and the use xt::view to only show the needed lines, but i am hopig in a more sophisticated method using the xtensor toolset.
My current filter, which returns only one direction looks like this:
auto unfiltered = xt::view(...);
auto filtered = xt::filter(unfiltered, xt::view(unfiltered, xt::all(), 0) > tresh);
EDIT:
It is possible i was not completly clear. I need a 2D view where i kept only those lines, where the first element of the line is greater than the treshold.
xt::view(unfiltered, xt::all(), 0)
is creating a view that only contains the first column of unfiltered. The following should do what you expect:
auto unfiltered = xt::view(...);
auto filtered = xt::filter(unfiltered, unfiltered > tresh);
EDIT: sorry for the misunderstanding, here is an update following OP remark:
The condition is not broadcast to the shape of the expression to filter, a workaround for now is:
auto unfiltered = xt::view(...);
auto filtered = xt::filter(unfiltered,
xt::broadcast(xt::view(unfiltered, xt::all(), 0, xt::newaxis()),
unfiltered.shape()) > tresh);
I'll open an issue for this.
Also notice that filter returns a 1D expression (because the elements satisfying a condition may be scattered in the original expression), you need to reshape it to get a 2D expression.
I'm new to coding and have searched as best I can to find out how to solve this before asking.
I'm trying to pull information from poloniex.com REST api, which is in JSon format I believe. I can import the data, and work with it a little bit, but when I try to call and use the elements in the contained dictionaries, I get "'unicode' object not callable". How can I use this information? The end goal with this data is to pull the "BTC: "(volume)" for each coin pair and test if it is <100, and if not, append it to a new list.
The data is presented like this or you can see yourself at https://poloniex.com/public?command=return24hVolume:
{"BTC_LTC":{"BTC":"2.23248854","LTC":"87.10381314"},"BTC_NXT":{"BTC":"0.981616","NXT":"14145"}, ... "totalBTC":"81.89657704","totalLTC":"78.52083806"}
And my code I've been trying to get to work with currently looks like this(I've tried to iterate the information I want a million different ways, so I dunno what example to give for that part, but this is how I am importing the data):
returnvolume = urllib2.urlopen(urllib2.Request('https://poloniex.com/public?command=return24hVolume'))
coinvolume = json.loads(returnvolume.read())
coinvolume = dict(coinvolume)
No matter how I try to use the data I've pulled, I get an error stating:
"unicode' object not callable."
I'd really appreciate a little help, I'm concerned I may be approaching this the wrong way as I haven't been able to get anything to work, or maybe I'm just missing something rudimentary, I'm not sure.
Thank you very much for your time!
Thanks to another user, downshift, I have discovered the answer!
d = {}
for k, v in coinvolume.items():
try:
if float(v['BTC']) > 100:
d[k] = v
except KeyError:
d[k] = v
except TypeError:
if v > 100:
d[k] = k
This creates a new list, d, and adds every coin with a 'BTC' volume > 100 to this new list.
Thanks again downshift, and I hope this helps others as well!
I've been trying to graph only for the past few hours. I only want to graph the TRUE arguments of this ifelse statement
which(RawGame1$event_desc == "Off Rebound")
reb <- ifelse(RawGame1$event_desc_id == "O",1,"")
Right now whenever I try to plot with ggplot, I get a bar graph where 13/22 bars are the 3rd argument(pointless data) that skews the scales and dimensions horribly. How do i delete them? Am i trying to graph it wrong?
ggplot(RawGame1[,], aes(x = pid.first.char, fill = reb)) +
geom_bar() +
ggtitle("Off Reb by Player") +
xlab("Player") +
ylab("Total Rebounds")
There has to be a simpler way i don't know about!?!? New to R and appreciate any help. Be gentle.
It would be much easier to answer if you provided a sample of your data (at least what head(RawGame1) prints out), also what the plot looks like now and what's the goal.
But I see that you have brackets without any filtering condition in RawGame1[,] - if you intended to select only event_desc_id=="0" there, just write RawGame1[RawGame1$event_desc_id==0,].
I have a list within my application, but was wondering if it is possible to have each list displayed show a different background colour, rather than the same one through out each item?
I have created a template but would be nice to have the background of each change colour.
Thanks
EDIT: I have also created the same list via a 'Ext.dataview.component.DataItem' / 'DataView' so if this is easier to control separately then great, as I am looking at interfering in te process of creating each and setting its background, if that is at all possible.
You could try to do that with simply XTemplate:
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Company: {[values.company.toUpperCase() + ", " + values.title]}</p>',
'<p>Kids: ',
'<tpl for="kids">',
'<div class="{[xindex % 2 === 0 ? "even" : "odd"]}">',
'{name}',
'</div>',
'</tpl></p>'
);
take a look at their explanations, might find something interesting:
http://docs.sencha.com/touch/2-0/#!/api/Ext.XTemplate
I have seen many variants on the Ext.query('class').up().addCls('backgroundClass'); hack, which makes perfect sense to me, but my question is WHEN are people calling this? I can't put it in 'painted', since DOM doesn't seem to exist yet.. where/when are you guys executing the Ext.get(..) call?
I have been looking for this also, and I had a hard time finding out how to access the individual items of a xlist...
This is the way I finally did it:
in your itemTpl, add a class to your < div >, using the property 'id' of your model:
itemTpl:'< div class="my_list_item_{id}"> ... content ... < /div>'
the tricky part is that if you want to set the background color of the whole item area, you have to access to < div > with class 'x-item-label' that is wrapping your itemTpl < div >.
Here is how I did it (for the first item as an example):
Ext.select('.my_list_item_1').first().up('div.x-list-item-label').addCls('background_item');
where 'background_item' is a CSS style, defining your background color.
(Since there is no way (at least that I know of) to get the index count of your items in the 'itemTpl' config, I had to use to automatic 'id' property of my model/store.
Note that if you apply filtering/sorting/... on your store, this property will not be sorted anymore. So if you want to link the order displayed in your list to the 'id' property, you have to do something like 'Ext.StoreManager.get('MyStore').getAt(indexInList).get('id') )
Hope this helps...
Since Sencha Touch 2.2.1 it's also possible to use striped parameter (more info here). It will add x-list-item-odd class to odd items of your list.