0

How do you specify the gap or distance between the slices (or between the origin) in exploded pie charts in .NET charting?

Is there any property or hack?

Joe Vi
  • 473
  • 4
  • 10
Gyum Fox
  • 3,287
  • 2
  • 41
  • 71

3 Answers3

0

This has been asked before here and the answer is no, there is no way - no hacks.

Community
  • 1
  • 1
Joe Vi
  • 473
  • 4
  • 10
0

There is no way to do it, but there is an alternative for 2D Pie Charts with no border on the series and single-color background: just set the border width and color properties of the series to have the desired size and the same color as the background.

Like this:

Chart1.Series[0].BorderWidth = 3;
Chart1.Series[0].BorderColor = System.Drawing.Color.White;

It will make the inner parts of the slices to be the same color as the background, giving the impression that those slices are exploded. The drawback is that it will make the very small slices disappear.

You may leave the points exploded if you want to increase the distance, but if you wish to reduce the exploded distance you will have to remove the explosion.

0

You can use the .net5 ported version and modify the source of PieChart.cs, starting with line #840:

                // Find Direction to move exploded pie slice
            if( exploded )
            {
                _sliceExploded = true;
                midAngle = ( 2 * startAngle + sweepAngle ) / 2;
                double xComponent = Math.Cos( midAngle * Math.PI / 180 ) * rectangle.Width / 10;
                double yComponent = Math.Sin( midAngle * Math.PI / 180 ) * rectangle.Height / 10;

                rectangle.Offset( (float)xComponent, (float)yComponent );
            }

and modify the x-yComponent to achive the expected result, like:

double xComponent = Math.Cos( midAngle * Math.PI / 180 ) * 1;
double yComponent = Math.Sin( midAngle * Math.PI / 180 ) * 1;

paying attention to the position of the point.label also...

Regards, Angelo

Angelo Cresta
  • 104
  • 1
  • 7