Interactive bar chart.user changes y axis value at runtime by dragging it - charts

For example 3 columns are there with y axis value as 100,200,300 in barcharts.
User select one column alone and drag it to 500 value in y-axis.
How to achieve this?
Is it available in library like androidplot or aChartPlugin?
If not which plugin support this requirement.Our project is for Android tablets
Please provide me sample code for this requirement.Thanks in advance.

To my knowledge no library exists for Android that provides 'out of the box' capabilities to drag and reorganize data. Having said that, any library that provides you with a way to correlate touch events to data elements and also supports dynamic updates should be suitable.
If you have specific requirements about how the "drag" is implemented then you may end up having to roll your own library or customize an existing one to your needs. If not, here's a basic workflow you could implement with Androidplot that represents the drag operation as a cursor:
1 - Detect selections using an OnTouchListener. Here's an example of a bar plot that allows bar selection via touch. Gives a full example of converting screen coords to model elements etc. Create and add an instance of XValueMarker denoting the current position of the selection. (An XValueMarker is basically a customizable vertical line marking an x-val.
2 - Detect "drag" events using an OnTouchListener. Here's an example that detects zooming and scrolling. It's not the same thing exactly but the scrolling logic is close enough to give you the general idea.
3 - As the user drags, update the position of the XValueMarker by XValueMarker.setValue(Number).
4 - Once the "drag" ends, remove the XValueMarker and modify the underlying XYSeries to reflect the change using basic data structure manipulation(s).
And of course remember to always call plot.redraw() after each operation that is expected to alter the appearance of the plot in some way.

Related

Is there a function to select and show certain features only in print composer?

I have a feature layer with points. I have three pages in my print composer. On one of my pages, I only want to show points that fall within a certain value range. First, I tried locking the style on the pages where I want to display all my points.
Then, I went to the Query Builder of the layer I want to select points from, and I created an expression to display only points from a range:
The problem is that this selection modifies the points shown on all my pages in print composer, even the ones where I locked the layers and style for layers. The only alternative solution I can think of is to select the points I want to show, create a new feature layer with those selected points, and then show that feature layer on my page in print composer. However I'd like to know if there's another way to do this without creating a new feature layer each time I want to filter the points I show in print composer.
There's another way. The points change because when you define a query, basically you define what features will be loaded to the project. So if you use categorized symbology you can define that some feature will be not displayed, but they will stay loaded in the project.
Here you can find how to use this type of symbology: Classifying Nominal Data

How can I filter over a bar graph data while showing the average of the entire data set?

I am making an interactive dashboard in Tableau that looks something like this:
https://public.tableau.com/app/profile/monica.ionescu/viz/ExploringHIVStatisticsinSouthAmerica/Dashboard1?publish=yes
(for your best viewing experience, please view the dashboard in the fullscreen view - button on bottom right corner of the board)
I need some help with the bar chart.
I currently have a reference line in place to mark the two averages so that they don’t move as I filter through data. When using the average line feature, the filters on the left change all the graphs on the dashboard in real-time (and thus the average with it). So, it seems like the average line is built from the data points currently on display rather than all the data points in our data set.
I want to show the averages on the bar graph as they are in the image (a constant for the whole data set) without having to manually set the average each time I add/update the data.
How do I make it so that when I change the filters, the bar graph changes but the average stays constant?
Thank you so much!
You can self-blend the data sources - duplicate the data source, but DON'T join any fields/set up relationships. The lack of join can make the secondary source act as a constant.
Alternatively create a FIXED calculation to calculate the average. This should also act as a constant - just make sure none of your filters are in context.

MapBox. A highlight effect by hover event on table. SetData takes 2s for updating source with 6000 features

I'm trying to implement a highlight effect by hover effect on the table's row. I've got the data table related to Mapbox's point features. I update the map point's styles by my rxjs state (every change in the state calls styles updating on my map). For small features count, it works well, but it takes 2 seconds for updating styles on the map with 6000 points. Directly setData execution takes 150-200 ms, but rendering takes 1-3 seconds. How can I improve the performance of the Mapbox for my task? As I wrote, I have 6000 points on the map, and when I hover the cursor over a row in the table I want to change the style for2 points. Change of style implemented by changing the feature's layer (might that be the matter?).
Thanks for any ideas.
the github issue.
setFeatureState is the most efficient way to update the styling of a small number of features on a map with many features.
It does have certain limitations: it only works on layers with feature IDs, and not all styling can be controlled through feature state (notably, layout properties such as icon-image cannot).
Documentation here: https://docs.mapbox.com/mapbox-gl-js/api/#map#setfeaturestate
I found more productive way to highlight any resource. I just use another data-source for selected / highlighted resources and one or few style layers. You only need to put selected resources to another data-source and draw them according selected style. That don't affective to common data sources, and don't need to recompute resources states, just draw selected resource above based resources.

