Author |
Topic  |
|
swalkup
9 Posts |
Posted - 22 Jan 2009 : 11:55:25
|
HI I am trying to create a two axis chart. the first and primary chart would be auto scaled both X and Y. (this is a X/Y linear plot) The second axis would be the same data but exploded (not sure if I am doing this correctly) time x 10 (I need to see the start and stop of the plot maganifed) and would be and multiable of the first chart so the same grid would be used. I can not get the scaling to track from one plot to the other.
this is still part of the booster test demo you sent me. Thanks Sam
Sam Walkup |
|
quinncurtis
1164 Posts |
Posted - 22 Jan 2009 : 12:41:01
|
What you describe should not be hard to do. The scales and axes do what you tell them to do.
So describe in detail exactly what you mean by "can not get the scaling to track from one plot to the other". I assume this means that the x10 graph does not display correctly. Exactly what is wrong with the display ? Exactly how are you setting the scale and axes of the x10 graph based on range of the auto-scaled initial graph ?
|
 |
|
swalkup
9 Posts |
Posted - 22 Jan 2009 : 13:00:15
|
If the main axis is 0,500,1000,5000 i expect the exploded view to be 0,50,100,500 ect here is the code excuse the mess
Public Sub InitializeChart(ByVal zip As Integer)
Dim theFont As Font Dim numPoints As Integer = 5000 Dim numPoints2 As Integer = 5000 Dim x1(numPoints - 1) As Double Dim y1(numPoints - 1) As Double Dim y2(numPoints - 1) As Double
Dim xs1(numPoints2) As Double Dim ys1(numPoints2) As Double
'ReDim Manual.inputForce(numPoints - 1) 'ReDim Manual.outputForce(numPoints - 1)
Dim i As Integer
For i = 0 To numPoints - 1 x1(i) = Manual.HBMinputForce(i) y1(i) = Manual.HBMoutputForce(i) 'xs1(i) = Manual.inputForce(i) * 10 'ys1(i) = Manual.outputForce(i) * 10 Next
For i = 0 To numPoints 'x1(i) = Manual.inputForce(i) 'y1(i) = Manual.outputForce(i) xs1(i) = Manual.HBMinputForce(i)
If Manual.CheckBox1.Checked = True Then ys1(i) = Manual.HBMVacuum(i) Else
ys1(i) = Manual.HBMoutputForce(i) End If
Next
attrib1 = New ChartAttribute(Color.Blue, 2, DashStyle.Solid) attrib2 = New ChartAttribute(Color.Red, 1, DashStyle.Solid) attrib3 = New ChartAttribute(Color.Green, 2, DashStyle.Solid)
theFont = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
Dataset1 = New SimpleDataset("First", x1, y1) Dataset2 = New SimpleDataset("Second", xs1, ys1)
pTransform1 = New CartesianCoordinates(ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE) pTransform2 = New CartesianCoordinates(ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE)
'pTransform1.SetGraphBorderDiagonal(0.19, 0.1, 0.7, 0.9) ' pTransform2.SetGraphBorderDiagonal(0.19, 0.1, 0.7, 0.9)
pTransform1.SetGraphBorderDiagonal(0.1, 0.15, 0.45, 0.9) pTransform2.SetGraphBorderDiagonal(0.1, 0.15, 0.45, 0.9) 'full overlap ' small pTransform2.SetGraphBorderDiagonal(0.3, 0.4, 0.45, 0.9)
' pTransform2.SetGraphBorderDiagonal(0.55, 0.15, 0.95, 0.9) 'full side
pTransform1.AutoScale(Dataset1, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR) pTransform2.AutoScale(Dataset2, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR)
'Select if Vacuum or Force Force Expoded view mode If Manual.CheckBox1.Checked = True Then 'Vacuum Mode Else 'Exploded View Mode
pTransform2.SetScaleStopX(xs1.Length / 10) pTransform2.SetScaleStopY(ys1.Length / 10) End If
pTransform3 = New CartesianCoordinates(ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE) ' pTransform3.SetGraphBorderDiagonal(0.825, 0.1, 0.95, 0.8) pTransform3.SetGraphBorderDiagonal(0.19, 0.1, 0.45, 0.8)
Dim background As New Background(pTransform1, ChartObj.PLOT_BACKGROUND, Color.White) chartVu.AddChartObject(background) Dim background2 As New Background(pTransform2, ChartObj.PLOT_BACKGROUND, Color.SteelBlue) chartVu.AddChartObject(background2)
'------------------------------------------------------------------------------------ Dim xAxis As New LinearAxis(pTransform1, ChartObj.X_AXIS) xAxis.CalcAutoAxis() chartVu.AddChartObject(xAxis)
Dim yAxis As New LinearAxis(pTransform1, ChartObj.Y_AXIS) yAxis.CalcAutoAxis() yAxis.SetChartObjAttributes(attrib1) ' axis color matches line color chartVu.AddChartObject(yAxis) '-------------------------------------------------------------------------------
Dim xAxis1 As New LinearAxis(pTransform1, ChartObj.X_AXIS) xAxis1.CalcAutoAxis() chartVu.AddChartObject(xAxis1)
Dim yAxis1 As New LinearAxis(pTransform1, ChartObj.Y_AXIS) yAxis1.CalcAutoAxis() yAxis1.SetChartObjAttributes(attrib2) ' axis color matches line color chartVu.AddChartObject(yAxis1) '-----------------------------------------------------------------------------------
Dim xAxisLab As New NumericAxisLabels(xAxis) xAxisLab.SetTextFont(theFont) chartVu.AddChartObject(xAxisLab)
Dim yAxisLab As New NumericAxisLabels(yAxis) yAxisLab.SetTextFont(theFont) chartVu.AddChartObject(yAxisLab) '---------------------------------------------------------------------------------
Dim xAxisLab1 As New NumericAxisLabels(xAxis1) xAxisLab.SetTextFont(theFont) chartVu.AddChartObject(xAxisLab1)
Dim yAxisLab1 As New NumericAxisLabels(yAxis1) yAxisLab.SetTextFont(theFont) chartVu.AddChartObject(yAxisLab1)
'---------------------------------------------------------------------------------------
Dim titleFont As New Font("Microsoft Sans Serif", 10, FontStyle.Bold) Dim yaxistitle As New AxisTitle(yAxis, titleFont, "Force Out ") chartVu.AddChartObject(yaxistitle)
Dim yaxistitle1 As New AxisTitle(yAxis1, titleFont, "Force Out ") chartVu.AddChartObject(yaxistitle1)
Dim xaxistitle As New AxisTitle(xAxis, titleFont, "Force In") chartVu.AddChartObject(xaxistitle)
' Setup Grids X
Dim xgrid As New Grid(xAxis, yAxis, ChartObj.X_AXIS, ChartObj.GRID_ALL) ' Dim xgrid As New Grid(xAxis, yAxis, ChartObj.X_AXIS, ChartObj.GRID_MAJOR) chartVu.AddChartObject(xgrid) ' Setup Grids y Dim ygrid As New Grid(xAxis, yAxis, ChartObj.Y_AXIS, ChartObj.GRID_ALL) ' Dim ygrid As New Grid(xAxis, yAxis, ChartObj.Y_AXIS, ChartObj.GRID_MAJOR) chartVu.AddChartObject(ygrid)
' Setup Grids X1
Dim xgrid1 As New Grid(xAxis1, yAxis1, ChartObj.X_AXIS, ChartObj.GRID_ALL) 'Dim xgrid As New Grid(xAxis, yAxis, ChartObj.X_AXIS, ChartObj.GRID_MAJOR) xgrid1.SetChartObjAttributes(attrib2) ' axis color matches line color
chartVu.AddChartObject(xgrid1) ' Setup Grids y1 Dim ygrid1 As New Grid(xAxis1, yAxis1, ChartObj.Y_AXIS, ChartObj.GRID_ALL) 'Dim ygrid As New Grid(xAxis, yAxis, ChartObj.Y_AXIS, ChartObj.GRID_MAJOR) ygrid1.SetChartObjAttributes(attrib2) ' axis color matches line color chartVu.AddChartObject(ygrid1)
' Setup Scatter Plot
'pTransform1.SetScaleStopY(xs1.Length / 10) Dim thePlot1 As New SimpleLinePlot(pTransform1, Dataset1, attrib1) ' Turn Off/on Second line Green line chartVu.AddChartObject(thePlot1)
' Dim attrib1 As New ChartAttribute(Color.Red, 2, DashStyle.Solid) ' attrib1.SetFillColor(Color.Red) ' attrib1.SetFillFlag(False) ' attrib1.SetSymbolSize(10) 'Dim thePlot2 As New SimpleScatterPlot(pTransform1, Dataset2, ChartObj.DOWNTRIANGLE, attrib1) Dim thePlot2 As New SimpleLinePlot(pTransform2, Dataset2, attrib2) 'Dim thePlot2 As New SimpleLinePlot(pTransform1, Dataset1, attrib1)
'Turn On Scatter Plot chartVu.AddChartObject(thePlot2)
'Setup Plot Line Green
' Dim attrib2 As New ChartAttribute(Color.Green, 1, DashStyle.Solid) 'pTransform1.SetScaleStopX(xs1.Length / 10)
' Dim attrib3 As New ChartAttribute(Color.Red, 2, DashStyle.Solid) 'yAxis = New LinearAxis(pTransform2, ChartObj.Y_AXIS) 'yAxis.SetAxisIntercept(xAxis.GetAxisMax()) 'yAxis.SetAxisTickDir(ChartObj.AXIS_MAX) 'yAxis.SetChartObjAttributes(attrib3) ' axis color matches line color 'chartVu.AddChartObject(yAxis)
' Setup Legends
Dim legendFont As New Font("Microsoft Sans Serif", 10, FontStyle.Bold) Dim legendAttributes As New ChartAttribute(Color.Gray, 1, DashStyle.Solid) legendAttributes.SetFillFlag(False) legendAttributes.SetLineFlag(False)
'Dim legend As New StandardLegend(0.1, 0.875, 0.8, 0.075, legendAttributes, StandardLegend.HORIZ_DIR) ''7777777777777777777777777777777777777
'Legend.AddLegendItem("Measured", ChartObj.CROSS, thePlot1, legendFont) 'Legend.AddLegendItem("Predicted", ChartObj.LINE, thePlot1, legendFont) 'Legend.SetLegendItemUniformTextColor(Color.Black) 'chartVu.AddChartObject(Legend)
Dim theTitleFont As New Font("Microsoft Sans Serif", 10, FontStyle.Bold) Dim mainTitle As New ChartTitle(pTransform1, theTitleFont, "Force Force Curve ") mainTitle.SetTitleType(ChartObj.CHART_HEADER) mainTitle.SetTitlePosition(ChartObj.CHART_HEADER) 'mainTitle.SetTitleType(ChartObj.CENTER_GRAPH) 'mainTitle.SetTitlePosition(ChartObj.CENTER_GRAPH)
chartVu.AddChartObject(mainTitle)
Dim theTitleFont2 As New Font("Microsoft Sans Serif", 10, FontStyle.Bold) Dim mainTitle2 As New ChartTitle(pTransform1, theTitleFont2, "First Booster Line ") mainTitle2.SetTitleType(ChartObj.CHART_SUBHEAD) mainTitle2.SetTitlePosition(ChartObj.ABOVE_CENTERED_PLOTAREA)
chartVu.AddChartObject(mainTitle2)
Dim theFooterFont As New Font("Microsoft Sans Serif", 10, FontStyle.Bold) Dim footer As New ChartTitle(pTransform1, theFooterFont, "Booster Test Curve") footer.SetTitleType(ChartObj.CHART_FOOTER) footer.SetTitlePosition(ChartObj.CENTER_GRAPH) footer.SetTitleOffset(8) chartVu.AddChartObject(footer) chartVu.SetResizeMode(ChartObj.AUTO_RESIZE_OBJECTS)
Dim infoFont As New Font("Microsoft Sands Serif", 12, FontStyle.Bold)
'Dim xinfoFontTemplate As New NumericLabel(ChartObj.DECIMALFORMAT, 0) 'Dim yinfoFontTemplate As New NumericLabel(ChartObj.DECIMALFORMAT, 1) 'Dim infoFontTemplate As New ChartText(pTransform1, infoFont, "SAMMY", 10, 10, ChartObj.PHYS_POS) 'infoFontTemplate.SetTextBgColor(Color.FromArgb(255, 255, 204)) 'infoFontTemplate.SetTextBgMode(True)
Dim infoFontTemplate As New ChartText(pTransform3, infoFont, "SAMMY", 0.05, 0.2, ChartObj.NORM_PLOT_POS) chartVu.AddChartObject(infoFontTemplate)
Dim toolTipFont As New Font("Microsoft Sans Serif", 10, FontStyle.Regular) Dim datatooltip As New DataToolTip(chartVu) Dim xValueTemplate As New NumericLabel(ChartObj.DECIMALFORMAT, 0) Dim yValueTemplate As New NumericLabel(ChartObj.DECIMALFORMAT, 1) Dim textTemplate As New ChartText(toolTipFont, "") textTemplate.SetTextBgColor(Color.FromArgb(255, 255, 204)) textTemplate.SetTextBgMode(True)
Dim transformArray As CartesianCoordinates() = {pTransform1, pTransform2} ', pTransform3, pTransform4, pTransform5} Dim zoomObj As New ZoomWithStack(chartVu, transformArray, 5, True) zoomObj.SetButtonMask(System.Windows.Forms.MouseButtons.Left) zoomObj.SetZoomYEnable(True) zoomObj.SetZoomXEnable(True) zoomObj.SetZoomXRoundMode(ChartObj.AUTOAXES_FAR) zoomObj.SetZoomYRoundMode(ChartObj.AUTOAXES_FAR) zoomObj.SetEnable(True) zoomObj.SetZoomStackEnable(True)
chartVu.SetCurrentMouseListener(zoomObj)
Dim toolTipSymbol As New ChartSymbol(Nothing, ChartObj.SQUARE, New ChartAttribute(Color.Green)) toolTipSymbol.SetSymbolSize(20.0) ' datatooltip.SetButtonMask(System.Windows.Forms.MouseButtons.None) datatooltip.SetTextTemplate(textTemplate) datatooltip.SetXValueTemplate(xValueTemplate) datatooltip.SetYValueTemplate(yValueTemplate) datatooltip.SetDataToolTipFormat(ChartObj.DATA_TOOLTIP_XY_ONELINE) datatooltip.SetToolTipSymbol(toolTipSymbol) datatooltip.SetButtonMask(MouseButtons.Middle)
datatooltip.SetEnable(True)
Dim multimouselistener As MultiMouseListener = New MultiMouseListener(datatooltip) multimouselistener.AddMouseListener(zoomObj)
chartVu.SetCurrentMouseListener(multimouselistener)
' chartVu.SetCurrentMouseListener(datatooltip)
' Form1.TextBox1.Text = System.w ' Form1.TextBox1.Text = Me.DisplayRectangle.ToString ' Height = 500 ' Form1.TextBox1.Text = DisplayRectangle.Height ' Form1.TextBox1.Text = Height
' Form1.TextBox2.Text = Width End Sub 'InitializeChart
Sam Walkup |
 |
