rpd
rpd

Reputation: 35

Devexpress Chartcontrol Series selection (and take a serie value )

I am working on a Full-Stacked Bar charts with chartcontrol and series bar in. My chart works like a charm.

My problem is about working on every series separately with respect to events. I work my chartcontrol's MouseClick(or ObjectHotTracked and ObjectSelected. I tried them also) event but I could not take every series values seperately when I clicked on them.

How can I do that? I looked up devexpress documentation but I found nothing about that.

In short: I want to take the value what serie I clicked. How can I do that?

Thanks in advance

Upvotes: 0

Views: 1708

Answers (1)

Abdellah OUMGHAR
Abdellah OUMGHAR

Reputation: 3755

First you must set the ChartControl.RuntimeHitTesting property to true, and Try code in ChartControl.MouseClick :

private void Form1_Load(object sender, EventArgs e)
{
    chartControl1.CrosshairEnabled = DefaultBoolean.False;
    chartControl1.RuntimeHitTesting = true;
}

private void chartControl1_MouseClick(object sender, MouseEventArgs e)
{
    // Obtain hit information under the test point.
    ChartHitInfo hi = chartControl1.CalcHitInfo(e.X, e.Y);

    // Obtain the series point under the test point.
    SeriesPoint point = hi.SeriesPoint;

    // Check whether the series point was clicked or not.
    if (point != null)
    {
        // Obtain the series point argument.
        string argument = "Argument: " + point.Argument.ToString();

        // Obtain series point values.
        string values = "Value(s): " + point.Values[0].ToString();
        if (point.Values.Length > 1)
        {
            for (int i = 1; i < point.Values.Length; i++)
            {
                values = values + ", " + point.Values[i].ToString();
            }
        }

        MessageBox.Show(argument + "\n" + values, "SeriesPoint Data");
    }
}

Upvotes: 1

Related Questions