Skip to content

Commit

Permalink
chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Mar 26, 2024
1 parent 70df848 commit a342635
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions SwiftPamphletApp/App/SwiftPamphletAppApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ struct SwiftPamphletAppApp: App {
var body: some Scene {
WindowGroup {
// SwiftPamphletApp() // 老版本
// HomeView() // 新版本
PlayWeatherView()
HomeView() // 新版本
// PlayWeatherView()
.modelContainer(for: [IOInfo.self, DeveloperModel.self], isUndoEnabled: true)

}
Expand Down
40 changes: 22 additions & 18 deletions SwiftPamphletApp/InfoOrganizer/Category/CategoryListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,29 @@ struct CategoryListView: View {
}
}
}
ScrollView(.horizontal) {
Chart {
ForEach(cates) { cate in
BarMark(
x: .value("名字", cate.name),
y: .value("数量", cate.infos?.count ?? 0)
)
.foregroundStyle(.orange)
.symbol(.circle)
.interpolationMethod(.catmullRom)
}
}
.chartXAxis {
AxisMarks(values: .automatic(minimumStride: 10)) { _ in
AxisGridLine()
AxisTick()

}
GroupBox("图表显示") {
Chart(cates) { cate in
// BarMark(
// x: .value("数量", cate.infos?.count ?? 0),
// y: .value("名字", cate.name)
// )
// .annotation(position: .overlay, alignment: .trailing, spacing: 3) {
// Text("\(cate.infos?.count ?? 0)")
// .font(.footnote)
// .foregroundColor(light: .white, dark: .white)
// }
SectorMark(angle: .value("数量", cate.infos?.count ?? 0), innerRadius: .ratio(0.5),
angularInset: 1.5)
.foregroundStyle(by: .value("名字", cate.name))
.annotation(position: .overlay, alignment: .trailing, spacing: 3) {
Text("\(cate.infos?.count ?? 0)")
.font(.footnote)
.foregroundColor(light: .white, dark: .white)
}
}
.chartXAxis(.hidden)
// .chartYAxis(.hidden)
// .aspectRatio(1, contentMode: .fit)
}

}
Expand Down
2 changes: 1 addition & 1 deletion SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct InfosView: View {
if !filterCateName.isEmpty && !searchString.isEmpty {
(info.name.localizedStandardContains(searchString)
|| info.url.localizedStandardContains(searchString)
|| info.des.localizedStandardContains(searchString)) && info.category?.name == filterCateName && info.star == filterStar
|| info.des.localizedStandardContains(searchString)) && info.category?.name == filterCateName
} else if !filterCateName.isEmpty {
info.category?.name == filterCateName
} else if searchString.isEmpty {
Expand Down

0 comments on commit a342635

Please sign in to comment.