I have two grid let say grid a and grid b. Value of grid a is (1, 2, 3, 4, 5, ... 50) and in grid b (3, 5, 10, 25) .
I need when I click row with value 10 in grid b, then grid a will automatically scroll to row with value 10 too. Below code I have been try :
gridRoomStatus?.setContentOffset(CGPoint.init(x: 0, y: 0), animated: true)
self.gridRoomStatus?.reloadColumns(self.gridRoomStatus?.columns)
I have that code to make grid a go to the top when grid b is clicking. But it's still not solving my problem. I can't get a specific point for row with specific value. In UITableView there are tableView.rectForRow(at: indexPath) but I can't find similar function with that in Shinobi data Grid. How to do that?
Here I solved this problem, example :
let rowHeight = 50
let rowIndexToSnapTo = 20
grid.setContentOffset(CGPoint(x: 0, y: rowHeight * rowIndexToSnapTo))
Related
enter link description here
I used Charts/danielgindi..
When a graph is selected, the highlight works properly. But what I want is to highlight the center graph on the first screen when no graph is selected.
chartView.highlightValue(x: 3, dataSetIndex: 3, dataIndex: 3)
chartView.highlightValue(Highlight(x: 3, dataSetIndex: 3, stackIndex: 3))
I wrote the code in the same way as above, but it failed.
solution
let midPoint = CGPoint(x: chartView.bounds.midX, y: chartView.bounds.midY)
let h = chartView.getHighlightByTouchPoint(midPoint)
chartView.highlightValue(h, callDelegate: true)
If I am using all of column A for example,
I want to do this:
IF cell value is between 30-34 then * 1.5, IF cell value is between 35-39 then * 2, IF cell value is between 40-44 then * 2.5???
You need to use nested if statements ...
If(and(A1>=30,A1<=34), A1*1.5, if(And(a1>=36,A1<=39),A1*2, if(and(A1>=40,A1<=44),A1*2.5,"")))
Paste the above into cell H1 and drag the formula down.
At some point, nested IF statements become unwieldy and a lookup to hard-coded values or a lookup table is more efficient.
=A2*lookup(A2, {0, 30, 35, 40}, {1, 1.5, 2, 2.5})
I have a very strange issue where a chart (SwiftChart) is not being displayed (is not visible/rendered) when the project is built and run.
Some background:
XCode 8 (project was originally and XCode 7 project)
Objective C project/ViewControllers
A swift file to render the chart (have tried calling this from viewDidLoad & viewDidLayoutSubviews)
Storyboard containing all ui elements
Using CocoaPods
The 'print' code you see in Swift outputs 'null'
The UIView where the chart is to be rendered exists within the storyboard and is setup as follows
The code being called is:
let chart = Chart()
print(chart.window?.frame.width)
print(chart.window?.frame.height)
let data = [(x: 0.0, y: 0), (x: 3, y: 2.5), (x: 4, y: 2), (x: 5, y: 2.3), (x: 7, y: 3), (x: 8, y: 2.2), (x: 9, y: 2.5)]
let series = ChartSeries(data: data)
series.area = true
chart.xLabels = [0, 3, 6, 9, 12, 15, 18, 21, 24]
chart.xLabelsFormatter = { String(Int(round($1))) + "h" }
chart.add(series)
Visually I see nothing. I'm struggling to figure out where the problem might be so any pointers greatly appreciated
You uave to initialize it with a frame when creating it programmatically since it's a UIControl subclass. It appears their first code example is wrong but they explain it correctly in the next. All on-screen views need a frame at a minimum.
But if you already have a view of this class in your storyboard you need an outlet to point to it. Your first line of code creates a new one, so you're not talking to the one you set up, but an improperly created off-screen one.
So add an outlet and connect it to your view so you can talk to it.
I have a collection View that I made horizontal scrolling. It has 3 rows and 5 columns. Once I enabled horizontal scrolling the cells fill up going down the columns instead of across the rows. For example i have an array 1,2,3,4,5,6,8,9,10,11,12,13,14,15,16 that i am using to fill my collection view. The cells would look like this
1,4,7,10,13,16
2,5,8,11,14
3,6,9,12,15
How can I fix this.
That's the default behavior of horizontal.If you want you can sort the array in some way so it'll be displayed the way you want it.
Like this:
var array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
var horizontalSortedArray = [Int]()
let columns = 5
let rows = 3
for i in 0..<columns {
for j in 0..<rows {
horizontalSortedArray.append(array[j*columns+i])
}
}
print(horizontalSortedArray)
// [1, 6, 11, 2, 7, 12, 3, 8, 13, 4, 9, 14, 5, 10, 15]
Now if you use this new array as your data source in horizontal mode it'll be displayed like this:
1 ,2 ,3 ,4 ,5
6 ,7 ,8 ,9 ,10
11,12,13,14,15
i'm hoping that this quick description and image will ring a bell with someone who has had a similar issue and therefore a suggestion/fix.
i have a column graph that i am adding data to dynamically (via jQuery parsing an XML file).
for some reason, after the data is added, the alignment of the different series gets a little off. the issue fixes itself after i toggle one of the series by being visible/invisible (by clicking the series in the legend).
when i add the data via hardcoding the numbers, just to ensure it works, it works great.
here is the image:
the yellow series is the last series added to the chart, the red and purple series line up ok after toggling the visibility of one of the 5 series.
any help would be greatly appreciated!
UPDATE with info on the data:
i have 5 series of data and 10 x-axis categories
i am building a multidimensional array of data as i parse the XML file
the array length is 5, with each of those 5 index's containing an array of length 10
this is what the array looks like after it has been populated with data:
index#: 0 value: 0,0,0,0,0,0,0,0,0,0
index#: 1 value: 180,210,0,0,0,0,0,0,180,210
index#: 2 value: 22,4,0,0,0,0,0,0,22,4
index#: 3 value: 0,0,0,0,0,0,0,0,0,0
index#: 4 value: 200,30,0,0,0,0,0,0,4,0
i am adding the data to the chart with the following JS code:
for (var c_ary_bs = 0; c_ary_bs < ary_bs_schedule_orig.length; c_ary_bs++) {
chart.series[c_ary_bs].setData(ary_bs_schedule_orig[c_ary_bs]);
}
hopefully that will help, thank you!
UPDATE 2, some more info
i've hard coded the data being added to the array, to help pinpoint the issue:
chart.series[0].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[1].setData([180, 210, 0, 0, 0, 0, 0, 0, 180, 210]);
chart.series[2].setData([22, 4, 0, 0, 0, 0, 0, 0, 22, 4]);
chart.series[3].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[4].setData([200, 30, 0, 0, 0, 0, 0, 0, 4, 0]);
alert('done')
when the alert fires, the graph columns are aligned properly, after I click "ok" to dismiss the alert, the alignment issue happens, as the previous image depicts.
I found an imperfect fix:
-setting the marginLeft of the chart to 70 alleviates the issue with the columns not aligning
-for some reason the y-axis title text is displaying over the y-axis ticks, so i am using the following to make it visible:
yAxis: {
title: {
x:-20,
text: 'Schedule Days'
}
}
(note the x: -20)
Whats's odd is that when I toggle one of the series (by clicking it in the legend) the yAxis title text reverts to where it should be (which is now 20px off because of the above fix).
The perfect fix would put the yAxis text where it is after I toggle one of the series, but at least this way it is now visible regardless of whether or not the user toggles the series.