Recent

Author Topic: ColorMapSeries in TChart  (Read 12316 times)

prema

  • New Member
  • *
  • Posts: 16
ColorMapSeries in TChart
« on: March 03, 2011, 09:39:53 am »
Hi all,

I found that there is a new series class TColorMapSeries what it seems what I looked for long time. It is nice and thanks for the guys who make TChart for this. But unfortunately I could get this series to work. Does someone tried it out and could provide me a simple demo project, please?

Thanks in advance

Premek

tomek

  • Jr. Member
  • **
  • Posts: 85
Re: ColorMapSeries in TChart
« Reply #1 on: March 03, 2011, 09:54:05 am »
Example for ColorMap is in demo\func.

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #2 on: March 03, 2011, 10:33:52 am »
Thanks a lot.  O:-) I tried all the demos except this one.  :-[

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: ColorMapSeries in TChart
« Reply #3 on: March 03, 2011, 12:05:33 pm »
I would like to hear any feedback on the color map series,
since I have implemented it on the request of a user and never heard back from him.

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #4 on: March 03, 2011, 12:30:59 pm »
OK. I will try to incorporate it to my project and I will post here my experience.  ;)

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #5 on: March 03, 2011, 02:49:26 pm »
So here are my first experiences:

- it work quite nice and smooth for calculating AZ with the function :)
- it is not suitable for my purpose  :(  ...
 
... because I have following problem. I have a several data sets, for example some profile linear data (XY doublets), for different external or calculation conditions. And I want now to plot these data in colour map where AX axis stay X axis as for the individual data sets. Y of the datasets become AZ in the colour map and let say number of individual conditions become AY.

I tried to use GetNearestPoint function in the OnCalculate event to get idea where AX are to put AZ as Y of my nearest point of the dataset but the drawing is very long due to the lot of points in the color map grid and with the bad output.

Conclusion: I idea is very good and it can be very useful but would be nice to have the opportunity to use several XY datasets as a data source.  So please let me now if you will continue with development of the ColorMapSeries.

Thanks

Premek
« Last Edit: March 03, 2011, 02:57:02 pm by prema »

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: ColorMapSeries in TChart
« Reply #6 on: March 03, 2011, 03:16:16 pm »
I would like to help you, but I do not quite understand your wish.
If the only problem is drawing speed, then some kind of cache might help.

Can you post an example code demonstrating your problem?

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #7 on: March 03, 2011, 03:30:59 pm »
Thanks for the help. Function GetNearestPoint doesn't work not only for speed but also in bad result. I try to describe what I would like to plot in the colour map.

I have let say 5 XY datasets of 10 members (for example 10 differents temperatures during the day in 5 different places around the world).

day time: 6     8    10    12   14    16   18    20   22    24
London: 15.5 16.8 25.4 23.2 24.2 25.6 20.5 18.9 15.8 15.0
New York: 20.2 21.8 22.0 23.5 24.8 25.0 24.8 23.2 22.1 20.1
Tokyo: 18.2 19.1 19.8 19.9 20.1 21.1 22.0 21.1 20.8 20.7
Berlin: 25.5 25.8 26.1 26.0 26.2 26.5 26.4 26.1 25.8 25.7
Madrid: 28.2 28.6 28.7 28.9 29.2 30.5 30.1 30.0 29.8 29.4

So I have 5 XY datasets like for London [6, 15.5][8, 16.8][10, 25.4]....

In the color map I would like to have X axis like 6 8 10 12 ...., Y axis like easy 1, 2, 3, 4, 5 (London, New York, ...) and the color level represent the temperature.

It start to be clear?

Premek


Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: ColorMapSeries in TChart
« Reply #8 on: March 03, 2011, 03:43:02 pm »
Why does not a simple

AZ := DataSet[Round(AY)].Point[Round(AX / 4)]

work?

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #9 on: March 04, 2011, 08:26:18 am »
It looks like easy but it doesn't work. I prepared example of the project. It loads the data what I mainly dealing with and print it to the LineSeries chart. What I would like to have with ColorMapSeries is shown on the ColorMap.png image included in the directory also.

Thanks again for your help and time

Premek

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: ColorMapSeries in TChart
« Reply #10 on: March 04, 2011, 12:13:36 pm »
The example is very useful -- now I understand what you are trying to accomplish.

There are a few problems with it:
1) Do you realize where the division by 4 comes from in my message?
It was to rescale X axis for your sample data, which had a step of 4.
Since the data in the project you have posted has an X step of 0.08,
this is the value you should divide by.
2) The picture you have provided has very detailed legend with contrasting
colors, while your project has only a short legend without much contrast.
3) Your data has very low Y resolution, which you might want to
counter with interpolation.
There are two kinds of interpolation: color-space and data-space.
Color-space interpolation is provided by ColorMap if you set Interpolate property.
Data-space interpolation is the responsibility of the user.
4) To get optimal quality/performance, StepX and StepY values should
approximately reflect the resolution of your axises.
5) Finally, setting DoubleBuffered property of the chart reduces flicker.

In the attached version of your project, I have corrected the above problems.
Note that cbInterpolate checkbox triggers both color and data interpolation,
but you might want to apply only one kind.
Note also that I used latest Lazarus SVN, which might have some incompatibilities
with your version.

prema

  • New Member
  • *
  • Posts: 16
Re: ColorMapSeries in TChart
« Reply #11 on: March 04, 2011, 01:09:08 pm »
 :D Very nice it works. Several coments:

add 1) OK I didn't understand what the StepX represent. Now is clear.
add 2) I working on it. This was just for the test. Your solution is also nice. But more contrast colours will be better for sure. Only question about the meaning of the second column in the lSource. First is the Y limit, second? and the third is colour.
add 3) OK using it makes better appearance. The data will not be better. All the time like this - it is neutron diffraction pattern. Question: it is possible after each zoom refreshing lSource in such way to reflect max and min of zoomed part?
add 4) OK
add 5) OK

Just one more question. x := Round((AX - 4) / 0.08); The AX - 4 reflect the starting point of the data?

You have done really nice job with the TChart. So thank you and good weekend.

Premek


Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: ColorMapSeries in TChart
« Reply #12 on: March 04, 2011, 02:08:16 pm »
Quote
OK I didn't understand what the StepX represent. Now is clear.
I will re-state it for clarity.
ColorMap is drawn as a grid of cells StepX pixels wide and StepY pixels high.
OnCalculate event is called once for each cell.
So, lower StepX/StepY values give better precision, but worse performance.

Quote
I working on it. This was just for the test. Your solution is also nice. But more contrast colours will be better for sure.
Agreed.

Quote
Only question about the meaning of the second column in the lSource. First is the Y limit, second? and the third is colour.
Second column is not used now.

Quote
Question: it is possible after each zoom refreshing lSource in such way to reflect max and min of zoomed part?
Only if you do it yourself in some event like BeforeDrawBackground.

Quote
Just one more question. x := Round((AX - 4) / 0.08); The AX - 4 reflect the starting point of the data?
Yes. It is a standard linear transformation.

 

TinyPortal © 2005-2018