|
Complicated skew chart |
Posted by Mark Fenbers on Jun-02-2014 00:48 |
|
I want to be able to replicate the attached chart in ChartDirector. It is essentially a 5-
dimensional chart.
The left side shows the only "normal" axis, the Y-axis labeled as Pressure is a logarithmic
scale with horizontal tick marks across the entire graph.
Another axis is Temperature, but is not really the "X" axis because the tick marks are
"skewed" at about a 45? angle and is shaded green every 10?C. But they are straight-line
tick marks, at least.
Before I go further, can ChartDirector create this much of the graph showing a skewed X-
axis, and plot data according to the skew? In the uploaded example, the solid and bold red
and blue lines are the only dynamic data that is plotted. (The remaining lines are part of
the baseline graph.)
Two of the three other lines are curved based on mathematic formulas. Can ChartDirector
plot dynamic data against a curved axis?
|
Re: Complicated skew chart |
Posted by Peter Kwan on Jun-03-2014 03:55 |
|
Hi Mark,
For the exact graph, you probably have to explicitly specify the scale. If you let
ChartDirector auto-scale the axis, it probably will not choose the y-axis scale of 100 to
1000, given that your data are from y = 750 to 980. ChartDirector will not choose the
same y-axis labels as well.
You may use Axis.setLogScale2 to set up a y-axis log scale without labels (using an
empty labels array), then use Axis.addLabel to add the labels you need. In this way, you
can replicate the exact same y-axis labelling. You can use Axis.setLinearScale to set up
the x-axis.
The way the x-axis scale is skewed means that as the pressure decreases, the
temperature also decreases. The reduction in temperature must be proportional to the
logarithmic reduction in pressure, which means:
change_in_temp = constant * log(pressure / pressure_at_bottom)
By checking on a few points, you should be able to easily determine what is the
"constant".
A skewed grid lines at x=-40 can be plotted by as a trend line using
XYChart.addTrendLayer. You just need to two points to plot a trend line. The two points
do not need to be at the border of the plot area. ChartDirector will extend the trend line
if necessary to the border of the plot area. The two points to use can be:
(-40, pressure_at_bottom_of_chart)
(-40 - constant * log(500 / pressure_at_bottom), 500)
You can use the same method to plot x=-30, -20, etc... Then you can use InterLineLayer
(see XYChart.addInterLineLayer) to fill the region between some of the trend lines to
create the skewed green zones.
Finally, to plot the data points, you have to adjust the x-coordinates to put it in the
correct position on the skewed scale. If your original data value is (x, y), you need to
change the x value to x - constant * log(y / pressure_at_bottom).
Hope this can help.
Regards
Peter Kwan |
|