I am not able to load this chart in whirglobeMap throght MBTile from which given below - webgl-globe

for path in paths{
if let tileSource = MaplyMBTileSource(mbTiles: Constant.path.hiPath() + "/" + path){
print("Tittle layer ",tileSource)
// set up the layer
let layer = MaplyQuadImageTilesLayer(coordSystem: tileSource.coordSys, tileSource: tileSource)
layer!.handleEdges = true
layer!.coverPoles = true
layer!.requireElev = false
layer!.waitLoad = false
layer!.drawPriority = kMaplyImageLayerDrawPriorityDefault+60
layer!.singleLevelLoading = false
globeMap.add(layer!)
selectedChartLayer.append(layer!)
}
MBTile Link:- https://drive.google.com/file/d/12rupa4ZPykmFMNuaqcz9Aa1vWfoJniBH/view?usp=sharing

Related

GTLRSheets_Color not holding value

I am trying to set a value for "background color" as seen below but when I print the value after setting it, it simply shows nil? This makes absolutely no sense. Please help, I have exhausted all resources already.
Thank you.
let request = GTLRSheets_Request.init()
request.repeatCell = GTLRSheets_RepeatCellRequest.init()
let colbox = GTLRSheets_GridRange.init()
colbox.startRowIndex = rowstart
colbox.endRowIndex = rowend
colbox.startColumnIndex = columnstart
colbox.endColumnIndex = columnend
request.repeatCell?.range = colbox
let color = GTLRSheets_Color.init()
color.blue = 60
color.red = 47
color.green = 77
request.repeatCell?.cell?.userEnteredFormat?.backgroundColor = color
request.repeatCell?.cell?.userEnteredFormat?.textFormat?.bold = true
request.repeatCell?.cell?.userEnteredFormat?.horizontalAlignment = "CENTER"
request.repeatCell?.fields = "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment)"
print(request.repeatCell?.cell?.userEnteredFormat?.backgroundColor)
let batchUpdate = GTLRSheets_BatchUpdateSpreadsheetRequest.init()
batchUpdate.requests = [request]
let createQuery = GTLRSheetsQuery_SpreadsheetsBatchUpdate.query(withObject: batchUpdate, spreadsheetId: spreadsheetId)
service.executeQuery(createQuery) { (ticket, result, NSError) in
}
Issue:
You should initialize cell and userEnteredFormat.
Solution:
cell refers to an instance of GTLRSheets_CellData, and should be initialized the following way:
request.repeatCell?.cell = GTLRSheets_CellData.init()
userEnteredFormat refers to an instance of GTLRSheets_CellFormat:
request.repeatCell?.cell?.userEnteredFormat = GTLRSheets_CellFormat.init()
Reference:
GTLRSheets_CellData
GTLRSheets_CellFormat
Swift: Initialization

How can I show and hide labels?

I have 4 labels (dayString1, dayString2, dayString3 and dayString4) in which they will put a numerical value and what I need to do is that if the content of dayString1 is less than 60 than the dayString2 appears, and if the sum of dayString1 + dayString2 is less than 60 the dayString3 appears and so on; My logic was this, but it gives error:
(Ambiguous reference to operator function '<')
func chooseDays() {
self.dayString = dayTextField.text!
self.dayString2 = dayTextField2.text!
self.dayString3 = dayTextField3.text!
self.dayString4 = dayTextField4.text!
if dayString < 60 {
self.dateTextField2.isHidden = false
self.dayTextField2.isHidden = false
self.dateTextField3.isHidden = true
self.dayTextField3.isHidden = true
self.dateTextField4.isHidden = true
self.dayTextField4.isHidden = true
SearchConstraint.constant = 72
if dayString + dayString2 < 60 {
self.dateTextField2.isHidden = false
self.dayTextField2.isHidden = false
self.dateTextField3.isHidden = false
self.dayTextField3.isHidden = false
self.dateTextField4.isHidden = true
self.dayTextField4.isHidden = true
SearchConstraint.constant = 112
if dayString + dayString2 + dayString3 < 60 {
self.dateTextField2.isHidden = false
self.dayTextField2.isHidden = false
self.dateTextField3.isHidden = false
self.dayTextField3.isHidden = false
self.dateTextField4.isHidden = false
self.dayTextField4.isHidden = false
SearchConstraint.constant = 152
}
}
}
return
}
You need to type caste string to integer before performing any comparison with another integer like this:
if Int(dayString) < 60 {
Also do nil coalescing technique to handle unwrapping of texts from textfields:
self.dayString = dayTextField.text ?? "0"
self.dayString2 = dayTextField2.text ?? "0"
self.dayString3 = dayTextField3.text ?? "0"
self.dayString4 = dayTextField4.text ?? "0"

iOS Charts - single values not showing Swift

When I have multiple points in an array for a line on a line graph, everything shows perfectly.
But when there is only one point, the dot does not show. I dont know why?
the delegate is being set elsewhere, but this doesnt seem to be the issue.
The below examples shows Test 2 and Test exercise. The first image is where each has one value, the second they each have 2.
heres my code
func startChart(){
chart.dragEnabled = true
chart.legend.form = .circle
chart.drawGridBackgroundEnabled = false
let xaxis = chart.xAxis
xaxis.valueFormatter = axisFormatDelegate
xaxis.labelCount = dataSets.count
xaxis.labelPosition = .bottom
xaxis.granularityEnabled = true
xaxis.granularity = 1.0
xaxis.avoidFirstLastClippingEnabled = true
xaxis.forceLabelsEnabled = true
let rightAxis = chart.rightAxis
rightAxis.enabled = false
rightAxis.axisMinimum = 0
let leftAxis = chart.leftAxis
leftAxis.drawGridLinesEnabled = true
leftAxis.axisMinimum = 0
let chartData = LineChartData(dataSets: dataSets)
chart.data = chartData
}
If I add
chart.setVisibleXRangeMinimum(myMinDate)
the value will show correctly. however it squashes the value to the left and overlaps 2 x value dates
The only way I could get around this was to add an additional invisible line.
I created a clear line that started the day before and ended the day after my single values.
As long as there is a line on the chart that goes from one point to another, the other single values show.
var singleValue = false
for i in 0...(dataSets.count - 1) {
if dataSets[i].values.count > 1{
singleValue = true
}
}
var data = dataSets
if singleValue == false {
let minNS = Calendar.current.date(byAdding: .day, value: -1, to: minNSDate as! Date)
let maxNS = Calendar.current.date(byAdding: .day, value: 1, to: maxNSDate as! Date)
var dataEntries: [ChartDataEntry] = []
let dataEntry1 = ChartDataEntry(x:Double(String(format: "%.2f",Double((minNS?.timeIntervalSince1970)!)))!,y:00.00)
let dataEntry2 = ChartDataEntry(x:Double(String(format: "%.2f",Double((maxNS?.timeIntervalSince1970)!)))!,y:00.00)
dataEntries.append(dataEntry1)
dataEntries.append(dataEntry2)
let set = LineChartDataSet(values: dataEntries, label: "")
set.setCircleColor(UIColor.clear)
set.circleHoleColor = UIColor.clear
set.setColor(UIColor.white, alpha: 0.0)
set.drawValuesEnabled = false
data.append(set)
}
chart.chartDescription?.text = ""
let chartData = LineChartData(dataSets: data)
chart.data = chartData
I think I found a better solution. Single point is not enough to draw a line (you need at least two points) so LineChartView can't render your data. You can fix that by replace LineChartView with CombinedChartView. CombinedChartView give a possibility to mix different types of data on one chart. You can check how many data entires do you have and decide which type of DataSet will be proper.
Code example:
if dataEntry.count == 1 {
let scatterDataSet = ScatterChartDataSet(values: dataEntry, label: title)
scatterDataSet.setColor(UIColor.pmd_darkBlue)
scatterDataSet.setScatterShape(.circle)
scatterDataSet.drawValuesEnabled = false
combinedChartData.scatterData = ScatterChartData(dataSets: [scatterDataSet])
}
else {
let lineDataSet = LineChartDataSet(values: dataEntry, label: title)
lineDataSet.setColor(UIColor.pmd_darkBlue)
lineDataSet.lineWidth = 3.0
lineDataSet.drawCirclesEnabled = false
lineDataSet.drawValuesEnabled = false
combinedChartData.lineData = LineChartData(dataSets: [lineDataSet])
}
combinedChart.data = combinedChartData
You can also combine two and more types DataSets in one chart.
Important
Don't forget to add this line:
combinedChart.drawOrder = [DrawOrder.line.rawValue, DrawOrder.scatter.rawValue]
You must to write types of data types you use otherwise data will not render.

web audio - merge 3 audiostreams into 1

Pretty confident that it should be possible.
Currently i can only get the stream from one:
let mediaElement = document.createElement("img");
mediaElement.className = "fileMedia";
mediaElement.style.maxWidth = "280px";
mediaElement.crossOrigin = "anonymous";
mediaElement.controls = true;
mediaElement.src = URL.createObjectURL(selectedLocalMedia); // a file from type="file" input
let audioCtx = new AudioContext();
// create placeholder stream from our AudioContext
let dest = audioCtx.createMediaStreamDestination();
this.audioStream[pluginHandleIndex] = dest.stream;
// connect our video element's output to the stream
let sourceNode = audioCtx.createMediaElementSource(mediaElement);
// if (pluginHandleIndex > 0) {
// let testvideo = document.getElementById("testvideo");
// let sourceNodeTwo = audioCtx.createMediaElementSource(testvideo);
// sourceNodeTwo.connect(dest);
// }
sourceNode.connect(dest);
sourceNode.connect(audioCtx.destination);
How can i add more audio streams to this.audioStream[pluginHandleIndex]( audioCtx.createMediaStreamDestination() ) ?
If you see commented lines
// if (pluginHandleIndex > 0) {
// let testvideo = document.getElementById("testvideo");
// let sourceNodeTwo = audioCtx.createMediaElementSource(testvideo);
// sourceNodeTwo.connect(dest);
// }
I try to attach tome like the first time, but this doesn't seem to work :/
Thanks!

Crystal Reports Leaving out parameter

I have a crystal report that I am modifying the record selection formula. I have a parameter "Inventory_Class" that can have 3 values 0, 1 or 2. If set to 1 I want my DB field "NON_Controllable" that is binary field to select all False records, if the parameter is set to 2 then I want all True records but if the incoming parameter is set to 0 then I don't want to filter on the DB field "NON_Controllable" at all. I can get formula to work when parameter is set to 1 and 2 selecting Non_Controllable false and true records but when the parameter is set to 0 my report returns no records when it should be returning all records.
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD} and
IF ({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE
ELSE IF ({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE
ELSE IF ({?INVENTORY_CLASS} = 0) THEN
NOT {Inventory_Cat_Header.NON_CONTROLLABLE}
How can I modify this formula to work?
you can try passing the parameters for each conditions instead.
IF
({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
ELSE IF
({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
else
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}