Many columns with same value

2 posts, 0 answers
  1. Erica
    Erica avatar
    1 posts
    Member since:
    May 2015

    Posted 12 Aug 2015 Link to this post

    Hi, I have a dynamic column chart in code-behind. I take the values from a table in my database and the values are divided by month (each month is a row in my table and each column is a group). However, my chart is showing 12 different columns with the same value for the same group. For example: in January, I have the value 10 and in February value 20 for Group A. In the chart, it is showing 12 columns with the value 10 in January and 12 columns with the value 20 in February. (I'm sorry I couldn't post a picture). I need only one column in each month. Can anyone help me with that?


    At first, I'm just getting a value from one of my table columns as a test.

    Here is my code:


        Dim chartGroups As New RadHtmlChart()
        chartGroups.ID = "chartGroups"
        chartGroups.Width = Unit.Pixel(1200)
        chartGroups.Height = Unit.Pixel(600)
        chartGroups.Legend.Appearance.Position = Telerik.Web.UI.HtmlChart.ChartLegendPosition.Bottom
        chartGroups.PlotArea.XAxis.TitleAppearance.Text = "Month"
        chartGroups.PlotArea.YAxis.TitleAppearance.Text = "Total"
        Dim chartDataTable As DataSet
        chartDataTable = Program_TypeGrouping_Controller.GetOrderIntake_ByYear(ddlYear.SelectedValue, 0)
    Dim npColumnSeries As New ColumnSeries
        Dim groupIntake As New SeriesItem
        Using reader As DataTableReader = chartDataTable.CreateDataReader()
            While reader.Read()
                Dim test As Double
                If reader.IsDBNull(3) Then
                    test = 0
                    test = reader(3)
                End If
                npColumnSeries.Stacked = False
                groupIntake.Name = reader.GetName(3)
                npColumnSeries.Spacing = 0
                groupIntake.YValue = test
                npColumnSeries.LabelsAppearance.Visible = False
            End While
        End Using


  2. Slav
    Slav avatar
    1351 posts

    Posted 17 Aug 2015 Link to this post

    Hello Erica,

    If I understand your scenario correctly, you need to create one ColumnSeries with a CategorySeriesItem for each category of the HtmlChart. Your current implementation inserts a ColumnSeries instance for each record in the data source, which result in having multiple columns in each category, instead of only one.

    You can change this by inserting the ColumnSeries instance only once, as shown in the sample page I attached to this post. I would also suggest checking the following help article for a better understanding of how column series are configured:

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top