Forum > TAChart

primary Questions about TChart

(1/4) > >>

majid.ebru:
Hi

i have many primary Questions  about TChart.

please help and guide me

how can i fix min and max axis ?

how can i have mult color line?

how can i change value of X axis to Srtinf Text?

how can i show value of point?

majid.ebru:
and

wp:

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i fix min and max axis ?

--- End quote ---
Set the Extent of the chart (can be done by code like below, or directly in the Object Inspector)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Chart1.Extent.YMax := 100;  Chart1.Extent.YMin := 0;  Chart1.Extent.UseYMax := true;  Chart1.Extent.UseYMin := true;

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i change value of X axis to Srtinf Text?

--- End quote ---
What you probably need is an event handler for the event OnMarkToText of the axis. Example

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Chart1AxisList1MarkToText(var AText: String; AMark: Double);begin  if AMark = 0.0 then AText := 'zero';end;

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i show value of point?

--- End quote ---
Set the Marks.Style of the series to smsValue. The settings of Marks.Style define the combinations of the data point parameters (x, y, text) which will be shown as datapoint label (http://wiki.lazarus.freepascal.org/TAChart_documentation#Mark_labels):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TSeriesMarksStyle = (    smsCustom,         { user-defined }    smsNone,           { no labels }    smsValue,          { 1234 }    smsPercent,        { 12 % }    smsLabel,          { Cars }    smsLabelPercent,   { Cars 12 % }    smsLabelValue,     { Cars 1234 }    smsLegend,         { ? }    smsPercentTotal,   { 12 % of 1234 }    smsLabelPercentTotal, { Cars 12 % of 1234 }    smsXValue);        { 21/6/1996 }    Change the format string in Marks.Format to limit the number of decimal places, e.g. '%.2f' for 2 decimals only.

I'll have to think about the other questions.
- What does the last image (06.png) mean?
- In image 05.png you have a chart with a line series, and there's a horizontal dividing line. The parts of the line series above the dividing line should be painted in a different color than the parts below the dividing line. Correct? Will be dividing line be fixed, or should it be user-changeable?

taazz:

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i have mult color line?

--- End quote ---
There is no reason for multi colour lines. lines are not part of the data only points are the data lines are there to sombolize an idea only it is either negative or positive it can't be both. Don't waste your time on a illogical case.

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i show value of point?

--- End quote ---
select the series of the chart and change the marks.style to what ever you need make sure that the marks are visible.

wp:

--- Quote from: majid.ebru on February 09, 2018, 07:31:31 pm ---how can i have mult color line?

--- End quote ---
Drawing the segments of a lineseries in different colors is not supported. But you can use a TUserDrawnSeries instead of the TLineSeries in which you can draw whatever you want - see attached demo.

* FormCreate defines some dummy data in an array of TDataRec records (record of x and y values) and calculates the range covered by the x and y values (Extent)
* The Extent has to be passed to the series in its event OnGetBounds.
* The event OnDraw expects code which paints the entire series. My code simply iterates through the data point array, calculates the image coordinates of each data point (by calling the chart's method GraphToImage) and draws the line segments in the color which is assigned to the current point index in the COLORS array. I should mention that using a Canvas in the OnDraw event is not up to the standard of TAChart which has introduced dedicated drawers. But there's nothing else at the moment, and you hopefully do not want to paint on exotic output devices.This probably is also the way to answer the question related to image 05.png where the series changes color above and below a dividing line. The only code which has to be added is the calculation of the intersection point of the line segment with the dividing line.

Navigation

[0] Message Index

[#] Next page

Go to full version