Fast Report Chart question

edited 11:57PM in FastReport 4.0
Hi all

I'm getting good results with the charting in FR. However I have one small problem. I've used charts before in Delphi and would add values by using :

Chart.SeriesList[j].AddXY(x, y, '', color);

However I can't find the AddXY() Method in the FR TfrxChartView component. So I'm using :

AChartView.SeriesData.YSource
AChartView.SeriesData.XSource

Problem is the chart looks like this:

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 11:57PM
    this might help you
    Chart1.SeriesData[0].Source1 := 'A;B;C'; //labels
    Chart1.SeriesData[0].Source2 := '1;2;3'; //x
    Chart1.SeriesData[0].Source3 := '4;5;6';//y
    Chart1.SeriesData[0].Source4 := '10;20;30';//offset
    Chart1.SeriesData[0].Values5 := 'clred;clyellow;clblue';//color
  • edited 11:57PM
    Hi gordk

    Sorry no this still makes absolutely no sense to me. Could you possible show me the code to get the last (bottom) graph picture on my first question?

    Thanks
    A
  • gordkgordk St.Catherines On. Canada.
    edited 11:57PM
    anton can you post a small demo of your problem here.
  • edited 11:57PM
    Hi

    I'll do that when I get a chance to put together a demo.

    In the mean time if you could demonstrate code like :

    Chart1.SeriesData[0].Source1 := 'A;B;C'; //labels
    Chart1.SeriesData[0].Source2 := '1;2;3'; //x
    Chart1.SeriesData[0].Source3 := '4;5;6';//y
    Chart1.SeriesData[0].Source4 := '10;20;30';//offset
    Chart1.SeriesData[0].Values5 := 'clred;clyellow;clblue';//color

    that will produce a chart like the 3rd image in my first question that would be more than enough help to me.

    Thanks

  • edited 11:57PM
    So if you could show me how to draw this using the most basic code:

  • edited 11:57PM
    So what I do using TeeChart is:

    // Set Y-axis = 0, 100
    // Set X-axis = 0, 30

    // First line, blue
    TeeChart.SeriesList[0].AddXY(0, 95);
    TeeChart.SeriesList[0].AddXY(3, 95);
    TeeChart.SeriesList[0].AddXY(9, 5);
    TeeChart.SeriesList[0].AddXY(17, 5);
    TeeChart.SeriesList[0].AddXY(30, 100);

    // Second line
    TeeChart.SeriesList[0].AddXY(0, 5);
    TeeChart.SeriesList[0].AddXY(3, 5);
    TeeChart.SeriesList[0].AddXY(9, 95);
    TeeChart.SeriesList[0].AddXY(17, 95);
    TeeChart.SeriesList[0].AddXY(30, 0);

    A
  • gordkgordk St.Catherines On. Canada.
    edited 11:57PM
    put a chart object on the page and edit it's properties to suit. your needs.
    write code in the obp event of the chartobject.
    procedure Chart1OnBeforePrint(Sender: TfrxComponent);
    begin
    Chart1.AddSeries(csLine);
    Chart1.SeriesData[0].DataType := dtFixedData;

    Chart1.SeriesData[0].xSource := '0;3;9;17;30';
    Chart1.SeriesData[0].ySource := '95;95;5;5;100';
    chart1.addseries(csline);
    chart1.seriesdata[1].datatype := dtfixeddata;
    //Chart1.SeriesData[1].xSource := '0;3;9;17;30';
    Chart1.SeriesData[1].ySource := '5;5;95;95;0';
    end;
  • edited 11:57PM
    Hi

    Thanks for the response but I've already got to this point.

    The problem is is that the X Axis is non linear. That is the distance between 0 and 3 is the same as between 3 and 9, and again between 9 and 17. I want the X Axis to go in a linear fasion from 0 to 30. So the graph will look like the image I've attached before.

    Perhaps here is something else I need to set in the Chart obj to make it so???

    Thanks
    A
  • edited August 2013
    Ah OK! By setting

    AChartView.SeriesData[0].XType := xtNumber;

    I now get the x-axis in a liner fasion:

  • edited 11:57PM
    Very, very close to working!!! [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> AChartView.Chart.BottomAxis.SetMinMax(0, 30); AChartView.Chart.LeftAxis.SetMinMax(0, 100); AChartView.Chart.BottomAxis.LabelStyle := talValue; AChartView.AddSeries(csLine); AChartView.SeriesData[0].XType := xtNumber; AChartView.SeriesData[0].DataType := dtFixedData; AChartView.SeriesData[0].XSource := '0;3;9;17;30'; AChartView.SeriesData[0].YSource := '95;95;5;5;100'; AChartView.AddSeries(csLine); AChartView.SeriesData[1].XType := xtNumber; AChartView.SeriesData[1].DataType := dtFixedData; AChartView.SeriesData[1].XSource := '0;3;9;17;30'; AChartView.SeriesData[1].YSource := '5;5;95;95;0'; Gives me this :[/img]>>>
  • edited 11:57PM
    Done!

    Adding: AChartView.Chart.BottomAxis.Increment := 5;

    Changes the axis to show "0, 5, 10, 15, 20. 25, 30" labels only.

    [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> Case closed...[/img]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.