This question is locked. New answers and comments are not allowed.
Hi telerik,
I'm creating images,actually byte array, from 4 RadCartesianCharts at server side without user intervention
with parallel task using STA thread at each chart,in which saves byte array into DB
and re-assembled to bitmap image at client side to display on WPF view.
Among 4 images,others works great except 1 specific chart,which composed of only annotations.
It is incomplete at first time missing some annotaions,however, when I try re-creating
then it shows completely. All calculation procedure and every variable to draw chart is same.
Pls see attached images comparing 2 images.
Creating chart is as follows;
Follwoing is to convert byte array with chart.
Any advice would be highly appreciated.
TIA
Kang
I'm creating images,actually byte array, from 4 RadCartesianCharts at server side without user intervention
with parallel task using STA thread at each chart,in which saves byte array into DB
and re-assembled to bitmap image at client side to display on WPF view.
Among 4 images,others works great except 1 specific chart,which composed of only annotations.
It is incomplete at first time missing some annotaions,however, when I try re-creating
then it shows completely. All calculation procedure and every variable to draw chart is same.
Pls see attached images comparing 2 images.
Creating chart is as follows;
RadCartesianChart cartChart = GetChart(GraphTypeEnums.OGR);
// decide x axis
cartChart.HorizontalAxis = new LinearAxis() { Maximum = _calculus.XMax, Minimum = _calculus.XMin, MajorStep = 1, Title = "나이" };
// decide y max
cartChart.VerticalAxis = new LinearAxis() { Maximum = _calculus.YMax, Minimum = _calculus.YMin, MajorStep = 1, Title = "AMH(ng/ml)" };
// draw when only allowable
if (AnalysisCalculator.AmhResultAllowable(_age))
{
// no series value but chart needs a series.
ScatterLineSeries scatterSeries = new ScatterLineSeries() { Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2 };
scatterSeries.XValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Age" };
scatterSeries.YValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Num" };
// 1 point of (0,0)
scatterSeries.ItemsSource = CordXy.GetACGList(0, 0);
cartChart.Series.Add(scatterSeries);
DoubleCollection aray = new DoubleCollection(new double[] { 1, 1 });
// amh line
cartChart.Annotations.Add(
new CartesianGridLineAnnotation
{
Axis = cartChart.VerticalAxis,
Value = _calculus.AmhLineVal,
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 2,
DashArray = aray
});
// age line
cartChart.Annotations.Add(
new CartesianGridLineAnnotation
{
Axis = cartChart.HorizontalAxis,
Value = _resultRoot.MedianAge,
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 2,
DashArray = aray
});
// amh range
cartChart.Annotations.Add(
new CartesianMarkedZoneAnnotation
{
HorizontalFrom = _calculus.IntAge - 0.2,
HorizontalTo = _calculus.IntAge + 0.2,
VerticalFrom = _calculus.FVMax,
VerticalTo = _calculus.FVMin,
Fill = new SolidColorBrush(Colors.DarkGray)
});
// value range
cartChart.Annotations.Add(
new CartesianMarkedZoneAnnotation
{
HorizontalFrom = _calculus.IntAge - 0.2,
HorizontalTo = _calculus.IntAge + 0.2,
VerticalFrom = _calculus.RVMax,
VerticalTo = _calculus.RVMin,
Fill = new SolidColorBrush(_calculus.Normal ? Colors.Blue : Colors.Red)
});
// mark top indicator
cartChart.Annotations.Add(
new CartesianCustomLineAnnotation
{
HorizontalFrom = _calculus.IntAge - 0.2 + (_calculus.Normal ? 0 : -0.2),
HorizontalTo = _calculus.IntAge + 0.2 + (_calculus.Normal ? 0.2 : 0),
VerticalFrom = _calculus.RVMax,
VerticalTo = _calculus.RVMax,
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 2
});
// boottom indicator
cartChart.Annotations.Add(
new CartesianCustomLineAnnotation
{
HorizontalFrom = _calculus.IntAge - 0.2 + (_calculus.Normal ? -0.2 : 0),
HorizontalTo = _calculus.IntAge + 0.2 + (_calculus.Normal ? 0 : 0.2),
VerticalFrom = _calculus.RVMin,
VerticalTo = _calculus.RVMin,
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 2
});
}
Follwoing is to convert byte array with chart.
private byte[] GetImageBytes(RadCartesianChart chart)
{
chart.Measure(new System.Windows.Size(chart.Width, chart.Height));
chart.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), chart.DesiredSize));
using (var stream = new MemoryStream())
{
Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(chart, stream, new PngBitmapEncoder());
return stream.ToArray();
}
}
Any advice would be highly appreciated.
TIA
Kang