Chart and colors?

renerene Prague, Czech Republic, Europe
edited 7:03PM in FastReport 3.0
Hi there,
I would like to know how to change the default color used in pie charts. It seems like FR hide and ignore all the TChartXXX properties like ColorSource (which will be very usefull - actually I have colors stored in DB, so I can get them in SQL) or array of color in ValueColor[] property. Is it possible to set my own colors for Pie some other way? Any idea? I suppose that some changes in frxChart will fix this issue. Does anybody tried to solve this already?
Thank you for any response,
Rene

Comments

  • renerene Prague, Czech Republic, Europe
    edited 7:03PM
    rene wrote:
    I would like to know how to change the default color used in pie charts.
    OK, no answer - nevermind.
    my solution is in change of definition of object "TfrxPieSeriesHelper" in standard unit "frxChartHelpers" (OK, this is not the best solution, but it works) this way (mind the +/- rm tags):
    { TfrxPieSeriesHelper }
    
    procedure TfrxPieSeriesHelper.AddValues(Series: TChartSeries; const v1, v2,
      v3, v4, v5, v6: String; XType: TfrxSeriesXType);
    var
      d: Double;
      c: TColor; // + rm 11.01.2007
    begin
      if Series.YValues.DateTime then
        d := StrToDateTime(v2)
      else
        d := frxStrToFloat(v2);
    //  Series.Add(d, v1, clTeeColor); // - rm 11.01.2007
    
      // + rm 11.01.2007
      c := clTeeColor;
      if v2 <> '' then
      try
        c := StringToColor(v3);
      except
       ; // nothing
      end;
    
      Series.Add(d, v1, c);
    end;
    
    function TfrxPieSeriesHelper.GetParamNames: String;
    begin
    //  Result := 'Label;Pie'; // - rm 11.01.2007
      Result := 'Label;Pie;Color (optional)'; // + rm 11.01.2007
    end;
    

    In my opinion is it very simple and usefull change with no harm to standard code of FR3.

    Enjoy it,
    Rene

    PS: If FR team consider to use it in next release/update of FR3, it will be great. (At least I will avoid some merging problems during upgrades.)

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.