Hi,
I am plotting scatter chart for 2 days. But there is a time in between when there is no data at all. Is there a way that I can get rid of this empty area on x-axis, and from the whole chart?
I want the x-axis label to be shown only if the data (y) is avaiable. For example, there is no data between 12-11 15:36 and 12-12 09:54, then this space should disappear on x-axis, and make the chart look continuous.
Many Thanks in Advance
Do you mean that you want to have breaks in your x axis scale? I don't think this would be possible. The axis scale has to be linear (or logarithmic) and continuous. Could you post a picture of what the chart would look like?
Thanks for the response. The image upload requires the picture to be at a URL, but unfortunately I can't.
Is there any mean that I can send you through an attachment?
In sum the graph looks like the following.
From 12-11 9:30 to 12-11 15:36 (There are data points.)
From 12-11 15:36 to 12-12 09:54 (There are no data points) <-- This takes more space than the actual data points, and need not be shown at all.)
From 12-12 09:54 to 12-12 15:50 (There are data points.)
Thanks
You can upload attachments by going to the options menu and selecting Add/Update (refer to the attached screenshot). Unfortunately, the chart axis doesn't allow breaks. Working around this can be tricky. I would suggest using a composite chart and creating 2 x axes and 2 chart layers side by side. You can also submit a feature request for this:http://devcenter.infragistics.com/Protected/RequestFeature.aspx
What happens if I am going to plot for 2 weeks (14 days), and I need to ignore all times between 4PM and the next day's 9AM, and the 2 weendend days?
And this case, I need 12 different X-axis (one for each day except weekends) to be laid side by side to make the chart look continuous. Is that allowed in Infragistics?
Breaks in X-Axis is one of the most essential features to have in any financial chart. I have requested the feature, but wonder how long it would take to be released.
If the above idea of having multiple X-Axis aligned side-by-side, can you please give me a quick code sample?
Do I need to create multiple layers (all scatter), or do I have to create multiple chart area?
It's easier to use 2 chart layers in a single chart area and manipulate the axis location with the Margin property. Here's an example:
ultraChart1.ChartType = ChartType.Composite;ChartArea area = new ChartArea();ultraChart1.CompositeChart.ChartAreas.Add(area);
AxisItem xAxis1 = new AxisItem();xAxis1.OrientationType = AxisNumber.X_Axis;xAxis1.DataType = AxisDataType.String;xAxis1.Margin.Far.Value = 50;xAxis1.Margin.Far.MarginType = LocationType.Percentage;AxisItem xAxis2 = new AxisItem();xAxis2.OrientationType = AxisNumber.X_Axis;xAxis2.DataType = AxisDataType.String;xAxis2.Margin.Near.MarginType = LocationType.Percentage;xAxis2.Margin.Near.Value = 50;
AxisItem yAxis = new AxisItem();yAxis.OrientationType = AxisNumber.Y_Axis;area.Axes.Add(xAxis1);area.Axes.Add(xAxis2);area.Axes.Add(yAxis);
ChartLayerAppearance layer1 = new ChartLayerAppearance();layer1.ChartType = ChartType.ColumnChart;layer1.AxisX = xAxis1;layer1.AxisY = yAxis;layer1.ChartArea = area;ultraChart1.CompositeChart.ChartLayers.Add(layer1);
ChartLayerAppearance layer2 = new ChartLayerAppearance();layer2.ChartType = ChartType.ColumnChart;layer2.AxisX = xAxis2;layer2.AxisY = yAxis;layer2.ChartArea = area;ultraChart1.CompositeChart.ChartLayers.Add(layer2);
NumericSeries series = new NumericSeries();series.Points.Add(new NumericDataPoint(0, "", false));series.Points.Add(new NumericDataPoint(6, "", false));ultraChart1.CompositeChart.Series.Add(series);
layer1.Series.Add(series);layer2.Series.Add(series);
I tried replicating this, but couldn't get the same behavior. Please check your data to make sure that factorData.x.Value is not always the same for each layer. That's really the only thing I can think of at the moment. You can debug the problem better if you bound your series to some very simple sample data. Otherwise, the code seems correct to me.
I first setup the chart like the following:
try
{
_chart.ChartType =
ChartType.Composite;
ChartArea area = new ChartArea();
_chart.CompositeChart.ChartAreas.Add(area);
yAxis.DataType =
AxisDataType.Numeric;
yAxis.Labels.Flip =
false;
yAxis.Labels.ItemFormat =
AxisItemLabelFormat.DataValue;
yAxis.Labels.ItemFormatString =
"<DATA_VALUE:0.##>";
yAxis.Labels.HorizontalAlign =
StringAlignment.Far;
yAxis.Labels.Layout.Behavior =
AxisLabelLayoutBehaviors.Auto;
yAxis.Labels.OrientationAngle = 0;
yAxis.Labels.VerticalAlign =
StringAlignment.Center;
yAxis.Labels.SeriesLabels.HorizontalAlign =
yAxis.Labels.SeriesLabels.Layout.Behavior =
yAxis.LineThickness = 1;yAxis.OrientationType =
AxisNumber.Y_Axis;
yAxis.RangeType =
AxisRangeType.Automatic;
yAxis.TickmarkStyle =
AxisTickStyle.Smart;
yAxis.NumericAxisType =
NumericAxisType.Linear;
yAxis.Visible =
true;
area.Axes.Add(yAxis);
_compositeChartLayers =
new Dictionary<string, ChartLayerAppearance>();
for (int i = 0; i< numberOfDays_; i++)
AxisItem xAxis = new AxisItem(_chart, AxisNumber.X_Axis);
xAxis.Key = dayLabel;
xAxis.Labels.ItemFormat =
xAxis.Labels.ItemFormatString =
xAxis.Labels.Layout.Behavior =
AxisLabelLayoutBehaviors.None;
xAxis.Labels.Orientation =
TextOrientation.VerticalLeftFacing;
xAxis.Labels.OrientationAngle = 0;xAxis.Labels.VerticalAlign =
xAxis.LineThickness = 1;
xAxis.OrientationType =
AxisNumber.X_Axis;
xAxis.RangeType =
xAxis.TickmarkStyle =
AxisTickStyle.DataInterval;
xAxis.Visible =
if (i != 0)
xAxis.Margin.Near.Value = 50;
xAxis.Margin.Near.MarginType =
LocationType.Percentage;
}
else
xAxis.Margin.Far.Value = 50;xAxis.Margin.Far.MarginType =
area.Axes.Add(xAxis);
ChartLayerAppearance layer = new ChartLayerAppearance();
layer.ChartType =
ChartType.ScatterChart;
layer.AxisX = xAxis;
layer.AxisY = yAxis;
layer.ChartArea = area;
if (!_compositeChartLayers.ContainsKey(i.ToString()))
_compositeChartLayers.Add(i.ToString(), layer);
_chart.CompositeChart.ChartLayers.Add(layer);
Then, when I get the data, I populate like the following:
In the below, factorDataCollection is the collection of all data points, and from that, I created XYSeries for each day. (The main logic is to check which date it belongs to, and populate the right series.
for (int i = 0; i < _numberOfDays; i++)
XYSeries xySerie = new XYSeries();
_chartSeries.Add(i.ToString(), xySerie);
if (_factorDataCollection != null)
int count = _factorDataCollection.Count;
if (count > 0)
for (int i = 0; i < _factorDataCollection.Count; i++)
FactorDataPoints factorData = _factorDataCollection[i] as FactorDataPoints;
if (factorData != null && !string.IsNullOrEmpty(factorData.FactorName) && factorData.x.HasValue && factorData.y.HasValue)
if (_tradingPeriodsInUnix != null && _tradingPeriodsInUnix.Count > 0)
foreach (int key in _tradingPeriodsInUnix.Keys)
int startTime = _tradingPeriodsInUnix[key].Key;
int endTime = _tradingPeriodsInUnix[key].Value;
bool isFirstDay = key == 0;
if (isFirstDay)
if (factorData.x.Value > startTime && factorData.x < endTime)
_chartSeries[key.ToString()].Points.Add(
new XYDataPoint(factorData.x.Value, factorData.y.Value, factorData.FactorName, false
));
(factorData.x.Value > startTime && factorData.x < endTime)
foreach (var dayKey in _compositeChartLayers.Keys)
_chart.CompositeChart.Series.Add(_chartSeries[dayKey]);
_compositeChartLayers[dayKey].Series.Add(_chartSeries[dayKey]);
_chart.InvalidateLayers();
Only the series object itself needs to be created beforehand. The number of data points can change dynamically, either by adding new points to the points collection or rebinding the series.
It's hard to tell what's happening in the image from the code snippet. Can you provide a more complete snippet or a sample? I would have to see what the data looks like and how the chart is created.
First, This won't work as the chart need to plot both Historical and Real-Time data. Correct me if I am wrong, but from what I see, all composite charts need to have a definite series that are already created beforehand.
Secondly, I have tried for two days, but this is what I am getting (see picture).
Can you please tell me why they are all plotted in this weird horizonal lines than using the empty space that does not have y-value?
I am using XYSeries, and have used the following setting for 2 X-Axis.
day 0:
xAxis.Margin.Far.Value = 50;
xAxis.Margin.Far.MarginType =
day 1: