Hi
I'm trying to create charts that render either a CurveArea gallery type or Area depending on the users selection. The first thing is that these chart types behave very differently and I have to modify behaviour depending upon which type is selected. If it's an Area I provide values for X, Y and YFrom which then draws the chart correctly. If it's a CurveArea I have to run through the list twice, once for the high value and once for the low value.
For both charts I set the colour opacity to around 60 so that the chart is a little transparent. The issue I have is that for an Area chart I get lines drawn between the Y and YFrom value, I don't want these lines at all as I want a nice clear area drawn. For the CurveArea it doesn't draw the lines as with Area but the first point always draws down to Zero regardless of the set of values.
The sample code below illustrates the problem if anyone has time to try it, just change the Chart Gallery type to Area or CurveArea
chart1.Gallery =
Gallery.Area;List<HighLow> _values = new List<HighLow>();
HighLow _one = new HighLow{ Date = DateTime.Now, High = 10,
Low = 5
};
HighLow _two = new HighLow{ Date = DateTime.Now.AddHours(6), High = 11,
Low = 4
};
HighLow _three = new HighLow{ Date = DateTime.Now.AddHours(12), High = 8,
Low = 2
};
_values.Add(_one);
_values.Add(_two);
_values.Add(_three);
chart1.Data.Series = 1; chart1.Series[0].Color = Color.FromArgb(50, 255, 20, 30); chart1.Series[0].FillMode =
FillMode.Solid;chart1.AxisX.ForceZero = false; chart1.AxisX.LabelsFormat.Format =
AxisFormat.DateTime;chart1.AxisX.DataFormat.Format = AxisFormat.DateTime; chart1.AxisX.LabelsFormat.CustomFormat =
"dd\nMMM";chart1.AxisX.Min = DateTime.Now.AddDays(-1).ToOADate();chart1.AxisX.Max = DateTime.Now.AddDays(1).ToOADate(); chart1.Series[0].SeparateSlice = 1;
if (chart1.Gallery == Gallery.Area) {
chart1.DataSourceSettings.Fields.Add(
new FieldMap("Date", FieldUsage.XValue));chart1.DataSourceSettings.Fields.Add(new FieldMap("Low", FieldUsage.FromValue)); chart1.DataSourceSettings.Fields.Add(
new FieldMap("High", FieldUsage.Value));ListProvider lstProvider = new ListProvider(_values); chart1.DataSourceSettings.DataSource = lstProvider;
}
else{
foreach (HighLow _highLow in _values) {
int _pointId = chart1.Data.Points ++; chart1.Data.X[0, _pointId] = _highLow.Date.ToOADate();
chart1.Data.Y[0, _pointId] = _highLow.Low;
}
_values.Reverse();
foreach (HighLow _highLow in _values) {
int _pointId = chart1.Data.Points++; chart1.Data.X[0, _pointId] = _highLow.Date.ToOADate();
chart1.Data.Y[0, _pointId] = _highLow.High;
}
}
The code above uses a class as below
class HighLow{
public int High { get; set; }
public int Low { get; set; }public DateTime Date { get; set; } }