DevExpress之饼状图突出(Explode)设置实例
程序员文章站
2023-12-15 17:05:04
本文实例讲述了devexpress之饼状图突出(explode)设置方法,分享给大家供大家参考。具体实现方法如下:
关键代码如下:
复制代码 代码如下:/// <...
本文实例讲述了devexpress之饼状图突出(explode)设置方法,分享给大家供大家参考。具体实现方法如下:
关键代码如下:
复制代码 代码如下:
/// <summary>
/// 饼状图突出设置
/// </summary>
/// <param name="chart">chartcontrol</param>
/// <param name="pieseries">series【仅仅适用于pieseriesview】</param>
/// <param name="explodemode">突出模式【枚举】</param>
/// <param name="explodedvalue">突出间距</param>
/// <param name="dragpie">是否可以拖动突出饼状</param>
public static void setpieexplode(this chartcontrol chart, series pieseries, pieexplodemode explodemode, int explodedvalue, bool dragpie)
{
if (pieseries.view is pieseriesview)
{
//bool _hittesting = chart.runtimehittesting;
if (!chart.runtimehittesting)
chart.runtimehittesting = true;
/// 饼状图突出设置
/// </summary>
/// <param name="chart">chartcontrol</param>
/// <param name="pieseries">series【仅仅适用于pieseriesview】</param>
/// <param name="explodemode">突出模式【枚举】</param>
/// <param name="explodedvalue">突出间距</param>
/// <param name="dragpie">是否可以拖动突出饼状</param>
public static void setpieexplode(this chartcontrol chart, series pieseries, pieexplodemode explodemode, int explodedvalue, bool dragpie)
{
if (pieseries.view is pieseriesview)
{
//bool _hittesting = chart.runtimehittesting;
if (!chart.runtimehittesting)
chart.runtimehittesting = true;
pieseriesview _pieview = pieseries.view as pieseriesview;
_pieview.explodemode = explodemode;
_pieview.explodeddistancepercentage = explodedvalue;
_pieview.runtimeexploding = dragpie;
// chart.runtimehittesting = _hittesting;
}
}
代码使用:
复制代码 代码如下:
private void builderdevchart()
{
series _pieseries = new series("series 1", viewtype.pie);
_pieseries.valuedatamembers[0] = "value";
_pieseries.argumentdatamember = "name";
_pieseries.datasource = createchartdata();
chartcontrol1.series.add(_pieseries);
//----------------------------------------
_pieseries.legendpointoptions.pointview = pointview.argumentandvalues;
_pieseries.setpiepercentage(numericformat.percent, pointview.argumentandvalues);
chartcontrol1.setaxisxtitle("test", color.red);
_pieseries.setlableposition(pieserieslabelposition.twocolumns);
chartcontrol1.setpieexplode(_pieseries, pieexplodemode.minvalue, 5, true);
}
{
series _pieseries = new series("series 1", viewtype.pie);
_pieseries.valuedatamembers[0] = "value";
_pieseries.argumentdatamember = "name";
_pieseries.datasource = createchartdata();
chartcontrol1.series.add(_pieseries);
//----------------------------------------
_pieseries.legendpointoptions.pointview = pointview.argumentandvalues;
_pieseries.setpiepercentage(numericformat.percent, pointview.argumentandvalues);
chartcontrol1.setaxisxtitle("test", color.red);
_pieseries.setlableposition(pieserieslabelposition.twocolumns);
chartcontrol1.setpieexplode(_pieseries, pieexplodemode.minvalue, 5, true);
}
运行效果如下图所示:
希望本文所述对大家的c#程序设计有所帮助。