Stacked Column Chart duplicate x axis

500 Views Asked by At

I have the following data in sql that needs to be represented in Stacked Column chart.
Name  Type  Amount
Paul    T1      100
John   T2      200
John   T3      300

The name represents the X-axis and the Type as Series. The issue I am facing is duplicate X-axis value with the same name. This is the code example I was following before getting the duplicate Name but now doesn't make sense.

  SectionData data = GetSectionData(sectionId);

        List<double[]> yValues= new List<double[]>();
        if (data != null && data.LineItems.Count() > 0)
        {
            List<string> xValues = new List<string>();              
            List<string> typeNames = new List<string>();

            int index=0;
            foreach (var yval in data.LineItems)
            {
                xValues.Add(yval.Name);

                typeNames.Add(yval.TypeName);
                double[] temp = new double[data.LineItems.Count()];
                temp.SetValue(yval.Amont, index);
                yValues.Add(temp);                    
                index++;
            }

            foreach (string name in typeNames)
            {
                StackedColumnChart.Series.Add(
                            new Series
                            {
                                Name = name,
                                ChartType = SeriesChartType.StackedColumn,
                                Font= new Font("Segoe UI", 8),
                                CustomProperties="DrawingStyle=Cylinder",
                                Legend = "Default"
                            }
                    );
            }

            for (int counter = 0; counter < typeNames.Count; counter++)
            {                   

                try
                {                      

                    StackedColumnChart.Series[counter].Points.DataBindXY(xValues, yValues.Select(i => i[counter]).ToList());                       

                }
                catch (Exception ex)
                {
                  //throw ex
                }
            }
}

Any help.

0

There are 0 best solutions below