Page 1 of 1
Converting Series type Line to Area
Posted: Fri Jan 30, 2015 11:24 am
by 16071129
While converting Series type Line to Area I am getting
"System.NullReferenceException - Object reference not set to an instance of an object."
I used following code.
Code: Select all
Steema.TeeChart.Styles.Series tSeries = tChartMain[0];
Steema.TeeChart.Styles.Series.ChangeType(ref tSeries, typeof(Steema.TeeChart.Styles.Area));
Steema.TeeChart.Styles.Area tArea = (Steema.TeeChart.Styles.Area)tChartMain.Series[0];
Kindly Help in resolving this issue.
Re: Converting Series type Line to Area
Posted: Fri Jan 30, 2015 12:32 pm
by narcis
Hello Quant,
This is a bug which I have added to our bug tracking system (
ID1109). I also fixed it for the next maintenance release. In the meantime you can do something like this:
Code: Select all
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
Steema.TeeChart.Styles.Series tSeries = tChart1[0];
//Steema.TeeChart.Styles.Series.ChangeType(ref tSeries, typeof(Steema.TeeChart.Styles.Area));
Steema.TeeChart.Styles.Area tArea = new Steema.TeeChart.Styles.Area(tChart1.Chart);
tArea.DataSource = tSeries;
tArea.Color = tSeries.Color;
tArea.LinePen.Color = (tChart1[0] as Steema.TeeChart.Styles.Line).LinePen.Color;
tArea.AreaLines.Color = tArea.LinePen.Color;
tChart1.Series.Remove(tSeries);
Re: Converting Series type Line to Area
Posted: Mon Feb 02, 2015 4:35 am
by 16071129
Thank you for your reply and workaround.
The Bugzilla link provided by you is showing the status RESOLVED FIXED.
Kindly send me the new solution.
Re: Converting Series type Line to Area
Posted: Mon Feb 02, 2015 8:21 am
by narcis
Hello Quant,
I see you are a source code customer. In that case you should add the code snippet below at the private void
Steema.TeeChart.Styles.Custom.DrawArea(Color BrushColor, int x, int y, int valueIndex) method in Custom.cs
Code: Select all
if (bAreaBrush == null)
{
bAreaBrush = new ChartBrush();
}
This should be added below those lines:
Code: Select all
Graphics3D g = chart.graphics3D;
bool oldBrushVisible = false;
Something like this:
Code: Select all
Graphics3D g = chart.graphics3D;
bool oldBrushVisible = false;
if (bAreaBrush == null)
{
bAreaBrush = new ChartBrush();
}
if (ColorEach)
{
//code continues here
Re: Converting Series type Line to Area
Posted: Mon Feb 02, 2015 12:28 pm
by 16071129
Now getting same error
Object reference not set to an instance of an object.
on line no. 3548 that is
which is in DrawPoint() Method of Custom.cs
Code: Select all
if (drawArea)
{
Color tmp = GetAreaBrushColor(tmpColor);
oldPenColor = pAreaLines.Color;
if (pAreaLines.Visible)
{
if (ColorEach)
{
pAreaLines.Color = Utils.DarkenColor(tmp, 60);
}
}
else
{
pAreaLines.Color = tmp;
}
g.Pen = pAreaLines;
DrawArea(tmp, x, y, valueIndex);
pAreaLines.Color = oldPenColor;
}
Re: Converting Series type Line to Area
Posted: Mon Feb 02, 2015 12:37 pm
by narcis
Hello Quant,
Does it occur running the same code
I added at bugzilla?
Code: Select all
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
Steema.TeeChart.Styles.Series tSeries = tChart1[0];
Steema.TeeChart.Styles.Series.ChangeType(ref tSeries, typeof(Steema.TeeChart.Styles.Area));
That being the case you might need more changes that have been implemented at our internal sources since the last maintenance release and you should wait for the next one.
Otherwise, please send us a simple code snippet we can run "as-is" to reproduce the problem here.
Thanks in advance.
Re: Converting Series type Line to Area
Posted: Mon Feb 02, 2015 1:10 pm
by narcis
Hello Quant,
NarcĂs wrote:
That being the case you might need more changes that have been implemented at our internal sources since the last maintenance release
You could also check if
pAreaLines is being initialized at
AreaLines property in Area.cs, for example:
Code: Select all
public ChartPen AreaLines
{
get
{
if (pAreaLines == null) pAreaLines = new ChartPen(chart, Color.Black);
return pAreaLines;
}
}