T O P I C R E V I E W |
sajimenez |
Posted - 01 Feb 2011 : 02:53:39 Hi, I have a chart with 2 series, where each serie uses an "Y" axis, and both use the same "X" axis. One serie can receive less points than the other one, I have the problem that the serie with Y axis that uses the same coordinates that the X axis, stays static with the X axis when receives all points, while the second serie keeps growing in X but the X axis doesn't grow with it. I would like the X axis grows with both series.
How can I do this?
Thanks a lot.
sajimenez |
7 L A T E S T R E P L I E S (Newest First) |
sajimenez |
Posted - 04 Feb 2011 : 18:24:38 Thank you for your reply, I will try your suggestion and I will let you know the results.
Thanks a lot.
sajimenez |
quinncurtis |
Posted - 02 Feb 2011 : 11:41:44 The y-axes will probably shift if you just do the things in the previous post. Add a couple of calls to reset the y-axes intercepts.
// Need to call these manually, because they are no longer part of the UpdateDraw queue. scrollFrame1.RescaleFrame(); scrollFrame2.RescaleFrame();
// Get the min and max x-scale values of the union of both coordinate systems double minx = Math.Min(scrollFrame1.ChartObjScale.ScaleMinX, scrollFrame2.ChartObjScale.ScaleMinX); double maxx = Math.Max(scrollFrame1.ChartObjScale.ScaleMaxX, scrollFrame2.ChartObjScale.ScaleMaxX);
// Set the min and max x-scale value of both coordinate systems to match scrollFrame1.ChartObjScale.SetScaleX(minx, maxx); scrollFrame2.ChartObjScale.SetScaleX(minx, maxx);
// Make yAxis1 and yAxis2 global to the class to you can access them here yAxis1.AxisIntercept = minx; yAxis2.AxisIntercept = maxx;
// Redraw everything this.UpdateDraw(); |
quinncurtis |
Posted - 02 Feb 2011 : 10:21:26 Here is something that may work, and it support the auto-scaling of the y-scales in both coordinate systems.
1. Undo adding both RTProcessVar objects to both RTScrollFrames.
2. Do NOT add the RTScrollFrames you create to the ChartView. The AddChartObject lines are commented out below. This removes the RTScrollFrame objects from the ChartView drawing queue.
scrollFrame1 = new RTScrollFrame(this, stockOpen1, pTransform1, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL); scrollFrame1.ScrollScaleModeY = ChartObj.RT_AUTOSCALE_Y_MINMAX;
// chartVu.AddChartObject(scrollFrame1);
scrollFrame2 = new RTScrollFrame(this, NASDAQChannel, pTransform2, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL); scrollFrame2.ScrollScaleModeY = ChartObj.RT_AUTOSCALE_Y_MINMAX; // chartVu.AddChartObject(scrollFrame2);
3. Now, you must call each RTScrollFrame update routine manually in the place you call UpdateDraw, before that call. Then you get the minimum and maximum x-values of both scaled coordinate systems, and scale both coordinate systems using those x-values. This makes the x-scale of both coordinate systems match. Then you call UpdateDraw, which will redraw everything with the new coordinate systems.
void UpdateMethod() { // Update RTProcessVar objects . . . // Need to call these manually, because they are no longer part of the UpdateDraw queue. scrollFrame1.RescaleFrame(); scrollFrame2.RescaleFrame();
// Get the min and max x-scale values of the union of both coordinate systems double minx = Math.Min(scrollFrame1.ChartObjScale.ScaleMinX, scrollFrame2.ChartObjScale.ScaleMinX); double maxx = Math.Max(scrollFrame1.ChartObjScale.ScaleMaxX, scrollFrame2.ChartObjScale.ScaleMaxX);
// Set the min and max x-scale value of both coordinate systems to match scrollFrame1.ChartObjScale.SetScaleX(minx, maxx); scrollFrame2.ChartObjScale.SetScaleX(minx, maxx);
// Redraw everything this.UpdateDraw(); }
|
sajimenez |
Posted - 01 Feb 2011 : 20:32:24 That sounds good, but I really need the auto-scaling for the y-range. I will try to solve this problem. Let me know if you have another workaround.
Thank you.
sajimenez |
quinncurtis |
Posted - 01 Feb 2011 : 17:51:43 It isn't really designed to do what you want, but if you can live with no auto-scaling for the y-range, perhaps it can be make to work.
Add both RTProcessVariables (pv1 and pv2 in the example below) to both RTScrollFrames (scrollFrame1 and scrollFrame2 in the example below).
scrollFrame1 = new RTScrollFrame(this, pv1, pTransform1, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL, ChartObj.RT_NO_AUTOSCALE_Y); // add second RTProcessVar to first scroll frame scrollFrame1.AddProcessVar(pv2);
scrollFrame2 = new RTScrollFrame(this, pv2, pTransform2, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL, ChartObj.RT_NO_AUTOSCALE_Y); // add first RTProcessVar to second scroll frame scrollFrame1.AddProcessVar(pv1);
This should keep the two coordinate systems (pTransform1 and pTransform2) in sync, because they will both process the same data. Let us know the results. |
sajimenez |
Posted - 01 Feb 2011 : 17:17:35 Thanks for your reply.
1. I have 2 RTScrollFrame, one for each coordinate system. I use the follow X axis:
this.xAxis = new LinearAxis(coordinates1, ChartObj.X_AXIS);
coordinates1 uses the follow RTScrollFrame:
scrollFrame = new RTScrollFrame(this.chart, coordinates1, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL, ChartObj.RT_NO_AUTOSCALE_Y);
2. I use coordinates1 for serie1, and coordinates2 for serie2. serie1 and serie2 are independent on time and points quantity.
For example, I set x axis interval 1 to 10, when serie1 receives 5 points, and serie2 receives 15 points, x axis keeps the interval 1 to 10 because serie1 only has 5 points, but serie2 shows the 15 points in the same interval (1 to 10), I want the x axis expands automatically to 15 points.
3. Y-axes re-scale correct. I dont have problem with this.
I modified your example RTStockDisplay to test this behavior, and the result is the same.
I added the variable to class RTStockDisplayUserControl1.cs: private int writeCounter = 0;
I modified the function InitializeData():
private void InitializeData() { stockChannelValue1 += 0.5 * (0.5 - ChartSupport.GetRandomDouble()); stockChannel1.SetCurrentValue(stockChannelValue1);
stockHighValue1 = stockChannelValue1 + 0.2 * (ChartSupport.GetRandomDouble()); stockHigh1.SetCurrentValue(stockHighValue1);
stockLowValue1 = stockChannelValue1 - 0.2 * (ChartSupport.GetRandomDouble()); stockLow1.SetCurrentValue(stockLowValue1);
stockOpenValue1 = stockLowValue1 + (stockHighValue1 - stockLowValue1) * (ChartSupport.GetRandomDouble()); stockOpen1.SetCurrentValue(stockOpenValue1);
stockCloseValue1 = stockLowValue1 + (stockHighValue1 - stockLowValue1) * (ChartSupport.GetRandomDouble()); stockClose1.SetCurrentValue(stockCloseValue1);
movingAverageStockValue = stockClose1.GetAverageHistoryValue(numPointsMovingAverage); movingAverageStock.SetCurrentValue(movingAverageStockValue);
this.writeCounter++;
if (this.writeCounter == 5) { NASDAQChannelValue += 10 * (0.5 - ChartSupport.GetRandomDouble()); ; NASDAQChannel.SetCurrentValue(NASDAQChannelValue); this.writeCounter = 0; }
intcStockValue += 0.5 * (0.5 - ChartSupport.GetRandomDouble()); if ((intcStockValue > 40) || (intcStockValue < 10)) intcStockValue = 20; intcStock.SetCurrentValue(intcStockValue);
txnStockValue += 0.5 * (0.5 - ChartSupport.GetRandomDouble()); if ((txnStockValue > 40) || (txnStockValue < 10)) txnStockValue = 20; txnStock.SetCurrentValue(txnStockValue);
cscoStockValue += 0.5 * (0.5 - ChartSupport.GetRandomDouble()); if ((cscoStockValue > 35) || (cscoStockValue < 10)) cscoStockValue = 20; cscoStock.SetCurrentValue(cscoStockValue);
amatStockValue += 0.5 * (0.5 - ChartSupport.GetRandomDouble()); if ((amatStockValue > 35) || (amatStockValue < 10)) amatStockValue = 20; amatStock.SetCurrentValue(amatStockValue); // Can't draw UpdateDraw in the middle of a zoom operation if (!zoomObj.ZoomObjActive) this.UpdateDraw(); updatecounter++; }
Each five calls to this function, the serie NASDAQChannel receive one point, while the other series keep scrolling, this serie stays static in x axis scale.
How can I keep the same x axis scale for both RTScrollFrame in my project or your example?
Thank you in advance.
sajimenez |
quinncurtis |
Posted - 01 Feb 2011 : 10:00:45 We can't quite interpret what you describe. Please answer these questions:
1. How are you re-scaling the x-axis now? Are you using a RTScrollFrame? Are you using two RTScrollFrame's, once for each coordinate system?
2. We do not understand this sentence "the series with Y axis that uses the same coordinates that the X axis, stays static with the X axis when receives all points." Does this mean that this x-, y-axis combination works correctly, or not correctly?
3. Do do you require that the y-axis also re-scale when scrolling. Or can you live with a fixed y-axis, but a scrolling x-axis.
|
|
|