|
Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by jouyang on Apr-15-2015 17:55 |
|
I want to draw something like color block chart, refer to color_block.png.
But if the value is not monotonic, say (1, 2, 10, 5, 7, 8, ), it always use do interpolation
automatically, which make the chart can't work as I expected, like color blocks.
Any solution to it ?
Thanks in advance!
|
Re: Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by Peter Kwan on Apr-16-2015 09:51 |
|
Hi jouyang,
Are you trying to draw rectangular color blocks on the chart? If this is the case, there are
many methods. For example, you can use a scatter layer or a bubble chart to draw
rectangular symbols. You can use different layers for symbols of different colors. Another
method is to use DrawArea to directly draw the rectangles.
I have attached an example that uses DrawArea to draw rectangles for your reference.
For the contour layer, suppose you have three points at (0, 0), (1, 1) and (0.583, 0.88),
and the z-value are 3, 7 and 10. To plot a contour layer, ChartDirector needs to fill the
entire surface, so ChartDirector needs to know the z-value at all intermediate points (such
as at (0.385, 0.683)), so 2D interpolation is used. If the coloring method is simply to fill a
rectangular region around the data point based on that value of the data point, then using
a scatter or bubble layer or using the DrawArea is more suitable.
If the above is not what you need, is it possible to provide an example (may be a link to an
image or attach an image) that help me understand what you need?
Regards
Peter Kwan
|
Re: Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by jouyang on Apr-16-2015 14:15 |
|
Hi Peter,
Thanks very much for your reply!
Yes, I've already used scatter layer to draw rectangular color blocks. But there is a
requirement to show ColorAxis aside.
But I searched the manual and found it could be used only with ContourLayer.
Then I tried to create one dummy ContourLayer with empty x/y/z data and add ColorAxis
for it.
Everything works well util I find that I can't use getColor function to get the specific color
for my chart.
The manual says :
"Note: You must call XYChart.layoutAxes, BaseChart.layout or XYChart.packPlotArea first
before calling this method. ChartDirector needs to perform auto-scaling and layout the axis
before it can compute the color.
"
I try call layoutAxes before using getColor, still getColor doesn't work as expected.
That's why I turn to try ContourLayer for help.
Do you have any suggestion?
Thanks in advance.
Regards,
Jouyang |
Re: Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by jouyang on Apr-16-2015 14:17 |
|
In short, what I want is to draw rectangle color blocks with ColorAxis aside.
Regards,
Ouyang |
Re: Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by Peter Kwan on Apr-17-2015 01:13 |
|
Hi jouyang,
I have attached an example which uses ColorAxis for your reference.
From my testing, the ColorAxis.getColor does not seem to work after XYChart.layoutAxes,
but it does work after BaseChart.layout, which is what the attached code is using.
Hope this can help.
Regards
Peter Kwan
|
Re: Is it possible to make ContourLayer don't automatically do interpolation ? |
Posted by jouyang on Apr-17-2015 11:05 |
|
Hi Perter,
Thanks very much for your timely reply !
Your suggestion is very helpful and useful for me!
In fact, I've tried layout. The getColor function seems return right color, but the output
chart is not something I want. And I used ScatterLayer to draw rectangle color blocks.
In your code, you use DrawArea to draw rectangle color blocks. That inspire me, cause I
remember in the manual it says : DrawArea should be used after makeChart, or else the
custom drawing will be at the background of the chart.
It works for me.
Thanks,
JOuyang |
|