Problem with series.Tags


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Alexander,

We were not able to reproduce this problem. We tested with version 14.4.11.12 some variations of the code below:

    NChart chart = nChartControl1.Charts[0];
    NBarSeries bar = new NBarSeries();
    bar.DataLabelStyle.Visible = false;
    bar.Values.AddRange(new double[] {10, 20, 15, 12, 22});
    chart.Series.Add(bar);
    bar.Tags[10] = "Some string";

but we didn't get any exception. We are not able to compile and run your code directly (some declarations are missing), but we didn't see anything wrong with it. In general we recommend you to use the indexer syntax instead of the Add method. Could you please try the code above in a new project and let us know if it throws an exception.

Best Regards,
Nevron Support Team


Alexander Haberl
Alexander Haberl
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)
Group: Forum Members
Posts: 15, Visits: 48
Hi!
I switched to Version 2014.1 (full version number: 14.4.11.12), and suddenly I got problems with this code (which worked perfectly in 2012.1:
selectedSeries.Tags[cntSelected] = dataRow;
It throws a null reference exception.
I changed the line to
selectedSeries.Tags.Add(cntSelected, dataRow);
then it worked, but when I want to redraw my chart and call
selectedSeries.ClearDataPoints(); I again get a null reference exception. When I don't set a Tag at all, everything works fine.
Here's the complete code which sets the chart (I left out some irrelevant parts):
        private void SetChart(bool setCostFunction)
        {
            selectedSeries.ClearDataPoints();
            unselectedSeries.ClearDataPoints();

            costfunctionSeries.ClearDataPoints();
            lowerConfidenceIntervalSeries.ClearDataPoints();
            upperConfidenceIntervalSeries.ClearDataPoints();

            double maxXVal = Double.MinValue;

            //Add all Baggerungen that are in the list:
            List<double> xVals = new List<double>();
            List<double> yVals = new List<double>();

            int cntSelected = 0;
            int cntUnSelected = 0;

            foreach (DataGridViewRow row in dgvOverview.Rows)
            {
                //Only add if nettosumme and Kubatur are present!
                DataRowView drv = (DataRowView)row.DataBoundItem;
                var dataRow = (WAMSDataSet.VwBaggerungOverviewRow)drv.Row;

                if (!dataRow.IsKubaturNull() && !dataRow.IsNettosummeNull())
                {
                    //Add to Lists:
                    xVals.Add(dataRow.Kubatur);
                    yVals.Add(dataRow.Nettosumme);

                    if (maxXVal < dataRow.Kubatur)
                    {
                        maxXVal = dataRow.Kubatur;
                    }

                    NDataPoint dataPoint = new NDataPoint(dataRow.Kubatur, dataRow.Nettosumme);
                   
                    //Is the row selected?
                    if (dataRow.Auswahl)
                    {
                        selectedSeries.AddDataPoint(dataPoint);
                        //Store ID as Tag!
                        //DOES NOT WORK ANYMORE!!!!
                        //selectedSeries.Tags.Add(cntSelected, dataRow);
                        //selectedSeries.Tags[cntSelected] = dataRow;
                        cntSelected++;
                    }
                    else
                    {
                        unselectedSeries.AddDataPoint(dataPoint);
                        //Store ID as Tag!
                        //DOES NOT WORK ANYMORE!!!!
                        //unselectedSeries.Tags[cntUnSelected] = dataRow;
                        //unselectedSeries.Tags.Add(cntUnSelected, dataRow);
                        cntUnSelected++;
                    }
                }
            }
    chartControl.Refresh();
}


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search