|
xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-21-2016 10:31 |
|
Hello all,
I have a question regarding what value to pass to xAxis.Addmark when I am using AutoScale?
Here is my Setup Code for both Axis:
// SETUP X-AXIS LEFT
Call c.yAxis.SetColors(-1)
Call c.yAxis.setAutoScale(30, 30, 0)
Call c.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.yAxis.setOffset(-4,0)
// SETUP Y-AXIS LEFT
Call c.yAxis.SetColors(-1)
Call c.yAxis.setAutoScale(30, 30, 0)
Call c.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.yAxis.setOffset(-4,0)
Thank you
Mike |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Peter Kwan on Jul-21-2016 11:22 |
|
Hi Mike,
Sorry, I am not too sure what you mean. Also, in your message, the code for x-axis is configuring the y-axis, not the x-axis.
The setAutoScale call in your code seems incorrect, as the first two parameters should be between 0 to 1, and their sum should not exceed 1.
For addMark, you just need to add the mark at the position you want. For example, if you want to add a mark at x=10, then you can just add the mark with 10 as the value. (A mark on a horizontal axis is a vertical line at the horizontal position you specified. The line will be from the bottom of the plot area to the top of the plot area.)
If the above is not what you need, would you mind to clarify where you would like the mark line to be?
Regards
Peter Kwan |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-21-2016 11:27 |
|
Thank you Peter for the direction. I do need this on the yAxis and my original mistake is that I just need to rotate the line from horizontal to vertical on the yAxis values.
Thank you for the autoscale corrections! |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-21-2016 11:27 |
|
Sorry copy/paste issue above
all c.xAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.xAxis.setAutoScale(30, 30)
Call c.xAxis.SetColors(c.kTransparent)
Call c.xAxis.setOffset(0, 4)
Call c.xAxis.setRounding(True, True)
Call c.xAxis.setMinTickInc(1)
// SETUP Y-AXIS LEFT
Call c.yAxis.SetColors(-1)
Call c.yAxis.setAutoScale(30, 30, 0)
Call c.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.yAxis.setOffset(-4,0) |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-21-2016 11:47 |
|
I guess my question (now) Is how do I glean the xPOS from the xAxis when I am using autoscale since I don't have a dataArray() to get this info from? Hopefully this makes sense.
Thanks |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-21-2016 12:02 |
|
I believe this is what I need to get the autoscaled xAxis values.
THanks! |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Peter Kwan on Jul-21-2016 12:59 |
|
Hi Mike,
I am still not so sure what is getting "xPOS" from the x-axis. Does it mean you want to get the x-axis scale (the min and max values of the x-axis), or the x-axis tick positions, or you would like to get the x pixel coordinate from a x data value? (These kind of things do not seem to be related to addMark.)
All axes in ChartDirector will be auto-scaled unless your code sets the scale directly (such as using Axis.setLinearScale, Axis.setLogScale, Axis.setDateScale, Axis.setLabels, etc). If the axis is auto-scaled, the scale will depend on the data that are using the axis, and also the auto-scale configuration (such as the tick density, margins, etc). Your code sets the auto-scale configuration. I assume there is no other code that sets the axis scale directly, otherwise the axis will not be auto-scaled at all and the auto-scale configuration will not be used.
So your code must already have some data, and have already passed those values to ChartDirector, otherwise ChartDirector cannot auto-scale the x-axis to accommodate those values. If you are adding layer, but does not provide x-coordinates (no Layer.setXData), then the x-coordinates of the data points are just the array index 0, 1, 2, 3, ....
If you need to know the result of auto-scaling (the min and max values of the x-axis), after adding all the data to ChartDirector (so that it can auto-scale the axis based on the data values), please use "Call c.layoutAxes()". This tells ChartDirector that all data have already been entered and the axis scale can be determined. After that, you can use Axis.getMinValue and Axis.getMaxValue to get the axis scale, and you can use XYChart.getXCoor to translate an x data value to an x pixel coordinate position.
Hope this can help.
Regards
Peter Kwan |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-25-2016 08:53 |
|
Peter yes this helps me alot actually thank you.
Your response with if we don't have x-axis data chartdirector uses an array of 0, 1, 2 etc. Do you know of a way I can modify that to begin at 1 base vs. 0 base?
Thanks again
Mike |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-25-2016 10:32 |
|
Also Peter,
When i am using my own X-Axis label array I lose the auto-scaling which is understood. Do you have any ideas for this?
Thanks |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-25-2016 21:15 |
|
This is a screen shot of my setLabels having too many. I have tried adjusting w/ xaxis.setLabelStep but I couldn't see a difference. I know I am missing something. Thanks
|
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Peter Kwan on Jul-26-2016 01:58 |
|
Hi Mike,
For your case, if you want the x-axis to start from 1 for the first data point, the best method is to use the x coordinate of 1 for the first data point. If you do not provide any x-coordinates, ChartDirector can only assume the coordinates using an arbitrary rule, which may not be what you prefer. So the best way is always to provide the x-coordinates you want to use for the data points (using Layer.setXData).
If you want to display the x-coordinates to be 1 larger than its actual value (that means displaying 0 as 1, 1 as 2, 2 as 3 and so on), you can use:
Call c.xAxis().setLabelFormat("{={value}+1}")
If you prefer to provide your own labels, which can be any text you like, you can use Axis.setLabels. You can step the labels by using Axis.setLabelStep. Without seeing your complete code, it is hard for me to determine what the labels do not step. Some possible reasons are that the setLabelStep may have been called with incorrect parameters, or you have other lines of code that also affects the scale. (In your code, it seems there are many lines of code that configures the x-axis scale.) If you need further help, is it possible to inform me of the complete charting part of the code? If you cannot post the entire code in the forum, you may email the charting part of the code to me at pkwan@advsofteng.net.
Regards
Peter Kwan |
Re: xAxis.Addmark Question w/ AutoScale |
Posted by Mike Cotrone on Jul-26-2016 01:59 |
|
Thanks Peter perfect!!! That should be what i need. |
|