Skip to main content

DXPieHint Class

A pop-up rectangle (tooltip) that shows information about a tapped series point.

Namespace: DevExpress.Xamarin.iOS.Charts

Assembly: DevExpress.Xamarin.iOS.Charts.dll

NuGet Package: DevExpress.XamarinForms.Charts

Declaration

public class DXPieHint :
    DXChartElement

The following members return DXPieHint objects:

Remarks

The Pie Chart Hint looks as follows:

The hint sample

How to: Allow End Users to Invoke Hints

Assign a new DXPieHint instance to the DXPieChart.Hint property to enable hints for a chart:

this.chart.Hint = new DXHint();

How to: Configure How the Hint Displays a Series’s Points

You can disable an individual series’ hints, specify a text pattern to format values, and arrange these values within tooltips:

pieSeries.HintOptions = new DXPieSeriesHintOptions {
    PointTextPattern = "{L}: {V$#.##} millions of km²"
};

The following symbols configure series and hint interaction:

Symbol

Description

DXPieSeries.HintOptions

DXPieSeriesHintOptions

In the code above, the series placeholders (L and VP) specify which series point values a tooltip should display in its text. The following label placeholders are available for Pie Series:

Placeholder Description
{S} Displays a series name.
{L} Displays a series point argument.
{V} Displays a series point value.
{VP} Displays a series point value as percentages.

Note

These values can be formatted using default format strings after the $ sign. For example, in the {VP$#.##} string, VP is a placeholder, $ is a format string separator, and #.## is a format string.

How to: Programmatically interact with a hint

The chart provides methods that show or hide the hint programmatically. The chart delegate allows you to track when a chart shows or hides the hint. For example, the following code shows a hint programmatically and notifies event listeners when end users invoke hints:

class LandAreaChartController: UIChartController {
    public event SelectedLandAreaChangedEventHandler SelectedLandAreaChanged;
    public List<LandAreaItem> LandAreas { get; set; }

    public override void ViewDidLoad() {
        base.ViewDidLoad();
        chart.Delegate = new ChartDelegate(this);
    }

    public void ShowHint(LandAreaItem item) {
        int pointIndex = LandAreas.IndexOf(item);
        if (pointIndex > 0) {
            chart.ShowHint(pointIndex, 0);
        } else {
            chart.HideHint();
        }
    }

    internal RaiseItemChanged(int itemIndex) {
        LandAreaItem item = (itemIndex >= 0) 
            ? LandAreas[itemIndex] 
            : null;
        SelectedLandAreaChangedEventHandler handler = SelectedLandAreaChanged;
        if (handler != null) {
            handler(this, item);
        }
    }
}

class ChartDelegate : DXChartDelegate {
    private LandAreaChartController controller;

    public ChartDelegate(LandAreaChartController controller) {
        this.controller = controller; 
    }

    public void DidShowHint(DXChartBase chart, DXHintInfo hintInfo) {
        NSNumber index = (NSNumber)info.SeriesPointInfos[0].DataPointIndices[0];
        controller.RaiseItemChanged(index.Int32Value);
    }

    public void DidHideHint(DXChartBase chart) {
        controller.RaiseItemChanged(-1);
    }
}

public delegate void SelectedLandAreaChangedEventHandler(object sender, SelectedLandAreaChangedEventArgs args);
public class SelectedLandAreaChangedEventArgs {
    public LandAreaItem SelectedItem { get; }
    public SelectedLandAreaChangedEventArgs(LandAreaItem selectedItem) {
        this.SelectedItem = selectedItem;
    }
}

The table below contains members the chart tooltip API includes.

Member

Description

DXChartBase.ShowHint(CGPoint)

Shows a hint for a series point at the specified screen point.

DXChartBase.ShowHint(nint, nint)

Shows a hint for a series point with the pointIndex of a series with the seriesIndex.

DXChartBase.HideHint()

Hides the hint the chart displays.

DXChartDelegate.DidShowHint(DXChartBase, DXHintInfo)

DXChartDelegate.DidHideHint(DXChartBase)

How to: Customize a tooltip’s appearance

The following image displays style properties that manages the hint appearance:

Style parameters

The code below configures the tooltip as the image above shows:

// All sizes are in screen points.
this.pieChart.Hint = new DXPieHint {
    Style = new DXHintStyle {
        BackgroundColor = new UIColor.FromWhiteAlpha(white: 0.8f, alpha: 0.8f),
        Padding = new UIEdgeInsets(12.0f, 24.0f, 12.0f, 24.0f),
        MarkerSize = 24,
        TextIndent = 12,
        TextStyle = new TextStyle {
            ForegroundColor = UIColor.Black,
            FontSize = 24
        }
    }
};

The following table lists symbols that specify the tooltip’s appearance:

Symbols

Description

DXPieHint.Style

Gets or sets the Pie Chart Hint’s appearance settings.

DXPieHintStyle

The Pie Chart Hint’s appearance settings storage.

Implements

IEquatable<Foundation.NSObject>
Foundation.INSObjectProtocol
ObjCRuntime.INativeObject

Inheritance

Object
Foundation.NSObject
See Also