Recent

Author Topic: Legend issues and wishes  (Read 3821 times)

wp

  • Hero Member
  • *****
  • Posts: 7520
Legend issues and wishes
« on: December 19, 2012, 10:32:41 am »
There are a few issues with the chart legend
  • ColorMapSeries: The values of the color source are displayed always with full precision which makes the legend very broad. It would be better if the Format property of the TChartSeriesLegend would be respected.
  • ColorMapSeries: The name of the z value shown in the legend is not always appropriate. For example, I am plotting a lot of temperature data recently, therefore it would be better to have a "T" instead of the "z" in the legend. It would be fine also if the interval optionally  could be abbreviated by, for example, "0 ... 0.2", instead of "0 <= z < 0.2". Sometimes it may be even desirable to show the center value instead of the interval ("0.1" in above example). Another wish would be to have the option of a gapless, band-like legend, maybe even with the full gradient like in the attached screen shot of gnuplot
  • Trying to implement an event handler for ChartSeriesLegend.OnCreate or OnDraw by double-clicking in the OI results in an error "Methode name "" must be an identifier."
  • LineSeries (probably also other ChartSeries): series values are not displayed when Legend.Multiplicity = lmPoint

See attached demo.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Legend issues and wishes
« Reply #1 on: December 19, 2012, 12:06:02 pm »
Quote
Format property of the TChartSeriesLegend would be respected.

Done since r39588.
It is a little tricky, however:
1) Since there are three different item positions, format is interpreted as 3 format strings delimited by '|'. So, default format may be expressed as
z ≤ %1:g|%g < z ≤ %g|%g < z
If Legend.Format contains less then three parts, the last one is replicated, so a simple '%.2f' will work too.
2) Each format is passed two values, previous and next level. Depending on your preference you might want to write '%1:.2f'.
3) Even before this commit, you could set arbitrary text to a legend item via Text field of the color source items.
4) OnCreate event receives a TLegendItem and can change it arbitrarily, in particular set Text property.

This also solves your next wish -- you can set any separator you like.

Quote
Trying to implement an event handler for ChartSeriesLegend.OnCreate or OnDraw by double-clicking in the OI results in an error "Methode name "" must be an identifier."
Yes, this is issue 19632.

I will get to the other points later.

wp

  • Hero Member
  • *****
  • Posts: 7520
Re: Legend issues and wishes
« Reply #2 on: December 19, 2012, 04:54:18 pm »
Thank you for the quick response. Your fix is working perfectly, however, only after a small modification:
Add "StrictDelimiter := true" to the local function "PrepareFormats" of TColorMap.GetLegendItems. Without this modification the format parts are not reckognized correctly.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Legend issues and wishes
« Reply #3 on: December 20, 2012, 06:26:12 pm »
Quote
Add "StrictDelimiter := true"
Ah, forgot that again. Fixed in r39600, along with a refactoring which will hopefully prevent this kind of bugs in the future.

Quote
LineSeries (probably also other ChartSeries): series values are not displayed when Legend.Multiplicity = lmPoint
This is because you did not set Legend.Format
By default, if Legend.Format = '', then Marks.Format is used, and if the latter is empty too, then nothing is displayed.


wp

  • Hero Member
  • *****
  • Posts: 7520
Re: Legend issues and wishes
« Reply #4 on: December 20, 2012, 10:46:07 pm »
Great, thanks a lot.

I am thinking to add a legend section to the Mandelbrot tutorial to demonstrate the new legend features. And I could also add a demonstration of how to open a context menu with the presence of ChartTools -- this is still an open item for me from another discussion. But I fear the tutorial may get too long now. I could use the current state as a starting point for a "part 2" with legend and context menu. What is your opinion?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Legend issues and wishes
« Reply #5 on: December 21, 2012, 12:26:48 am »
Quote
I could use the current state as a starting point for a "part 2" with legend and context menu. What is your opinion?

For legend, sure, no problem -- it is colormap-specific anyway.
For context menu, there is a downside -- if a user is only interested in context menu,
he will be faced with many of unrelated details.
But a separate tutorial only for context menu is excessive too,
so it is probably a good compromise anyway.

 

TinyPortal © 2005-2018