Created
August 12, 2015 11:34
-
-
Save bh3605/f58dfdedf34dc947e395 to your computer and use it in GitHub Desktop.
Hides sections of data points in a data table and returns a modified copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function setExclusionFilter(table as DataTable) as DataTable | |
dim unit = cbxSelectUnit.text | |
dim xAxisName = table.columns(0).columnName | |
dim yAxisName = table.columns(1).columnName | |
dim unitExclusionRegions = from row in exclusionRegions | |
where row.field(Of String)("UnitID") = unit and row.field(Of Boolean)("Active") = true | |
select axis = row.field(Of Char)("Axis"), low = row.field(Of Double)("Low"), high = row.field(Of Double)("High") | |
dim query as String = "" | |
if(unitExclusionRegions.count <> 0) | |
for i=0 to unitExclusionRegions.count-1 | |
if(unitExclusionRegions(i).axis = "x") | |
query &= "( `" & xAxisName & "` < " & unitExclusionRegions(i).low & " OR `" & xAxisName & "` > " & unitExclusionRegions(i).high & ")" | |
elseif(unitExclusionRegions(i).axis = "y") | |
query &= "( `" & yAxisName & "` < " & unitExclusionRegions(i).low & " OR `" & yAxisName & "` > " & unitExclusionRegions(i).high & ")" | |
end if | |
if(i <> unitExclusionRegions.count-1) | |
query &= " AND " | |
end if | |
next | |
end if | |
query = query.Replace(",", ".") | |
dim result = table.Select(query) | |
if(result.length() = 0) | |
return table | |
end if | |
dim dataTableResult = result.CopyToDataTable() | |
return dataTableResult | |
end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment