mschart 饼图 如何实现以下效果:饼图点击一个分块再展开一个饼图

cstslqq 2014-10-23 11:29:18
mschart 饼图 如何实现以下效果:
饼图上点击一个分块再展开一个饼图,实现多层饼图。
...全文
922 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cstslqq 2015-10-14
  • 打赏
  • 举报
回复
已解决,参考如下代码:
using System.Windows.Forms.DataVisualization.Charting;
...

/// <summary>
/// Mouse Down Event
/// </summary>
private void chart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Call Hit Test Method
HitTestResult result = chart1.HitTest( e.X, e.Y );

// Check if data point is already exploded
bool exploded = ( chart1.Series[0].Points[result.PointIndex].CustomProperties == "Exploded=true" )? true : false ;

// Remove all exploded attributes
foreach( DataPoint point in chart1.Series[0].Points )
{
point.CustomProperties = "";
}

// If data point is already exploded get out.
if( exploded )
return;

// If data point is selected
if( result.ChartElementType == ChartElementType.DataPoint )
{
// Set Attribute
DataPoint point = chart1.Series[0].Points[result.PointIndex];
point.CustomProperties = "Exploded = true";
}

// If legend item is selected
if( result.ChartElementType == ChartElementType.LegendItem )
{
// Set Attribute
DataPoint point = chart1.Series[0].Points[result.PointIndex];
point.CustomProperties = "Exploded = true";
}
}

/// <summary>
/// Mouse Move Event
/// </summary>
private void chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Call Hit Test Method
HitTestResult result = chart1.HitTest( e.X, e.Y );

// Reset Data Point Attributes
foreach( DataPoint point in chart1.Series[0].Points )
{
point.BackSecondaryColor = Color.Black;
point.BackHatchStyle = ChartHatchStyle.None;
point.BorderWidth = 1;
}

// If a Data Point or a Legend item is selected.
if
( result.ChartElementType == ChartElementType.DataPoint ||
result.ChartElementType == ChartElementType.LegendItem )
{
// Set cursor type
this.Cursor = Cursors.Hand;

// Find selected data point
DataPoint point = chart1.Series[0].Points[result.PointIndex];

// Set End Gradient Color to White
point.BackSecondaryColor = Color.White;

// Set selected hatch style
point.BackHatchStyle = ChartHatchStyle.Percent25;

// Increase border width
point.BorderWidth = 2;
}
else
{
// Set default cursor
this.Cursor = Cursors.Default;
}

}
...
zy786995202 2014-11-13
  • 打赏
  • 举报
回复
帮顶,我也想学习一下
cstslqq 2014-10-29
  • 打赏
  • 举报
回复
没有人用过吗
cstslqq 2014-10-23
  • 打赏
  • 举报
回复
求高手解答!

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