08-26-2013 07:07 AM
Hi ,
We are using NationalInstruments.UI.WebForms.ScatterGraph to genenarte a graph. We are facing problem some times the xaxis range is not refreshing. All the plots are added without any issues but Range is not refreshing.Please refer the attachment.
Version Details:
Runtime Version : v4.0.30319
Version :9.0.40.292
// Before calling the CreateGraph method we are calling setdaterange method .
//As a default it will show 24hrs interval after that it will show it in selected date range which is selected from the top of UI.
private void SetDateRange(XAxis xAxis)
{
try
{
if (isDefault)
{
xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate);
xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy HH:mm:ss");
xAxis.Mode = AxisMode.Fixed;
xAxis.AutoSpacing = false;
xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(6), typeof(double));
xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));
}
else
{
xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy");
xAxis.Mode = AxisMode.Fixed;
xAxis.AutoSpacing = false;
if (startdate == enddate)
{
xAxis.Range = new Range((DateTime)startdate, new TimeSpan(23, 0, 0));
}
else
{
xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate.Add(new TimeSpan(23, 0, 0)));
}
xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(2), typeof(double));
xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));
}
}
catch (Exception ex)
{
TM.Trace(LogLevel.Error, ex.Message);
}
}
// We are adding the graphs as below
private void CreateGraph(double[] ChartDateTime, double[] Values) try
{
try
{
ScatterPlot newPlot = new ScatterPlot();
int chartlen = 0;
chartlen = ChartDateTime.Length;
double[] dataX = new double[chartlen];
double[] dataY = new double[chartlen];
DateTime[] dateX = new DateTime[chartlen];
XAxis xAxis = xyDataGraph.XAxes[0];
YAxis yAxis = xyDataGraph.YAxes[0];
newPlot.XAxis = xAxis;
newPlot.YAxis = yAxis;
yAxis.AutoSpacing = false;
yAxis.MajorDivisions.Base = 0;
yAxis.MajorDivisions.Interval = 3;
yAxis.MinorDivisions.Base = 0;
yAxis.MinorDivisions.Interval = 1;
yAxis.Range = new Range(0, 10);
xyDataGraph.YAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.Numeric, "0");
newPlot.PlotXY(ChartDateTime, Values);
xyDataGraph.Plots.Add(newPlot);
xyDataGraph.DataBind();
}
catch (Exception ex)
{
TM.Trace(LogLevel.Error, ex.Message);
}
}
Please let us know if we have missed out anything. Please find the attached image.
Regards
Guhan.S