Horizontal Label on DateTimeAxis dissappears sometimes after changing data, why? - apache-flex

I'm working with an Adobe Flex project and I have data I'm plotting against a DateTimeAxis (X-axis) but because there are a lot of points, I have to do some manipulation and remove some objects in the array (I do this by copying data to another array, removing items, then copying the new array into the original array). However, sometimes after I do this, the date labels disappear off of the x-axis! Why does this happen? I look through my array and I cannot find a reason its occurring (no objects with nothing in them, everything appears in chronological order). Any ideas?

I have the same problem. It appears the DateTimeAxis is a buggy component. Try to set the disabledDays property to [].
Also, the DateTimeAxis is sometimes not able to compute proper values for its labels, so it simply displays nothing. I guess...
BTW, have you tied to use the slice method to give a piece of your original data to your chart, instead of performing add and remove manipulations ? It could be faster...

Related

Accessing a Components Property prior to the Instantiation

I have the following problem:
I have a list of Components, that contain Rectangles with a width of either 200 or 800. I'd like to filter this list, and only create objects of the Rectangles with a width of 200 as I work on a small screen.
Preferably I do not want to create all objects, check their width, and destroy those with the wrong width again. For obvious reasons I really only want to create those with a width of 200.
To do this I would need to aquire knowledge of the width, before I instantiate them.
As far as I have seen, there is no publicly available and documented way of introspecting/reflecting the Component prior to it's instantiation.
My question is: Is there a non-public way to gain knowledge about what is packaged inside of my Component? Might it be possible with C++?
Or would it at least be possible to find out what kind of Object is encapsulated? Whether it will be a CustomComponent1, a Button, a RedRectangle...
Unfortunately not. You can't even predict it, since the Component could even point to a qml file that hasn't even been downloaded yet, if it was fetched from the network.
There are a couple of things you can try though, if you have room to approach the problem from another angle:
What you can do is pass properties from outside the component into it as it gets created. Assuming you control the code within the Component, you can then adjust how the internal elements get created based on the value of the property(ies) that was(were) set from outside.
If that's not good enough, say your Component provides multiple elements and you only want to create the ones that match your criteria (possibly a combination of many), then you can introduce a second Component layer within the first Component, and have that second Component either create the actual element if it matches your criteria, or an empty Item{} if it doesn't, which is as close as it gets to not creating anything.
I hope that helps!

Changing QGraphicsScene Insertion Order Without Reloading

I'm working on a graphical shape editor that uses the QGraphicsScene/QGraphicsView as its basis. I have a lot of experience with the scene/view framework and understand it fairly well. The issue that I'm having is that QGraphicsScene::items always returns items in the insertion order (either ascending or descending) regardless of the Z-order or the use of QGraphicsItem::stackBefore call.
The issue is that, as with most graphics editors, I need to be able to move shapes forward or backward in the stacking order. At the end, to save the resulting data, I have to traverse the list of the items in the scene and save each item's data in whatever format I'm using.
The only way that I've found to do this is that I have to remove items from the scene and reinsert them in the desired stacking order. In this particular task, it's a small number of items and happens without noticeable delay, but in a related editor, it could be many thousands.
While the QGraphicsItem::zValue and QGraphicsItem::stackBefore allow me to influence the drawing order, neither of them changes the order that gets returned from QGraphicsScene::items. Since the data I ultimately save needs to reflect the drawing order, I have to remove and reinsert to get the correct ordering at the end.
Questions:
Have I've overlooked any other techniques for managing items within the scene that will influence the results of QGraphicsItem::items?
Or is there another method for traversing the items within the scene that will give me the drawing order?
I can confirm that QGraphicsScene::items() and items(sortOrder) return the item list in the original creation and stacking order, which does not at all agree with the docs.
However, I found that by using
QGraphicsScene::items( QGraphicsScene::itemsBoundingRect, Qt::IntersectsItemBoundingRect, sortOrder) I do get the items in the correct drawing order, so this function apparently takes calls to QGraphicsItem::stackBefore() into account.
i don't use the z-order feature so I can't comment on whether that works in this scenario or not.

Shinobi charts recreating every time

I am using shinobicharts ChartFragment. I have scenario that each time I have to load the chart with different data within same activity i.e I am not recreating that activity. But I am failed to do this. It not recreating and not clearing the series which I previously set to that chart.
Can anybody help, how can I remove old series in that chart and load new series each time? I tried shinobiChart().removeSeries() but it didn't work.
Thanks
If you wish to dynamically load new data, you do not necessarily need to remove the series. Instead you can simply add data points to your data adapter. You will find the following methods useful:
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#add(int, com.shinobicontrols.charts.Data)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#add(com.shinobicontrols.charts.Data)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#addAll(int, java.util.Collection>)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#addAll(java.util.Collection>)
In these api docs you will also find similar methods to remove data points.
One thing to bear in mind is that adding or removing a data point to / from a SimpleDataAdapter class instance which is set on a series will trigger a redraw of that series. If you are working with large numbers of data points, this might not be performant. In this case a more suitable approach might be to temporarily remove the data adapter from the series, perform the modification to the data and then re add the data adapter back to the series. Alternatively you might like to implement your own DataAdapter and control when you instruct the chart to redraw that series (via the fireUpdateHandler method).
You can of course remove the series itself and add a new one, but this approach is potentially inefficient. That said, if you wish to remove a series from a chart you need to use the following method:
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.html#removeSeries(com.shinobicontrols.charts.Series)
In order for this method to be successful you will first need to obtain a reference to the correct series, which you must pass to this method as a parameter.
I hope that you find this information useful. If you need any further help please if possible post any relevant code, such as that which you use to create your fragments and set up your chart.
Thanks and kind regards,
Kai.
Disclaimer - I work for ShinobiControls.

