如何从Coredata获取的数据中创建一个Barchart?

发布于 2025-02-03 00:19:20 字数 728 浏览 3 评论 0原文

我正在尝试从Coredata模型中从获取的数据中创建一个Barchart。 我正在尝试使用 https://github.com/apppear/chartview 特别是版本v1 .5.5。 该请求将我从数据库中返回一个实体数组,假设其[实体]。 (实体有两个属性一个日期和一个INT64) 我想使用此数据来创建Barchart,并使用Gi​​tHub Readme上的示例创建的标签:

barchartview(数据:ChartData(值:[(“ 2018 Q4”,63150),(“ 2019 Q1”,“ 2019 Q1”, 50900),(“ 2019 Q2”,77550),(“ 2019 Q3”,79600),(“ 2019 Q4”,92550))),标题:“销售”,传奇:“季度”)//传奇是可选的< /code>

尤其是我想使用的ChartData的初始化是public Init&lt; n:binaryInteger&gt;(values:[(string,n)])

现在我尝试映射(使用.map()) fetchrequest给我的阵列,但没有成功。 如何将数据从数组转换为Init的ChartData的所需签名? 还是您还有其他建议来完成此任务,例如我可以使用的某些订单软件包而不是前面提到的订单软件包?

I'm trying to create a barchart from fetched data from a CoreData model.
I'm trying to use https://github.com/AppPear/ChartView in particular the release v1.5.5.
The request returns me from the database an array of Entities, let's say its [Entity]. (Entity has two attributes a date and an Int64)
I want to use this data to create the barchart with the labels created by like the example on the github readme :

BarChartView(data: ChartData(values: [("2018 Q4",63150), ("2019 Q1",50900), ("2019 Q2",77550), ("2019 Q3",79600), ("2019 Q4",92550)]), title: "Sales", legend: "Quarterly") // legend is optional

In Particular the init of ChartData I wanna use is public init<N: BinaryInteger>(values:[(String,N)])

Now I tried to map (using .map() ) the array that the fetchRequest gives to me but unsuccessfully.
How do I transform the data from the array, into the required signature of the init of ChartData ?
Or do you have any other suggestion in order to accomplish this task, like some order packages I could use instead of the one mentioned before?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒一口袋星星 2025-02-10 00:19:20

您是否尝试过ChartData(值:fetchrequestresult.map {(“ \($ 0.date)”,$ 0.INT64VALUE)}?
关于其他LIB,您应该查看图表。它在许多应用程序中都广为人知和使用

Have you tried ChartData(values: fetchRequestResult.map { ("\($0.date)", $0.int64value) }?
Regarding other libs, you should have a look into Charts. It's in more wide known and used by a lot of apps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文