Help with C1Chart of stacked bar type

Posted by: itzik on 2 May 2019, 8:10 am EST

    • Post Options:
    • Link

    Posted 2 May 2019, 8:10 am EST

    Hello,

    I am trying to use the C1Chart according to your C# code example:

    private void Form1_Load(object sender, EventArgs e)
    {
            // Clear previous data
                    c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            // Data
                    string[] items = new string[] { "Item1", "Item2", "Item3"};
            int[] sales2005 = new int[] { 800, 1500, 2000};
            int[] sales2006 = new int[] { 1000, 1200, 1400};
    
            // Create first series
                    C1.Win.C1Chart.ChartDataSeries ds2005 =
            c1Chart1.ChartGroups[0].ChartData.SeriesList.AddNewSeries();
            ds2005.Label = "2005";
            ds2005.LineStyle.Color = Color.Yellow;
            ds2005.X.CopyDataIn( items);
            ds2005.Y.CopyDataIn( sales2005);
    
            // Create second series
                    C1.Win.C1Chart.ChartDataSeries ds2006 =
            c1Chart1.ChartGroups[0].ChartData.SeriesList.AddNewSeries();
            ds2006.Label = "2006";
            ds2006.LineStyle.Color = Color.Red;
            ds2006.AutoEnumerate = true;
            ds2006.Y.CopyDataIn( sales2006);
    
            // Set chart type
                    c1Chart1.ChartGroups[0].ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Bar;
            c1Chart1.ChartGroups[0].Stacked = true;
    
            // Set y-axis minimum
                    c1Chart1.ChartArea.AxisY.Min = 0;
    
            c1Chart1.Legend.Visible = true;
    
            // Remove the Axes caption
                    c1Chart1.ChartArea.AxisX.Text = "";
            c1Chart1.ChartArea.AxisY.Text = "";
    }
    

    I did something similar but more dynamic, according to the data of a datatable.

    My question is how can I add a tool tip text support that displays for each graph column the series data. The X the Y and the series to which it belongs.

    The main problem is to get the value of each series in the graph column.

    Thank you in advance for your help.

  • Posted 6 May 2019, 1:30 am EST

    Hi,

    We are sorry for the delay. However, In order to show X,Y values and Series name in tooltip, you can set the ChartDataSeries.TooltipText property for each data series as follows:

    dataSeries.TooltipText = "Series: {#TEXT}" + '\r' + '\n' + "x = {#XVAL}" + '\r' + '\n' + "y = {#YVAL}";
    

    You can also refer the following documentation link https://help.grapecity.com/componentone/NetHelp/c1chart2d/webframe.html#addtooltipstochartsp.html for the same.

    Also, If you just started using C1Chart, I would suggest you to use FlexChart instead. C1Chart is in maintenance now and FlexChart is our new charting control. You can refer the FlexChart’s key features listing from “https://help.grapecity.com/componentone/NetHelp/FlexChartWin/webframe.html#KeyFeatures.html”.

    Thanks & Regards,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels