How to use PlotArea - MVVM style in omponent One - componentone

Am trying to use ComponentOne MVVM style (I want to stay away from having to write code behind). I was able to figure out from their samples how to use data binding to bind data from the ViewModel onto the view.
<c1:C1Chart x:Name="lineChart"
ChartType="Line" Data="{Binding ChartData}">
In my case, I want want to display multiple data series using one common axes. It looks like Plot Area does exactly that. But am unable to figure out the xaml that needs to be written to accomplish that. All the examples I have seen involves adding code in code behind.
Any ideas?
Thanks
Kay

Figured it out, I can do something like this
<c1:C1Chart x:Name="chart" View="{Binding ChartView}" Data="{Binding ChartData}"/>
And on my view model, ChartView is property of type ChartView to which I can add plot areas
Thanks
Kay

Related

Swift Animation Similar to Line Chart

my question can be a little bit confusing, however I will do my best to explain it. So I need to create a view like below in the image, which looks like a line chart.
In other words, the line thumbs should be interactive, so that user can move them up and down, which will led to the movement of "ropes" between each pair. The problem is I can not figure out to start what kind of structure in swift so that I can create this view. So far, I am thinking about to create separate sliders and connect them by drawing, lines between them, but I think there should be some better solution. Any help, idea, advice or hint is appreciated. Thanks in advance.
Part 1. Learning to use "drawRect" in a UIView
Make a custom view, i.e. subclass UIView. To draw the nine angled line segments (and indeed the grid behind) you'll need to master core graphics. Fortunately there are many of QA on this very topic:
How to draw a line in the simplest way in swift
Part 2. Custom layers in UIView
You'll have to learn about adding custom CALayers to views. There are many examples of this, eg
https://stackoverflow.com/a/57465440/294884
https://stackoverflow.com/a/41553784/294884
(Note that for the small text labels, I would probably simply add many UILabels programmatically, which you will also need to learn about.)
Part 3. Using UISlider
There's really nothing wrong with using a UISlider for each of your red dots. If you're just getting started with iOS, I suggest trying that first to become familiar with it.
A handy tip is, simply use a horizontal stack view to hold them all - you can space them as you wish.
Part 4. Using gestures
Beyond UISlider. The red buttons would most likely be custom UIViews. And, most simply, you would use UIPanGestureRecognizer to detect the finger moving.
Again you can find many QA on this field of study, example Move UIView within parent view using pangesture
If you master these four general fields you will be able to achieve the view in question, good luck!

Design for annotating UICollectionView selections with additional controls

Using UICollectionView and excellent help given on here on StackOverflow, I've been able to build a "Gantt Chart" style control for my iPhone:
Cosmetics aside (I'm doing the functional right now, I've got a graphics designer on tap to look at colors and all that).
Background aside, the spans were relatively straightforward to do with a custom UICollectionViewLayout subclass. Each span is an item.
But I need to add some functionality, and am unsure how to proceed. Where I'm trying to go is illustrated roughly as:
Sketchy cosmetics aside, the point is that I want to "annotate" whatever the currently selected span is with additional information (I promise to find someone to help me look it pretty). And I want them to be active, I'm not sure if it brings up an editing control or does drag, but I want to be able recognize gestures on either the numbers or the bold lines and do things with them, distinct from touching on the span which drives selection.
I can think of (at least) 3 ways to try and implement this:
Use supplementary views. Cause selection to invalidateLayout, detect the selected state in my prepareLayout, and generate additional layout attributes for the two anchors. Implement a subclass of UICollectionReusableView which does the drawing, and adds touchable subviews (or its own gesture recognizers). This feels... wrong. I get the idea that supplementary views are more for headers and footers, not for controls that come and go as the selection state changes. But maybe it's an appropriate extension of the facility?
Use the backgroundView (or selectedBackgroundView, not sure it matters) of my current SpanCell class (which is a subclass of UICollectionViewCell). As long as I disable clipsToBounds, I can draw the annotation around the bounds of the span. I'll have to give it some knowledge of the big picture to find the endpoints, but that's not too offensive. I would just show/hide this view in response to selection changes. This seems like the best way to do it.
Do it in the main backgroundView of the entire UICollectionView. As shown, I've already got a specialized backgroundView which shows the the current time grid, strip style. I could further extend this view to draw annotations and manage touchable sub controls in response to selection changes. This would give me most direct implementation, but it feels like I'll end up with a big monster "doing too many jobs" object for the background.
Question then, for those who have more experience, is which route would you go? Would it be one of the above 3? Or something different? And why?
While your question is very technical with UICollectionView implementation, which I am not very familiar with, this seems like a job for the container (in this case, the collection view). Imagine you need your annotation to consider, in addition to the selected item, other items? Like for example, avoiding collision between annotation lines and another item?
For me, option number 3 seems like the most correct one. If you fear a large class, you can extern it to an annotation controller class, which should be notified whenever the annotations should be updated.

Where to begin? - iOS "excel- like" view

I'm new to iOS development. I have finished the "console" part of my app (it does what I need it to do in a Mac app without a UI), but now I have no idea on where to start for my (iOS) UI part.
Basically, I need something like a simple grid of cells (like Excel); my code reads a file, creates a dynamic (varies per file content) 2D array, and I want to show this on my UI, making each cell selectable by the user (each cell would correspond to a position in my 2D array).
Could someone point me in the right direction (even if its only the name of the classes I need to look up in apple's doc.)? I have been trying to find answers online, but it seems I'm not looking for it right.
In case I didn't explain myself correctly, I want something like this:
UICollectionView is the correct class to use for this. It allows you to create layouts with multiple rows and columns in a similar style to UITableView. You can also create your own custom layouts if the default one does not do what you need.

ios filter options similar to the apple store (dropdown list)

I'm trying to figure out how to make a filter option similar to the apple store's filter options. The first thing that came to my mind are dropdownlists similar to websites. But it doesn't seem to have it on the objects options in xcode. Was wondering where should I start in order to make that kind of function.
It's similar to this
http://www.insightguides.com/docs/halo-asset-manager/images/apps/berlitz-cruise-2013-ipad-6.jpg
Unless you guys can recommend something else? Looking at this, it seems to me it's just a popover? If this is so, I am in need of 4 - 5 filters, does that mean I should create 4 - 5 viewcontrollers to popover? It seems like a lot of space is being used just for filters, not really sure how to dynamically generate it using just 1 viewcontroller.
Thoughts?
Assuming all your filters look the same but have different data then you could just have one FilterViewController and change its data source depending on the filter type.
And yes, that does look like a simple UIPopoverController.
So when you have to display a new popover create a FilterViewController and assign it the appropriate data source. You can use delegation to inform the parent class which filter was selected and use the data source to tell the filter view controller what data it should display to be filtered.

How to work with dynamic content

I am working with a UITable View and I am trying to figure out the best way to handle the way I display the content as its dynamic.
For instance some of the things I search may have a title and a description but then other times only have a title.
In a n instance like this I would like to be able to control the positioning of the labels in my UITableCell, of which I have created a custom one.
For instance this is a graphical view of what I am trying to do.
Title:
No Title:
As you can see with the second option I have decided to move the UILabel to the left where the Title label would be.
So What would be the best way of doing this?
I am thinking maybe creating several different format types in a .xib and then just using if statments.. if its missing such and such then use cell a or b or c.
Or is there a better way to achieve this?
Any help or advice would be greatly appreciated.
The different formats in .xib files will do the trick, just instance the proper cell type according to your needs, the other is delving into how you draw your cells, adding labels as you see fit when you get your data and drawing them appropriately.

Resources