Profile Picture

Labels missing

Posted By Reimund Köhler 14 Years Ago
Author
Message
bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Reimund,

If it works then I don't need a test app . Let me know if you meet any problems.

Best regards,
Bob



Reimund Köhler
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Hi Bob,

I tried both. The lock method didn't help. But that was no real surprise, because all control interaction was made by the UI thread only.

Fortunately the invalidate method is working. I used
NAxis axis = control.Charts[0].Axis (StandardAxis.PrimaryX);
axis.InvalidateScale();

So I'm happy with my labeled charts. Many thanks for your help. Sorry, a test app ist not available. As written before, my own test app was working without any problems.

My real app is deserializing and copying the chart control internally. Maybe that treatment leads to some kind of confusion. At the moment putting that treatment into a test app is too much effort. Sorry.

Best regards,
Reimund

bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Reimund,

This is obviously a multithreading issue. Note that the component is not thread safe meaning that you have to synchronize access to the chart document when accessed from say a worker thread and the UI thread which seems to be the case. This is done by inserting all code that modifies the chart inside a lock / unlock block:

nChartControl1.Document.Lock();

// code for chart modification goes here

nChartControl1.Document.Unlock();

You can also try to explicitly invalidate the scale using:

NAxis axis = nChartControl1.Charts[0].Axes(StandardAxis.PrimaryX);
axis.InvalidateScale();

after you feed labels.

Hope this helps - is it possible to send a test app that replicates the problem?

Best regards,
Bob



Reimund Köhler
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Hi Bob,
yes the problem persists. The code snippet works fine, but the real application is much more complicated and i'm not able to reproduce the effect in a sample.

The real application gets statistical data from a database. Retrieving the data needs some time. Therefore I implemented the retrieving in a background thread. After receiving the data in the worker thread, the main thread puts the data into the chart control.

Using the background processing, the labels for the x-axis are missing in the chart graphic. Inspecting the control in the debugger, the labels are correct. Deactivating the background processing, everything is fine and chart graphic display the labels correctly. Using background processing and AutoLabels=true, also the labels appear.

In the meanwhile I tried two different kinds of background processing, but none displays the labels in the real application. I have build a test application with background processing and it's working fine. But the real application, .... :-(

One special thing of the real application is the dynamic creation of the chart control. Maybe some special features get lost (i.e. events). But that's just a guess.

Best regards
Reimund

bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Reimund,

Most likely the item.regptName field does not contain a valid string - I just tested with the following code:

  class NItem
  {
   public NItem(string name, double value)
   {
    Name = name;
    Value = value;
   }

   public string Name;
   public double Value;
  }

  List<NItem> items = new List<NItem>();

  private void Form1_Load(object sender, EventArgs e)
  {
   NChart chart = nChartControl1.Charts[0];
   chart.Series.Add(SeriesType.Bar);
  }

  private void button1_Click(object sender, EventArgs e)
  {
   items.Clear();
   Random rand = new Random();
   items.Clear();
   int count = rand.Next(10);
   for (int i = 0; i < count; i++)
   {
    double value = rand.Next(100);
    items.Add(new NItem(value.ToString(), value));
   }

   RefreshChart();
  }

  private void RefreshChart()
  {
   NBarSeries series = (NBarSeries)nChartControl1.Charts[0].Series[0];
   series.Values.Clear();

   NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).ScaleConfigurator;
   scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;
   scaleConfiguratorX.AutoLabels = false;
   scaleConfiguratorX.Labels.Clear();

   foreach (NItem item in items)
   {
    scaleConfiguratorX.Labels.Add(item.Name);
    series.Values.Add(item.Value);
   }

   nChartControl1.Refresh();
  }

and the control was working properly. Let me know if the problem persists...

Best regards,
Bob



Reimund Köhler
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Hello,
I'm drawing a simple horizontal bar chart. While using AutoLabels=true, all is working fine. But setting AutoLabels=false, there are no labels drawn. What's my mistake?


NBarSeries series = (NBarSeries)control.Charts[0].Series[0];
series.Values.Clear();

NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)control.Charts[0].Axis(StandardAxis.PrimaryX).ScaleConfigurator;
scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;
scaleConfiguratorX.AutoLabels = false;
scaleConfiguratorX.Labels.Clear();

foreach (breakageData item in this_list.Values)
{
scaleConfiguratorX.Labels.Add(item.regptName);
series.Values.Add(item.percent);
}
control.Refresh();


Regards
Reimund Köhler




Similar Topics


Reading This Topic