Closed martheli closed 6 years ago
@martheli You need to add padding in ChartSettings
. Something like:
var chartSettings = ChartSettings()
chartSettings.leading = 10
chartSettings.top = 10
chartSettings.trailing = 10
chartSettings.bottom = 10
let chartConfig = BarsChartConfig(
chartSettings: chartSettings,
valsAxisConfig: ChartAxisConfig(from: 0, to: (max?.1)!, by: 10)
)
After making those changes I am getting error now below. I can't set chart config if its of type ChartConfigXY
, it is expecting type BarsChartConfig
.
var chartSettings = ChartSettings()
chartSettings.leading = 10
chartSettings.top = 10
chartSettings.trailing = 10
chartSettings.bottom = 10
let chartConfig = ChartConfigXY(
chartSettings: chartSettings,
xAxisConfig: ChartAxisConfig(from: 0, to: (max?.1)!, by: 20),
yAxisConfig: ChartAxisConfig(from: 0, to: (max?.1)!, by: 20)
)
let frame = chartView.frame
let chart = BarsChart(
frame: frame,
chartConfig: chartConfig, // Error here
xTitle: xTitle,
yTitle: "# of devices",
bars: data,
color: UIColor.red,
barWidth: 20
)
nvm I figured it out. Correct code should look like this for me:
var chartSettings = ChartSettings()
chartSettings.leading = 10
chartSettings.top = 10
chartSettings.trailing = 10
chartSettings.bottom = 10
let chartConfig = BarsChartConfig(
chartSettings: chartSettings,
valsAxisConfig: ChartAxisConfig(from: 0, to: (max?.1)!, by: 20)
)
let frame = chartView.frame
let chart = BarsChart(
frame: frame,
chartConfig: chartConfig,
xTitle: xTitle,
yTitle: "# of devices",
bars: data,
color: UIColor.red,
barWidth: 20
)
I have the following function used to set up a simple bar chart. When it loads, the top of the Y axis values get cut off. Does the view scale with the data?