-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from TelemetryDeck/add-cluster-structure
Add cluster structure
- Loading branch information
Showing
25 changed files
with
818 additions
and
211 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// BarCharTopN.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import Charts | ||
import DataTransferObjects | ||
|
||
struct BarChartTopN: View { | ||
let result: TopNQueryResult | ||
|
||
var body: some View { | ||
Chart { | ||
//ForEach(result.rows) { row in | ||
// BarMark( | ||
// x: .value("Date", 4), | ||
// y: .value("Total Count", 5) | ||
// ) | ||
//} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// BarChartGroupBy.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import Charts | ||
import DataTransferObjects | ||
|
||
struct BarChartGroupBy: View { | ||
let result: GroupByQueryResult | ||
|
||
var body: some View { | ||
Chart { | ||
/*ForEach(result.rows) { row in | ||
BarMark( | ||
x: .value("Date", 5), | ||
y: .value("Total Count", 5) | ||
) | ||
}*/ | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// BarChartTimeSeries.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import Charts | ||
import DataTransferObjects | ||
|
||
struct BarChartTimeSeries: View { | ||
let result: TimeSeriesQueryResult | ||
|
||
var body: some View { | ||
Chart { | ||
ForEach(result.rows, id: \.timestamp) { row in | ||
BarMark( | ||
x: .value("Date", row.timestamp), | ||
y: .value("Total Count", row.result["count"]?.value ?? 0) | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ClusterBarChart.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
import SwiftUI | ||
import DataTransferObjects | ||
|
||
struct ClusterBarChart: View { | ||
let query: CustomQuery | ||
let result: QueryResult | ||
|
||
var body: some View { | ||
switch query.queryType { | ||
case .timeseries: | ||
if case let .timeSeries(result) = result { | ||
BarChartTimeSeries(result: result) | ||
} else { | ||
Text("Mismatch in query type and result type 1") | ||
} | ||
/*case .groupBy: | ||
if case let .groupBy(result) = result { | ||
BarChartGroupBy(result: result) | ||
} else { | ||
Text("Mismatch in query type and result type 2") | ||
}*/ | ||
case .topN: | ||
if case let .topN(result) = result { | ||
BarChartTopN(result: result) | ||
} else { | ||
Text("Mismatch in query type and result type 2") | ||
} | ||
default: | ||
Text("\(query.queryType.rawValue) bar charts are not supported.") | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// ClusterChart.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import DataTransferObjects | ||
|
||
/// Cluster/Chart – given a query and a result, displays the result | ||
struct ClusterChart: View { | ||
|
||
let query: CustomQuery | ||
let result: QueryResult | ||
let type: InsightDisplayMode | ||
|
||
var body: some View { | ||
switch type { | ||
case .barChart: | ||
ClusterBarChart(query: query, result: result) | ||
case .lineChart: | ||
ClusterLineChart(query: query, result: result) | ||
default: | ||
Text("Not supported") | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ClusterLineChart.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import DataTransferObjects | ||
|
||
struct ClusterLineChart: View { | ||
let query: CustomQuery | ||
let result: QueryResult | ||
|
||
var body: some View { | ||
switch query.queryType { | ||
case .timeseries: | ||
if case let .timeSeries(result) = result { | ||
LineChartTimeSeries(result: result) | ||
} else { | ||
Text("Mismatch in query type and result type") | ||
} | ||
default: | ||
Text("\(query.queryType.rawValue) bar charts are not supported.") | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// LineChartTimeSeries.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import Charts | ||
import DataTransferObjects | ||
|
||
struct LineChartTimeSeries: View { | ||
let result: TimeSeriesQueryResult | ||
|
||
var body: some View { | ||
Chart { | ||
ForEach(result.rows, id: \.timestamp) { row in | ||
LineMark( | ||
x: .value("Date", row.timestamp), | ||
y: .value("Total Count", row.result["count"]?.value ?? 0) | ||
) | ||
} | ||
.interpolationMethod(.cardinal) | ||
|
||
ForEach(result.rows, id: \.timestamp) { row in | ||
AreaMark(x: .value("Date", row.timestamp), | ||
y: .value("Total Count", row.result["count"]?.value ?? 0)) | ||
} | ||
.interpolationMethod(.cardinal) | ||
.foregroundStyle(LinearGradient(colors: [Color.telemetryOrange.opacity(0.25), Color.telemetryOrange.opacity(0.0)], startPoint: .top, endPoint: .bottom)) | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// ClusterInstrument.swift | ||
// Telemetry Viewer (iOS) | ||
// | ||
// Created by Lukas on 23.05.24. | ||
// | ||
|
||
import SwiftUI | ||
import DataTransferObjects | ||
|
||
struct ClusterInstrument: View { | ||
@EnvironmentObject var api: APIClient | ||
|
||
let query: CustomQuery | ||
let title: String | ||
let type: InsightDisplayMode | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 8) { | ||
Text(title) | ||
.font(.headline) | ||
.fontWeight(.medium) | ||
.foregroundStyle(Color.Zinc600) | ||
.padding(.top) | ||
.padding(.horizontal) | ||
QueryRunner(query: query, type: type) | ||
} | ||
.compositingGroup() | ||
.background(.background) | ||
.shadow(color: .gray.opacity(0.15), radius: 5, x: 0, y: 2) | ||
.border(Color.Zinc200, width: 1.0) | ||
.padding(.vertical, 5) | ||
} | ||
} |
Oops, something went wrong.