I am plotting points in a line chart continuously, reading data from a device every second. This may go upto an hour or more.
i.e, plotting almost 3600 points every hour . The elapsed time/sample number is displayed in the X-Axis label.
After a few minutes of plotting, the X-Axis labels disappear. this is because there is no more space to display them.
I do not want to use the scroll bar and scaling.
Is it possible to modify label display at runtime ? For example, if I have a chart display area equivalent to the size of this Text box, then to start with I will display all sample numbers/elapsed time [vertically] like 1 2 3 5 6 ....
After sometime, based on the lenght of X Axis, when some number of points have been plotted, then I will start displaying only selected labels like: 1 5 10 15 20 ......
Again after some number of points are plotted, I will change to 1 10 20 30 40 ....
and then 1 20 40 ..... like this....
Is there a way to do this?
You can try using Scatter chart for this. I've tried:
table.Columns.Add("a", typeof(string));
table.Columns.Add("Y", typeof(int));
table.Rows.Add(new object[ { "b", 20, 10 });
this.ultraChart1.ScatterChart.ConnectWithLines = true;
this.ultraChart1.ScatterChart.IconSize = Infragistics.UltraChart.Shared.Styles.SymbolIconSize.Small;
this.ultraChart1.DataSource = table;
this.ultraChart1.DataBind();
In this case when you want to change the interval that the labels are displayed you can just put:
this.ultraChart1.Axis.X.TickmarkInterval = 10;
I tried that. I think we are only hiding few labels when we specify TickMarkInterval.
Because same output is observed after plotting some points. The labels that are displayed based on the Interval specified, start becoming blur [ truncated top and bottom when drawn vertically] and after some more point they vanish.
Is there a way to clear all labels and redr aw labels ?
It's little hard to reproduce this problem. Which version of our chart are you using?
I've also tried this:
public partial class Form1 : Form
{
InitializeComponent();
}
series.Points.Add(dataPoint);
int count = series.Points.Count;
and when new points are added the x-axis labels are recalculated automatically. If this still doesn't help, could you send us your code so we can investigate the problem?
Only difference is that I have to plot against time [ show date time as X - Axis label]
I am having problem if I have to display datavalues against time. Whatever problem I have is with Linechart displaying Date Time in X-Axis as label [ Instead of XYSeries and XYDataPoint Am using NumericTimeSeries and NumericDataPoint respectively ]
Is it possible to have Scatter chart displaying DateTime as labels...
I am using 8.1 version
In the code below I have tried to reproduce the problem
private Random rnd; System.Windows.Forms.Timer timer1;public Form1() { InitializeComponent();rnd = new Random(); ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;ultraChart1.LineChart.TreatDateTimeAsString = true;ultraChart1.Axis.X.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.DataInterval; ultraChart1.Axis.X.TickmarkInterval = 2;ultraChart1.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>"; }protected override void OnLoad(EventArgs e) { base.OnLoad(e);NumericTimeSeries series = new NumericTimeSeries(); for (int i = 0; i <= 5; i++) {System.Threading.Thread.Sleep(500);NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point); this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh(); } ultraChart1.Axis.X.TickmarkInterval = 5; int count = series.Points.Count;for (int i = 1; i <= count + 20; i++) {System.Threading.Thread.Sleep(500); RepeatDraw(); } ultraChart1.Axis.X.TickmarkInterval = 10; timer1 = new Timer(); timer1.Interval = 100;timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); }private void RepeatDraw() { NumericTimeSeries series = this.ultraChart1.Series[0] as NumericTimeSeries;NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point); this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh(); }private void timer1_Tick(object sender, EventArgs e) { NumericTimeSeries series = this.ultraChart1.Series[0] as NumericTimeSeries; int count = series.Points.Count;for (int i = 1; i <= count + 200; i++) { NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point);this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh(); } timer1.Stop(); }
System.Windows.Forms.Timer timer1;
ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;
ultraChart1.Axis.X.TickmarkInterval = 2;
base.OnLoad(e);NumericTimeSeries series = new NumericTimeSeries(); for (int i = 0; i <= 5; i++) {System.Threading.Thread.Sleep(500);NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point); this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh(); } ultraChart1.Axis.X.TickmarkInterval = 5; int count = series.Points.Count;for (int i = 1; i <= count + 20; i++) {System.Threading.Thread.Sleep(500); RepeatDraw(); } ultraChart1.Axis.X.TickmarkInterval = 10; timer1 = new Timer(); timer1.Interval = 100;timer1.Tick += new EventHandler(timer1_Tick); timer1.Start();
base.OnLoad(e);
series.Points.Add(point);
this.ultraChart1.Series.Add(series);
ultraChart1.Axis.X.TickmarkInterval = 5;
RepeatDraw();
ultraChart1.Axis.X.TickmarkInterval = 10;
timer1.Interval = 100;
timer1.Start();
NumericTimeSeries series = this.ultraChart1.Series[0] as NumericTimeSeries;NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point); this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh();
NumericTimeSeries series = this.ultraChart1.Series[0] as NumericTimeSeries; int count = series.Points.Count;for (int i = 1; i <= count + 200; i++) { NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point);this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh(); } timer1.Stop();
NumericTimeDataPoint point = new NumericTimeDataPoint(DateTime.Now, rnd.Next(100), DateTime.Now.ToShortTimeString(), false); series.Points.Add(point);this.ultraChart1.Series.Add(series);this.ultraChart1.Refresh();
timer1.Stop();
In this case the code can be something like:
private Random rnd;
this.dateTime = DateTime.Now;
this.ultraChart1.Axis.X.TickmarkIntervalType = Infragistics.UltraChart.Shared.Styles.AxisIntervalType.Seconds;
It worked.
Thanks a lot.
Regards
sanms
You can try adding the following line:
this.ultraChart1.Axis.X.Labels.Layout.Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.None;
Even this did not solve my problem. You can simulate it by just copying the code below and running it for some time, say for 300 seconds..
Sorry I could not insert the output graph here.
I modified your code to have a delay of 500ms before each draw. Because I get data from device based on a specified interval [say every second]
Also added 1 Second to dateTime after each draw.
private const int maxLabels = 15;
private DateTime dateTime;
public Form1()
rnd = new Random();
protected override void OnLoad(EventArgs e)
NumericTimeSeries series = new NumericTimeSeries();
this.ultraChart1.Axis.X.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.DataInterval;
System.Windows.Forms.Timer timer1 = new Timer();
timer1.Interval = 500;
timer1.Tick +=new EventHandler(timer1_Tick);
private void timer1_Tick(object sender, EventArgs e)
NumericTimeSeries series = this.ultraChart1.Series[0] as NumericTimeSeries;
NumericTimeDataPoint dataPoint = new NumericTimeDataPoint(this.dateTime, rnd.Next(100), dateTime.ToString(), false);
this.ultraChart1.Axis.X.TickmarkInterval = count / maxLabels;
dateTime = dateTime.AddSeconds(1);