Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

series.marks.visible question or marks overlap

Status
Not open for further replies.

Tracey

Programmer
Oct 16, 2000
690
NZ
Hi [wavey]

I have dynamically created a chart, with 4 series (only 3 for data)

I had the marks.visible := true but the labels along the stacked series' were overlapping each other.

one workaround i thought was to have the marks.visible property true only if the series had a positive value. However this produced erratic results. I am wondering if it is possible to do this in a loop with one series.

Where my code loops through a set of records, each record has a value for each of the 3 series. I check the value of the variables holding the recordvalues, if not > 0 then marks.visible = false;
Once all values for the current Y axis value are ascertained, I then add the values to the series' from the variables.
Then add the series' to the serieslist

then the TJPegImage is created, and saved to file to display on my chart. then it is shown in the html of my report, the series' cleared and the loop starts again.

Is there anyone here who knows enough about dynamic chart creation to help me figure out either:
Why I am getting inconsistant results
or
How to stop the series labels (marks) from overlapping

[cheers]

Tracey
[hippy]



 
without knowing what component you are using, I don't think many people will be able to help!!!

Perhaps some code snippets as well???
 
I am creating a TChart with
FChart := TChart.Create(nil);

I refrained from the code because it was pretty long-winded.

I have moved away from trying to do this, and have set all marks.visible to false, and show colours in the legend.

I believe what was happening was that on the last pass through my variables, setting the marks.visible property for the THorizSeries obj effected all shown values because the object is used multiple times to create one chart.

Just for the record, i will post some snippets of code, if anyone can tell me how i could have done what i wanted to i would really appreciate it for next time

(i have taken a lot of irrelivent code out)

Code:
    procedure SetChartValues;           //sets value of bars in the chart
    begin
        with FChart do
        begin
            SeriesList.Clear;
            if fOutWork > 0 then
                HorizBarSeries.marks.visible := true
            else
                HorizBarSeries.marks.visible := false;
            //do the same for all variable / series

            LabelSeries.AddBar(0, StringVar, 0);
            HorizBarSeries.Addbar(fOutWork, 'OutWork',
                clltGray);

            BarParts.Addbar(fParts, 'Parts',
                clMedGray);

            BarLabour.Addbar(fLabour, 'Labour',
                clDkGray);
            SeriesList.Add(LabelSeries);
            SeriesList.Add(HorizBarSeries);
            SeriesList.Add(BarParts);
            SeriesList.Add(BarLabour);
            with Title do
            begin
                Font.Size := 8;
                Font.Color := clBlack;
                Text.Clear;
                Text.Add('Costs for ' + sRef + ' during ' + sFromDat + ' - ' + sToDat);
            end;
        end;                            //with fchart
    end;                                //procedure

    procedure SaveAndShow;
    begin
        Bitmap := FChart.TeeCreateBitmap(clWhite,
            Rect);
        FJPEG.Assign(Bitmap);
        //GOT TO SAVE EACH CHART AS A SEPERATE FILE OR THEY WILL ALL BE THE SAME
        FJPEG.SaveToFile('\icons\breakdownchart'
            + IntToStr(iThisMachine) + '.jpg');
        Str.Add('<tr><td colspan=6 align=center><IMG Src=&quot;\icons\breakdownchart'
            + IntToStr(iThisMachine) +
            '.jpg&quot;></td></tr>');
    end;
///stuff....
while not eof do
begin
    //IF MACHINE HAS CHANGED, DISPLAY ITS REF
    if not (iThisMachine =
        FieldByName('MachineID').AsInteger) then
    begin
        if bShowChart then
        begin
            SaveAndShow;
        end;
        bShowChart := true;
        iThisMachine :=
            FieldByName('MachineID').AsInteger;
        LabelSeries.Clear;
        HorizBarSeries.Clear;
        BarParts.Clear;
        BarLabour.Clear;
        fParts := 0.0;
        fLabour := 0.0;
        fOutwork := 0.0;
        bNewSystem := true;
    end                                 //if machine has changed
    else
        Str.Add('<tr><td>');
    StringVar := FieldByName('system').AsString;
    iThisSystem := FieldByName('systemid').AsInteger;
    Next;
    //do this whenever the system value is changed, or we move
    //on to another machine (could have the same system)
    if (iThisSystem <>
        FieldByName('SystemID').AsInteger) or
        (iThisMachine <>
        FieldByName('MachineID').AsInteger) then
    begin
        SetChartValues;
        bNewSystem := true;
        fParts := 0.0;
        fLabour := 0.0;
        fOutwork := 0.0;
    end;                                //if changed system or machine
end;                                    //wHILE NOT EOF

It doesnt look like there are many people creating charts in code out there, judging from the replies (or lack of) i have had to all my posts in various forums / mailing lists. There is a major disadvantage of not being able to access many methods/functions because they can only be accessed from events.

If anyone could point me to some detailed advanced tutorials on dynamic chart creation i will pay generously with stars ;-)

[cheers]
 
I've done a fair bit of work with TCharts and have also noticed a lack of information. One site I have found useful, although it takes an age for the post to go up is groups.google.com. There is a dedicated reporting-charting forum ( which you can post your questions which do, more often than not, get answered. Also a guy called David Berneda who works for Steema (who produce TChart) does post answers. You can also go to the Steema website ( and post a technical problem. But unless you actually have a maintenance agreement your posts are a low priority to them. However, I have had some good answers from them in the past. Also, on the same page there are tutorials and FAQs etc. which you may find of some use.

Hope this helps!


Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Thanks Stretch... I have spent quite a bit of time on steema.com
I will check out that forum..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top