ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Question on How to get X/Y position when graph is created
Posted by Mike Cotrone on Jul-27-2016 22:01
Peter,

Sorry for the newbie questions still, but when I draw my graph I am trying to record each plotted x/y coordinate so I can stuff them into a class tracker object. How can I grab this info after I use the  Layer.addDataSet()?


  // SETUP GRAPH PLOT AREA
  graph = New CDXYChartMBS(Me.Width*f, Me.Height*f, &hffffff, -1, 0)
  Call graph.setPlotArea(49*f, 40*f, (Me.Width-69)*f, (Me.Height-100)*f, &hffffff, graph.kTransparent,  &hffffff, &hcccccc, graph.kTransparent)
  Call graph.SetAntiAlias(True, 1)

  // DRAW TOP LINE
  call graph.addLine(50*f, 40*f, (Me.Width-20)*f, 40*f, &hcccccc, 1)
  // DRAW BOTTOM LINE
  call graph.addLine(50*f, (Me.Height-60)*f, (Me.Width-20)*f, (Me.Height-60)*f, &hcccccc, 1)

  // SETUP X-AXIS
  Call graph.xAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
  graph.xAxis.setAutoScale(.2, .2)
  Call graph.xAxis.SetColors(graph.kTransparent)
  Call graph.xAxis.setMargin(0, 5)
  Call graph.xAxis.setIndent(False)
  Call graph.xAxis.setRounding(True, True)
  Call graph.xAxis.setMinTickInc(1)
  Call graph.xAxis.setLabelFormat("{={value}+1}")
  Call graph.xAxis.setOffset(-1,4)

  // SETUP Y-AXIS LEFT
  Call graph.yAxis.SetColors(-1)
  graph.yAxis.setAutoScale(.2, .2, 0)
  Call graph.yAxis.setIndent(False)
  Call graph.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
  Call graph.yAxis.setOffset(-4,0)

  // WRITE DATA TO GRAPH
  for i = 0 to udpSessionGraphDataClassArray.Ubound

    // ONLY DRAW SELECTED LAYERS
    If udpSessionGraphDataClassArray(i).contextualMenuChecked = False Then Continue

    // Y-AXIS LEFT
    Dim throughputDataArray() as Double
    throughputDataArray() = udpSessionGraphDataClassArray(i).jitterMS()


    Dim thisFillColor as Integer = udpSessionGraphDataClassArray(i).colorFill
    Dim thisBorderColor as Integer= udpSessionGraphDataClassArray(i).colorBorder

    Dim leftYLayer As CDAreaLayerMBS
    leftYLayer = graph.addAreaLayer
    leftYLayer.addDataSet(throughputDataArray).setDataColor(thisFillColor, thisBorderColor)
    leftYLayer.setLineWidth(1)

next i


Thanks!

  Re: Question on How to get X/Y position when graph is created
Posted by Peter Kwan on Jul-28-2016 01:34
Hi Mike,

For the plotted x/y coordinate, I assume you are referring to the X/Y pixel coordinates (as opposed to the x/y data values).

To determine the pixel coordinates, it is necessary to determine the axis scale. To determine the axis scale, it is necessary to consider all the data in the chart. That means to obtain the pixel coordinates, your code needs to first add all the data to the chart. It can then call XYChart.layoutAxes or XYChart.layout, so that ChartDirector knows that all data have been added and can determine the axis scale. Your code can also simply displays the chart (rendering the chart implies all data have already been added). After that, your code can use XYChart.getXCoor and XYChart.getYCoor to obtain the pixel coordinates of the data points.

Hope this can help.

Regards
Peter Kwan

  Re: Question on How to get X/Y position when graph is created
Posted by Mike Cotrone on Jul-28-2016 04:03
Thank you very much Peter.