Stacked Bars and Legend [SOLVED] lazarus / 55-TAChart ---------------------------------------------------------------------- PZsolt27 · 2015-12-15 21:50 Hi all, I'm new to the Lazarus, sorry if I ask stupid questions. And sorry for my English. So, I have a project and I should draw stacked bars. With YCount of the Source and using TChartStyles I was able to create nice stacked bars. But there should be some legend as well, but as far as I understand, there is one legend item for each series. How can I create more legend items? Is there some way to create legend items without reference to the main chart? There is one more question. How can I colorize the labels of the bottom axis? I have to display the days of a month and I want to colorize the weekends. How can I do this? Thanks in advance, Zsolt ---------------------------------------------------------------------- wp · 2015-12-15 22:11 Did you see the tutorial http://wiki.lazarus.freepascal.org/TAChart_Tu torial:_Stacked_BarSeries? It explains how to do the legend for stacked series. Regarding legend items without reference to the chart: I don't think that it is straightforward... You can try to owner-draw the entire legend, though (event OnDrawLegend of the chart), there is an example in the demo/legend folder of the TAChart installation (http://wiki.lazarus.freepascal.org/TAChart_Demos#legend). At the moment there is not way to paint the axis labels in individual colors, sorry. But in principle, it should be possible: you can define the axis labels in a ListChartSource which provides space for a color. It is mainly intended for series data points, but it can be applied to an axis as well. Unfortunately the color is ignored by the axis. Let me look into the source to see how difficult it is to change that. ---------------------------------------------------------------------- PZsolt27 · 2015-12-15 22:23 Many thanks for the tutorial link, I did not find it... this is exactly what I need!!! I don't really want to use the OnDrawLegend event. Concerning the axis labels, what about some OnDrawAxisLabel event where we could customize it's color/style? ---------------------------------------------------------------------- wp · 2015-12-15 22:46 Quote from: PZsolt27 on December 15, 2015, 11:23:01 pmConcerning the axis labels, what about some OnDrawAxisLabel event where we could customize it's color/style? Allowing too much variability in the marks migh lead to a mess in the entire layout process, I don't know... At first, I'll try to activate the color in the ListSource; that's not harmful to the layout. ---------------------------------------------------------------------- PZsolt27 · 2015-12-16 09:02 Many thanks for your effort! ---------------------------------------------------------------------- wp · 2015-12-16 09:38 There's some overhead with the axis labels, I don't know if it's worth the effort of implementing such a rarely used feature. Another idea which would also give you the opportunity to use different fonts: Add a second x axis. Use two TChartListsources. Populate the first one with the weekend dates only, set the label font accordingly; assign it to the Marks.Source of the first x axis. Populate the second source with the non-weekend dates, keep standard label font, assign it to the Marks.Source of the second axis. Give both axes the same non-zero group index in order to paint them at the same line. See attached demo. ---------------------------------------------------------------------- PZsolt27 · 2015-12-16 10:03 Thanks for the demo, it works fine! With this dual-axis workaround all my Lazarus problems have been solved. Many thanks!