Open Vincz opened 2 years ago
Hi @willdale! So I managed to get the result I wanted (by duplicating the code) !
Both the fill
of the PieChart
and the stroke
of the DoughnutChart
accept a Color
or a Gradient
.
I wanted to make a PR, but I have the following problems:
Color
and Gradient
in the related datapoints? If I change public var colour: Color
in PieChartDataPoint
by public var colour: ShapeStyle
, I get the error Protocol 'ShapeStyle' can only be used as a generic constraint because it has Self or associated type requirements
. startAngle
and amount
of the data point itself, if we want to be able to use RadialGradient
as in my example:Here is an example of a modified version of PieChart
.
PieSegmentShape(id: chartData.dataSets.dataPoints[data].id,
startAngle: chartData.dataSets.dataPoints[data].startAngle,
amount: chartData.dataSets.dataPoints[data].amount)
.fill(AngularGradient(
gradient: Gradient(colors: [
Color(DynamicColor(chartData.dataSets.dataPoints[data].colour).lighter(amount: 0.3)),
Color(DynamicColor(chartData.dataSets.dataPoints[data].colour).darkened(amount: 0.1))
]),
center: .center,
startAngle: .radians(chartData.dataSets.dataPoints[data].startAngle),
endAngle: .radians(chartData.dataSets.dataPoints[data].startAngle+chartData.dataSets.dataPoints[data].amount)
))
Could you help me with this? What would be the preferred way to handle this case?
Would it be possible to handle gradients colors within Pie or Doughnut Charts ? Something like that?