Legend for ColorMapSeries lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2012-10-23 13:53 Given the following situation: - TChart with ColorMapSeries, z values ranging between 23 and 34 - Chart.Legend.Visible = true, ColorMapSeries.Legend.Multiplicity = lmPoint - ColorSource with three entries corresponding to the minimum, center and maximum z value. - ColorMapSeries.Interpolate = true Ideally, I would expect in the legend color entries for "nice" z levels, like 23, 24, 25, ..., 34. The legend however displays only the three items which were entered in the color source, and they are labeled by ranges like "23 <= z < 28.5"  -- see attached screenshot. These labels seem to correspond to the case that Interpolate is off. If Interpolate is true the labels should not be ranges but numbers only, in my opinion. I guess I can change the legend text in the Series.Legend.OnCreate, but it would be better if the legend text would be correct automatically How to add some more intermediate legend items to identify the interpolated colors? I know that I can use the ColorMapSeries.ColorByValue to get the color of any intermediate value. But how about the intermediate values themselves? Of course I could calculate the intermediate levels for the color source by hand, or maybe I could use Legend.UserItems (never tried this before...). But in each case I would have to find the "nice" intermediate values by myself. On the other hand, this procedure exists already in the ChartAxis. My question: Is there a way to use the generation of "pretty" labels outside the axes? ---------------------------------------------------------------------- Ask · 2012-10-23 18:44 QuoteThese labels seem to correspond to the case that Interpolate is off. If Interpolate is true the labels should not be ranges but numbers only, in my opinion.Since r39152, legend symbols for interpolated color map display full color range, so the problem should be solved. QuoteIs there a way to use the generation of "pretty" labels outside the axes?Yes, use TIntervalChartSource.ValuesInRange, see TIntervalSourceTest.IntervalSource of the test project for an example. However, ValuesInRange ignores color. I'll think about it. Meanwhile, you can also use user-defined source as an alternative to the user-defined legend items. It will be slightly less efficient, but simpler. ---------------------------------------------------------------------- wp · 2012-10-24 14:04 QuoteSince r39152, legend symbols for interpolated color map display full color range, so the problem should be solved.Thanks, the mini-gradients are nice. They may become a "trademark" of TAChart, I have never seen them with any other charting program. One little issue left: there is no information on the higest value -- see screenshot; I think the 3rd item should be "28.5 < z <= 34". I am not sure about the first item: in my case there are no values smaller than 23, so this item might be skipped if the second item becomes "23 <= z <= 28.5". Of course, the item "z<= 23" is completely justified when there are values smaller than the first color. In such a case, however, the legend should also allow for a case that there are values larger than the last color, i.e. "z>34". I cam imagine cases where the "out-of-range" colors are different from the first and last colors of the color gradient - see the Mandelbrot set tutorial (not finished yet). So it's getting complicated again, sorry... In addition, the legend items may get quite long, for example if calculated from true data the numbers may have many decimals. Is there a way to format the numbers in this type of legend? I tried Series.Legend.Format, but this does not change anything. And finally, combining two numbers in the legend text widens the legend even further. So I think it would be great to haven an option that avoids the number/color pairs (no ranges, no mini-gradient) and switches to a single value/single color for each legend item. QuoteYes, use TIntervalChartSource.ValuesInRange, see TIntervalSourceTest.IntervalSource of the test project for an example.Oh, that's tough... QuoteMeanwhile, you can also use user-defined source as an alternative to the user-defined legend items. It will be slightly less efficient, but simpler.Sorry, I don't understand. How can a userdefine chartsource help me finding "nice" labels? I found an easy way to add additional intermediate labels by means of a dummy bar series. The color/value pairs are copied from the color source, and intermediate pairs are added as needed (I still have to calculate the "nice" values by myself). Unfortunately, the series does not show up in the legend if it is not active. Therefore the series must be hidden by using coordinates for the data points that are within the extent of the colormap series and is painted over by the color map. Not nice, but works. Maybe it would be better if the ColorMapSeries had some kind of "ColorAxis" (I think I saw this concept with MatLab) because an axis can do this automatically.