Adding one point to a flex line series without everything getting redrawn

I have an air app that collects live data from a user's action and graphs it. It records data every second and charts it on three different line series from the same array collection.
This works out great at first, but it gets worse and worse as time goes by. When it gets close to an hour it's almost unusable.
I'd like to be able to add a point to the graph and have flex JUST draw the new point and not invalidate the whole series and redraw it. Is this possible? I'm willing to override something to make this work.
My last ditch effort is to take the average of 5 or 10 points and only adding those. This will still work poorly when the user is going for 3 hours or so, but I can't think of a better way.
First, I wouldn't use ArrayCollection, but ArrayList since it's faster than ArrayCollection. Even better would to use VectorCollection.
Second, the Flex charts are made to be easy to use, but not very good at going 'outside the specs'. What you'll need to do is override the core functionality of the chart altogether for this to work, however that is a fairly daunting task because of the sheer amount of code involved in charts.
I would recommend you either create your own very quick and dirty component that draws the lines (it's fairly easy, I've done it myself) or use another charting library out there like Flare.
I added a UIComponent that overlaid the whole graph. I then used a cartesiandatacanvas to convert the current data point to x/y coordinates on the screen and did a lineTo to draw from the last point.
This lets me keep drawing the graph without a total reload of the data.
Each point is inserted into a sqlite db. If the chart is resized I clear the uiComponent.graphics and query the sqlite db and bind the data to it. If the user plays the chart from there I leave the currently drawn lines on the chart and continue using the above method.

Dojo datagrid and treegrid help - datagrid has a reformating flash?

I'm having a bit of a time trying to get Dojo grids (1.5) to play nice. Specifically I've spent about two weeks of work trying to implement a grid that allows for our result set data to collapse into rows, where rows can be expanded. Data comes in as a full set in JSON format, using ItemFileReadStore as the store. Any subsequent sorts or pagings are handled by GETing a new json from the application, and passing in new query parameters in the url.
The nested data was only two layers deep - a top layer to always be displayed and an array of child data with identical structure as the top layer. Each node has a unique ID and a cluster ID - on a parent node the unique ID and cluster ID will match.
I was initially very excited with TreeGrid - but I couldn't see how I could format it to do what I needed - namely eliminate the 'summary row' and one extra row full of null cells (???) that I just couldnt figure out how to remove unless I focused the query to only one cluster. I studied the test examples, built many test pages myself, tried to understand the forestModel, which for what I could tell was unnecessary... I found so little documentation, and sources I found online hinted that TreeGrid might not be reliable...
So I decided I would try to implement the expandable/collapsible rows in dataGrid.
I flattened the JSON data and added another attribute to indicate being a top level node ('alwaysShow' = true). I built my grid programaticaly and applied grid.filter() to pull only those top level nodes. I modified that filter by extending the ItemFileReadStore _FetchItems "filter" method to allow for OR querying instead of AND, and also modified it to allow for keys to point to arrays - when a top level node (small +/- icon in the cell) is clicked, the cluster ID of the parent node is added to the grid.filter.allowed[] and the filter is updated, allowing nodes with that cluster_id value to be displayed.
This worked fine on my small test set of five records (although id say a little slugish...) - but now I am pulling ~900 rows back from the application, and on expanding large clusters (~80 rows) I am seeing a very long flash of blue and white on the filter updates. I've spent most of my day trying to step through in firebug to find where its happening, but the dojo logic is so spread out. Seems to be happening before the call to _Grid.js defaultUpdate.
Its so bad that I am considering trying again with TreeGrid. Im also considering just doing this by hand... Im kicking myself for spending so much time trying to get Dojo to work to begin with. I would also consider a commercial "JSON->table with collapsible row" library if anyone has any recommendations...
Any suggestions or insights? Familiarity with the flashing problem or how I could adapt TreeGrid to my needs? I'm aware this is a bit of a rant... Many thanks for any help.
-robbie
EDIT: I eventually gave up trying to get Dojo to do what I needed and coded it myself in less than a day. Not the best use of three weeks...
EDIT:
I just found a solution that works for me, I have added the following CSS:
.dojoxGridSummaryRow {
visibility: collapse
}
Basically the summaries are probably still created but they are not visible nor taken into account in the table layout. That's good for me. Hope this will solve your issue.
This won't help but just to let you know that:
"- but I couldn't see how I could format it to do what I needed - namely eliminate the 'summary row' "
is the very EXACT same thing I'm trying to achieve and did not find the solution even though this looks like a very simple feature... Will let you know if I found a solution...

Resources