willdale / swiftuicharts-demo Goto Github PK
View Code? Open in Web Editor NEWDemo Project for willdale/SwiftUICharts
Demo Project for willdale/SwiftUICharts
SwiftUICharts Demo (macOS) Group
Swift Compiler Error Group
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:58:20: Cannot find 'StackedBarDataSets' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:59:13: Cannot find 'StackedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:60:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:61:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:62:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:65:13: Cannot find 'StackedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:66:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:67:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:68:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:71:13: Cannot find 'StackedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:72:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:73:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:74:17: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:77:13: Cannot find 'StackedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:78:18: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:79:18: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/StackedBarChartDemoView.swift:80:18: Cannot find 'StackedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:57:20: Cannot find 'GroupedBarDataSets' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:58:13: Cannot find 'GroupedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:59:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:60:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:61:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:64:13: Cannot find 'GroupedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:65:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:66:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:67:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:70:13: Cannot find 'GroupedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:71:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:72:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:73:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:76:13: Cannot find 'GroupedBarDataSet' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:77:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:78:17: Cannot find 'GroupedBarDataPoint' in scope
~/src/SwiftUICharts-Demo/Shared/Views/ChartViews/BarChart/GroupedBarChartDemoView.swift:79:17: Cannot find 'GroupedBarDataPoint' in scope
Really enjoying this library! Thanks for such excellent work! ๐
I am trying to understand .linearTrendLine.
I see that it takes chartDate as a parameter, but then also takes a firstValue and lastValue. As far as I can tell the line is just a straight line drawn from firstValue to lastValue?
I was wondering if this was something you might come back to to add support for a trend line with curves more along the lines of a moving average? I also tried .averageLine
but this just gave me a flat horizontal line across the data.
Thanks again for for a great library! ๐ป
Is there no xAxisNumberOfLabels for BarChartStyle? If not any work around? I have a Bar Chart with 60 data points but only want 5 labels so they can fit.
Thanks!
I may be misunderstanding the implementation - but I don't seem to be able to get the x-axis labels to align at the bottom of the chart.
I've set the style to make use of the .chartData
, and provided those labels in the LineChartData
. When I add this to the Chart itself, the yAxis labels remain the same - but the yAxis grid compresses to the top 50% of the view, as does the line - and the x-axis labels are centered!
Before I add .xAxisLabels(chartData: chartData)
:-
After I add .xAxisLabels(chartData: chartData)
:-
And this is how I have implemented :-
private var baseline: Double {
let baseline = Double(readings.minimumValue() - (readings.valueRange() / 2))
if baseline <= 0 {
return 0
}
return baseline
}
private var topLine: Double {
return Double(readings.maximumValue() + (readings.valueRange() / 2))
}
private var chartStyle: LineChartStyle {
let yAxisGridStyle = GridStyle(
numberOfLines: 5,
lineColour: Color.Brand.sky,
lineWidth: 1,
dash: [1000]
)
return LineChartStyle(
xAxisLabelPosition: .bottom,
xAxisLabelFont: Font.Primary.metadata,
xAxisLabelColour: Color.UI.midGrey,
xAxisLabelsFrom: .chartData(rotation: .degrees(0)),
yAxisGridStyle: yAxisGridStyle,
yAxisLabelPosition: .leading,
yAxisLabelFont: Font.Primary.metadata,
yAxisLabelColour: Color.UI.midGrey,
yAxisNumberOfLabels: 5,
yAxisLabelType: .numeric,
baseline: .minimumWithMaximum(of: baseline),
topLine: .maximum(of: topLine),
globalAnimation: .default)
}
private var dataSet: LineDataSet {
let lineStyle = LineStyle(
lineColour: ColourStyle(colour: lineColor),
lineType: curvedLine ? .curvedLine : .line,
strokeStyle: Stroke(lineWidth: 2, lineCap: .round, lineJoin: .round),
ignoreZero: ignoreZero)
return LineDataSet(dataPoints: readings.map { (value: UInt, date: Date?) in
LineChartDataPoint(value: Double(value), date: date)
}, style: lineStyle)
}
private var chartData: LineChartData {
return LineChartData(
dataSets: dataSet,
metadata: ChartMetadata(title: "Peak Flow"),
xAxisLabels: ["M", "T", "W", "T", "F"],
chartStyle: chartStyle,
noDataText: Text("No Data"))
}
var body: some View {
LineChart(chartData: chartData)
.id(chartData.id)
.yAxisGrid(chartData: chartData)
.xAxisLabels(chartData: chartData)
.yAxisLabels(chartData: chartData)
.yAxisPOI(chartData: chartData,
markerName: "Target",
markerValue: 450,
labelPosition: .center(specifier: "Target %.0f"),
labelColour: Color.Brand.white,
labelBackground: Color.UI.midGrey,
lineColour: Color.UI.midGrey,
strokeStyle: StrokeStyle(lineWidth: 1, dash: [2, 2]))
}
}
Any help at all would be appreciated - Not sure if it is a bug, but would be ace if you could feedback, love the library and keen to use. Many thanks :-)
Hi, I am using your library and found the bug on xAxisLabels
at LineChartData
: in case of data set like this [1,3,4,4,4], three last entries would be stacked to the end. To fix this it is better to change it to
case .chartData:
if let labelArray = self.xAxisLabels {
HStack(spacing: 0) {
ForEach(labelArray.indices, id: \.self) { index in
YAxisChartDataCell(chartData: self, label: labelArray[index])
.foregroundColor(self.chartStyle.xAxisLabelColour)
.accessibilityLabel(Text("X Axis Label"))
.accessibilityValue(Text("\(labelArray[index])"))
if index != labelArray.count - 1 {
Spacer()
.frame(minWidth: 0, maxWidth: 500)
}
}
}
.padding(.horizontal, -4)
}
}
P.S. sorry for posting it as an issue and not PR.
Will there be an updated demo for using version 3?
Please, provide an API to
markerType
, especially color and stroke width.Thanks
This is an awesome project and I used it in my app, but the demo project seems to be empty, hope can write some details about the usage
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.