|
quinncurtis
1164 Posts |
Posted - 22 Jan 2009 : 13:16:39
|
Please describe in minute detail exactly what is wrong with the resulting graph. If you have your own web site and can upload an image to it, you can post an image in a reply, using the image button above and inserting the url to the image between the image tags.
 |
 |
|
swalkup
9 Posts |
Posted - 22 Jan 2009 : 13:28:20
|
I have looked at this example until I am BLUE in the face!!! I need 1: The grid to be a full X & Y grid. 2: The first plot to be auto scaled. 3: the second plot to be the same data as in the first plot but exploded by 10. ie. if first grid line is 100 on the first plot the second plot would be 10.
Is this the proper way to explode it??
pTransform2.SetScaleStopX(xs1.Length / 10) pTransform2.SetScaleStopY(ys1.Length / 10)
sam
Sam Walkup |
 |
|
quinncurtis
1164 Posts |
Posted - 22 Jan 2009 : 13:32:36
|
In our example, the x-values are the same as the index of the array, so something like this may work.
pTransform2.SetScaleStopX(xs1.Length / 10) pTransform2.SetScaleStopY(ys1.Length / 10)
In your example that is NOT THE CASE. Your x-values are completely different than the array index.
Shouldn't the stop values for the x10 transform (pTransform2) simply be 1/10 the stop values of the pTransform1.
pTransform2.SetScaleStopX(pTransform1.ScaleStopX/ 10) pTransform2.SetScaleStopY(pTransform1.ScaleStopY/ 10)
|
 |
