Caves Travel Diving Graphics Mizar Texts Cuisine Lemkov Contact Map RSS Polski
Trybiks' Dive Texts Charts TChart - Missing Labels in Axes YAC Software
  Back

List

Charsets

Charts

DBExpress

Delphi

HTML

Intraweb

MSTest

PHP

Programming

R

Rhino Mocks

Software

Testing

UI Testing

VB.NET

VCL

WPF

TChart - Missing Labels in Axes
Recently I stumbled upon a small problem with using labels in horizontal axes in TChart when adding different numbers of values in several series.

Namely, TChart takes labels for values in an axis from the labels of the first series. So, if in the first series you have less values than in other series, labels won't show up in an axis:



The code for the above example is as follows (now value in the first series for X = 10):
  Series1.AddXY(20, 10, 'test2');
  Series1.AddXY(30, 20, 'test3');
  
  Series2.AddXY(10, 25, 'test1');
  Series2.AddXY(20, 15, 'test2');
  Series2.AddXY(30,  5, 'test3');
To fix this issue, add a NULL value to the first series for all X values that need to have a label in an axis:
  Series1.AddNullXY(10, 0, 'test1');
The second value (Y) is not relevant here.

Now, the label for X = 10 is displayed in the bottom axis:



This works nicely in D2007, but that's not enough in D2009. In the new version of Delphi you have to set the series' TreatNulls to Dont Paint. What's more, you have to set this in the designer:



The following code, when added to the code snippets above, will not do (IME):
  Series1.TreatNulls := tnDontPaint;
HTH

Top

Comments
#1
Pete wrote on 2011-08-24 15:35:04
Thanks for posting this solution, saved me hours of head scratching.

Top

Add a comment (fields with an asterisk are required)
Name / nick *
Mail (will remain hidden) *
Your website
Comment (no tags) *
Enter the text displayed below *
 

Top

Tags

Charts

Delphi


Related pages

Delphi interfaces... again

Checking "Dangling" Event Handlers in Delphi Forms

Drag-n-drop files onto the application window

Intraweb and MaxConnections

A Case for FreeAndNIL

Intraweb as an Apache DSO module

"Device not supported" in Intraweb

Automated GUI Testing

Rounding and precision on the 8087 FPU

SessionTimeout in Intraweb

Using TChart with Intraweb

Unknown driver: MySQL

TIdMessage's CharSet

Software Guarantees

Automated Testing of Window Forms

Memory Leaks and Connection Explosions in DBExpress

Controlling Conditional Defines and Compilation Switches

Detecting Memory Leaks with DUnit

last_insert_id() and DBExpress

Registering Extensions

DBExpress and Thread Safety

Forms as Frames

Checking Dangling Pointers vs. the New Memory Manager

Accessing Protected Members

Objects, interfaces, and memory management in Delphi