London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
2.1 C
New York
Saturday, February 1, 2025

ios – Swift chart: x axis stride by two hours


I’m attempting to implement a inventory chart with swift with two plots: one is the worth and the opposite is a prediction/approximate for the worth. The information is in Entry format, which consists of a date and a value subject. I’m attempting to make two variations of the chart – weekly/day by day. For the day by day chart, I hoped the x-axis could possibly be labeled as hour increment. Nonetheless, since there are two hours, it’s too crowded. I used to be questioning whether it is doable to make use of stride(by: 4 hours) as an alternative and the way can I implement this? I attempted making a TimeInterval variable (60 * 60 * 4) and setting up 4 hours from the calendar part nevertheless it did not work.

Chart {
                ForEach(toggleWeekChart ? self.sentiments : dailySentiments, id: .date) { sentiment in
                    LineMark(
                        x: .worth("Date", sentiment.date),
                        // TODO: take away -1 for actual sentiment knowledge
                        y: .worth("Sentiment", sentiment.closePrice - 1),
                        collection: .worth("Sentiment", "B")
                    )
                    .foregroundStyle(.blue)
                    
                }
                ForEach(toggleWeekChart ? self.entries : dailyEntries, id: .date) { entry in
                    LineMark(
                        x: .worth("Date", entry.date),
                        y: .worth("Worth", entry.closePrice),
                        collection: .worth("Worth", "A")
                    )
                    .foregroundStyle(.inexperienced)
                    
                    
                    let curGradient = LinearGradient(
                        gradient: Gradient (
                            colours: [
                                .green.opacity(0.5),
                                .green.opacity(0.2),
                                .green.opacity(0.05),
                            ]
                        ),
                        startPoint: .high,
                        endPoint: .backside
                    )
                    
                    AreaMark(
                        x: .worth("Date", entry.date),
                        yStart: .worth("Worth", spherical(minY - ((maxY - minY) / 100) * 20)),
                        yEnd: .worth("PriceEnd", entry.closePrice)
                    )
                    
                    .foregroundStyle(curGradient)
                    .alignsMarkStylesWithPlotArea()
                    
                }
                
            }
            //            .chartForegroundStyleScale(["Price": .green, "Sentiment": .blue])
            .chartLegend(place: .high, alignment: .middle)
            .chartYScale(area: minY - ((maxY - minY) / 100) * 20...maxY + ((maxY - minY) / 100) * 20)
            .chartXAxis
            {
                AxisMarks(values: .stride(by: toggleWeekChart ? .day : .hour))
                { date in
                    AxisGridLine()
                    AxisValueLabel(format: toggleWeekChart ? .dateTime.weekday(.slim) : .dateTime.hour(), centered: true)
                }
            }.chartYAxis {
                AxisMarks(place: .main)
            }

chart

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com