|
swalkup
9 Posts |
Posted - 22 Jan 2009 : 13:44:10
|
thanks I will try it in a bit! Sam
Sam Walkup |
 |
|
swalkup
9 Posts |
Posted - 22 Jan 2009 : 17:30:00
|
Thank You Thank You!!!!!
Now one more small problem. I am autoscale. I am setting the Axis label for the second plot with the yAxis2.SetAxisIntercept(-18.9) Command. When the data changes in the plot the axis lable changes positions with it. Why? How can I fix it?? Looked at the example all of you data stays the same.
Sam
Sam Walkup |
 |
|
quinncurtis
1164 Posts |
Posted - 22 Jan 2009 : 23:18:59
|
You are picking code out our example without understanding why the specific value in the example is being used.
You must set the axis intercept in the same units as the scale of the of the x-scale used in your second coordinate system. That has nothing to do with the -18.9 value, which only applies to the x-scale of our example, where the range of x-scale is always from 0 to 100.
If the range of the x-scale for the second graph is from 0 to R, then you would need to offset your x-axis to the left about 20%, or xintercept = -(0.2 * R). If the start of the scale is not 0, then you would use xintercept = xmin -(0.2 * R), where R is the range of the scale (xmax - xmin). So you would call
yAxis2.SetAxisIntercept(xintercept)
If you haven't done so, make sure and read the FAQ #2 for the product, in the manual, and at: http://www.quinn-curtis.com/QCChart2DFAQs.htm |
 |
|
|
Topic  |
|
|
|