Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1679 - Adding a new series messes up the custom palette
Summary: Adding a new series messes up the custom palette
Status: IN_PROGRESS
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Editors (show other bugs)
Version: 20.170306
Hardware: PC Windows
: --- major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-08 08:44 EST by h.hasenack
Modified: 2017-03-14 05:27 EDT (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description h.hasenack 2016-11-08 08:44:14 EST
When adding a new tchartsieres to an existing chart that utilkizes a custom palette, the pallette is destroyed adn an standard palette is restored.
Comment 1 h.hasenack 2016-11-08 08:46:15 EST
Here's the fix, in TeeGally.pas mared with HH_PATCH_REGISTERPALETTE
-------------------

Function CreateNewSeriesGallery( const AOwner:TComponent;
                                 const OldSeries:TChartSeries;
                                 const tmpChart:TCustomAxisPanel;
                                 ShowFunctions,
                                 CheckSeries:Boolean;
                                 Var SubIndex : Integer;
                                 AGalleryWidth: Integer=0;
                                 AGalleryHeight: Integer=0  ):TChartSeries;

  function InternalShowGallery:TChartSeries;
  var Show3D   : Boolean;
      tmpClass : TChartSeriesClass;
      tmpFunctionClass : TTeeFunctionClass;
      tmpPalette : Integer;
{$ifdef HH_PATCH_REGISTERPALETTE}
      tmpColorPalette:TColorArray;
{$endif}
      tmpOwner : TComponent;
  begin
    result:=nil;
    Show3D:=tmpChart.View3D;

    tmpPalette:=(tmpChart as TCustomChart).ColorPaletteIndex;
{$ifdef HH_PATCH_REGISTERPALETTE}
    tmpColorPalette:=(tmpChart as TCustomChart).ColorPalette;
{$endif}

    //If we show the gallery from the chart editor we use its gallery size
    if (AOwner is TChartEditForm) and
       (TChartEditForm(AOwner).GalleryWidth>0) and
       (TChartEditForm(AOwner).GalleryHeight>0) then
    begin
      AGalleryWidth:=TChartEditForm(AOwner).GalleryWidth;
      AGalleryHeight:=TChartEditForm(AOwner).GalleryHeight;
    end;

    if GetChartGalleryClass(AOwner,OldSeries,ShowFunctions,tmpClass,Show3D,
                            tmpFunctionClass,CheckSeries,SubIndex,
                            tmpPalette, AGalleryWidth, AGalleryHeight,
                            tmpChart) then
    begin
      tmpChart.View3D:=Show3D;
      (tmpChart as TCustomChart).ColorPaletteIndex:=tmpPalette;
{$ifdef HH_PATCH_REGISTERPALETTE}
      if tmpPalette<0 then // restore custom palette
        (tmpChart as TCustomChart).ColorPalette:=tmpColorPalette;
{$endif}

      if (not Assigned(OldSeries)) or
         (ShowFunctions or ((tmpClass<>OldSeries.ClassType) or (SubIndex<>-1))) then
      begin
        if Assigned(OldSeries) then tmpOwner:=OldSeries.Owner
                               else tmpOwner:=TCustomAxisPanelAccess(tmpChart).GetDesignOwner;

        result:=CreateNewSeries(tmpOwner,tmpChart,tmpClass,tmpFunctionClass);

        if SubIndex<>-1 then
           TSeriesAccess(result).SetSubGallery(result,SubIndex);
      end;
    end;
  end;

begin
  try
    result:=InternalShowGallery;
  except
    on E:Exception do
    begin
      {$IFDEF TEEEXCEPTIONS}
      if csDesigning in tmpChart.ComponentState then
         TTeeExceptionForm.Send('GALL',E);
      {$ENDIF}
      raise;
    end;
  end;
end;