|
Group: Forum Members
Posts: 86,
Visits: 221
|
Hi Experts,
I have a FastPoint Chart with Y axis as a NLogarithmicScaleConfigurator. The plotting of the points is done in Paint2D. When I use the code with a Linear axis everything is working fine. But when I switch the axis to NLogarithmicScale, the following doesnt work anymore: NScale axisScaleY = m_Chart.Axis(m_Series.VerticalAxes[0]).Scale; axisScaleY.Ruler.GetScaleAndOffset(out scaleY, out offsetY);
=> the out values scaleY and offsetY are always 0.
So what must be changed in the following code that it also is working for logarithmic axis ?
Thanks for your help, Best regards, Joern
Code which is working for Linear axis::
public void Paint2D(NChartRenderingContext2D context, NGraphics graphics) { unsafe { if (graphics == null || graphics.DeviceGraphics == null) return;
if (m_XValues.Length < 1 || m_YValues.Length < 1) return;
NScale axisScaleX = m_Chart.Axis(m_Series.HorizontalAxes[0]).Scale; NScale axisScaleY = m_Chart.Axis(m_Series.VerticalAxes[0]).Scale; NScaleRuler rulerX = axisScaleX.Ruler; NScaleRuler rulerY = axisScaleY.Ruler; // cache values need to be transformed from logical to scale double[] xValues = m_XValues; double[] yValues = m_YValues;
int count = xValues.Length; float modelScaleX = (float)1.0; float modelScaleY = (float)1.0;
GraphicsState state = graphics.DeviceGraphics.Save();
context.ActivateCamera(m_Chart);
double scaleX = 0.0; double offsetX = 0.0;
rulerX.GetScaleAndOffset(out scaleX, out offsetX); scaleX *= modelScaleX; offsetX *= modelScaleX;
double scaleY = 0.0; double offsetY = 0.0;
try { rulerY.GetScaleAndOffset(out scaleY, out offsetY); } catch (Exception) { //throw; }
scaleY *= modelScaleY; offsetY *= modelScaleY;
NRange1DD viewXRange = axisScaleX.RulerRange; NRange1DD viewYRange = axisScaleY.RulerRange;
double viewX1 = viewXRange.GetValueInRange(m_XRange.Begin); double viewX2 = viewXRange.GetValueInRange(m_XRange.End); double viewY1 = viewYRange.GetValueInRange(m_YRange.Begin); double viewY2 = viewYRange.GetValueInRange(m_YRange.End);
if (double.IsNaN(viewX1) || double.IsInfinity(viewX1)) return; if (double.IsNaN(viewX2) || double.IsInfinity(viewX2)) return; if (double.IsNaN(viewY1) || double.IsInfinity(viewY1)) return; if (double.IsNaN(viewY2) || double.IsInfinity(viewY2)) return;
int pointSize = (int)context.Device.LengthConverter.ConvertNLengthToLength(new NLength(m_PointSize, NGraphicsUnit.Point)); int pointSizeDiv2 = pointSize / 2;
int pointOffsetX = pointSize; int pointOffsetY = pointSize;
float x1 = (float)(viewX1 * scaleX + offsetX); float y1 = (float)(viewY1 * scaleY + offsetY);
....
graphics.DeviceGraphics.DrawImage(drawBitmap , new Rectangle((int)x1 , (int)y2 , drawBitmap.Width , drawBitmap.Height) , new Rectangle(0, 0, drawBitmap.Width, drawBitmap.Height) , GraphicsUnit.Pixel); Point[] points = new Point[] { new Point((int)x1, (int)y2) };
graphics.DeviceGraphics.Transform.TransformPoints(points); m_SelectionOrigin = points[0];
|