how to restrict scrolling for +ve part in cpxygraph

I am new to core plot SDK, implemented core plot in my app. i need to restrict -ve part of graph. i.e always i will have +ve values for graph((1,1),(10,15),(20,15)).i need horizontal , vertical scrolling for +ve part only.So i want to restrict remaining 3 parts of graph. I tried in all ways help less, so posted here. if any one already done with this type requirement, please help me ASAP.
Thanks in advance.
The easiest way to restrict the scrolling ranges is to set the globalXRange and globalYRange properties on your plot space. If you want more control, you can use a plot space delegate. CPTestApp (the Mac version) demonstrates both techniques.

how to efficiently find a rect # some x,y point with iphone sdk

I am looking for an efficient way to handle the image/frame detection from touch methods. Let's say i am building a keyboard or similar to this. I have 'n' number of images placed on the UI. When someone touches an alphabet (which is an image), i can do the following to detect the corresponding letter
1) CGRectIntersectsRect(..,..) : if i use this, then i need to check each & every letter to find out what letter exists at that touch point (let's say 100,100). This becomes O(n). If i move my finger accross the screen, then i will get m points & all corresponding image detection becomes O(n*m) which is not good.
2) Other way is building a hash for each & every x,y position so that the look up will be simply O(1). But again this will be a memory constraint as i need to store 300*300 ( assuming i am using 300*300 screen size). if i reshuffle my letters, then everything needs to calculated again. So this is not good
In other words, i need some thing like , given a point (x,y), i need some way of finding which rectangle is covering that point efficiently.
Sorry for long post & any help would be grateful.
Thanks
If there are in a regular grid, then integer division by the grid size. Assuming you've a small, fixed screen size, a bucket array gives as similar gain ( a 2D grid, where each entry is a list of the rectangles which intersect that part of the grid ) is very fast if tuned correctly so the lists only have a few members. For unbounded or large spaces, KD trees can be used.
It's useful to have the rects you want as final targets set up as subviews as a larger UIView (or subclass) where you expect all these related hits to occur. For example, if you're building your own keyboard, you could add a bunch of UIButton objects as subviews and hit test those.
So, the easy and traditional way of hit testing a bunch of subviews is to simply have code triggered by someone hitting those buttons. For example, you could add the subviews as UIControl objects (which is a subclass of UIView that adds some useful methods for catching user touch events), and call addTarget:action:forControlEvents: to specify some method to be triggered when the user does something in the rect of that UIControl. For example, you can catch things like UIControlEventTouchDown or UIControlEventTouchDragEnter. You can read the complete list in the UIControl class reference.
Now, it sounds like you might be going for something even more customized. If you really want to start with a random (x,y) coordinate and know which rect it's in, you can also use the hitTest:withEvent: method of UIView. This method takes a point in a view, and finds the most detailed (lowest in the hierarchy) subview which contains that point.
If you want to use these subviews purely for hit testing and not for displaying, then you can set their background color to [UIColor clearColor], but don't hide them (i.e. set the hidden property to YES), disable user interaction with them (via the userInteractionEnabled BOOL property), or set the alpha below 0.1, since any of those things will cause the hitTest:withEvent: method to skip over that subview. But you can still use an invisible subview with this method call, as long as it meets these criteria.
Look at UIView's tag property. If your images are in UIViews or subviews of UIView, then you can set each tag and use the tag to look up in an array.
If not, then you can improve the speed by dividing your array of rectangles into sets that fit into larger rectangles. Test the outer rectangles first, then the inner rectangles. 25 rectangles would need only 10 tests worst case as 5 sets of 5.
Thanks Pete Kirkham & Tyler for your answers which are really helpful. Lets say i dont wanna use buttons as i am mainly displaying images as a small rectangles. To check for the rect # (x,y) , i can trigger that easily by making my grid as a square & finding
gridcolumn = Math.floor(pos.x / cellwidth); gridrow = Math.floor(pos.y / cellheight);
But my problem is with touchesMoved. Lets say i started # grid-1 & dragged till grid-9 (in a 3*3 matrix), in this case, i am assuming i will get 100-300 (x,y) positions, so everytime i need to run above formula to determine corresponding grid. This results in 300 calculations which might effect the performance.
So when i display an image as a rect, can i associate some id for that image? so that i can simply just save the ids in a list (from grid-1 to grid-9) so that i can avoid the above calculation.
Thanks for your help