Jump to content

uniChart Set Color On BarSeries


andyhill

Recommended Posts

Yes, that worked fine (for an other purpose).

 

But now  :   1 color  for all Bars   (on 1 UniBarSerie). 

Below graphic.

 

On the program I sent you :

I have an UniChart with one UniBarSeries.

I can Set the color on MainForm. OnCreat Event   (let say yellow for all bars)

but  at Runtime, when I Click on UniButton1   to change all Bars color  to red,  not work.

 

Thx

 

 

_____

Edit :

The UniBarSeries : Sometimes contains 3 bars,  Sometimes contains 25, Sometimes contains 50....  (it depend on a dataSource)

so Method topic#15  is not appropriate.

post-1785-0-02547100-1513068397_thumb.png

Link to comment
Share on other sites

Hi,

 

Can you try this approach?:

 

1.

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  myColor: string;
begin
  myColor := 'red';

  UniChart1.ClientEvents.UniEvents.Values['chart.beforeInit']:=
    'function(sender, config)'+
    '{' +
    'sender.themeAttrs.seriesThemes = [{fill: "' + myColor + '"}];' +
    'sender.themeAttrs.colors=["' + myColor + '"];' +
    //'sender.themeAttrs.refresh;' +
    '}'   ;

  //Set_Color('red');

  Construct_MyGraph;
end;

2.

procedure TMainForm.Set_Color(MyColor:string);
begin
  with UniChart1.JSInterface do
  begin
    JSCode(#1'.chart.themeAttrs.colors[0]="' + MyColor + '";');
    JSCode(#1'.chart.themeAttrs.seriesThemes[0].fill="' + MyColor + '";');
    JSCall('chart.redraw', []);
  end;
end;

3.

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  Set_Color('green');
end;

Best regards,

  • Upvote 1
Link to comment
Share on other sites

  • 6 months later...
  • 6 months later...
On 12/12/2017 at 8:03 PM, Sherzod said:

1.


procedure TMainForm.UniFormCreate(Sender: TObject);
var
  myColor: string;
begin
  myColor := 'red';

  UniChart1.ClientEvents.UniEvents.Values['chart.beforeInit']:=
    'function(sender, config)'+
    '{' +
    'sender.themeAttrs.seriesThemes = [{fill: "' + myColor + '"}];' +
    'sender.themeAttrs.colors=["' + myColor + '"];' +
    //'sender.themeAttrs.refresh;' +
    '}'   ;

  //Set_Color('red');

  Construct_MyGraph;
end;

 

Used this code in one of my older projects successfully.

With current/newer version of ExtJSVersion 6.6.0 this approach is not working anymore.

Link to comment
Share on other sites

30 minutes ago, neo4a said:

I'll be glad if we can find a solution soon.

TIA.

Hello,

Try this config

UniChart -> ClientEvents -> UniEvents -> function chart.beforeInit:

function chart.beforeInit(sender, config)
{
    config.colors = ["green", "yellow", "red", "#94ae0a", "#115fa6", "#a61120", "#ff8809", "#ffd13e", "#a61187", "#24ad9a", "#7c7474", "#a66111"];
}

 

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

I have two bar series created in design. Not stacked.
If I assign different brush colors C1 and C2 to them, when running, all bars in both series appear with color C1.
It does not work assigning colors in design time nor in run time.
And in the legend still appear original colors.

Thx in advance 

Link to comment
Share on other sites

9 minutes ago, AntonioM said:

I have two bar series created in design. Not stacked.
If I assign different brush colors C1 and C2 to them, when running, all bars in both series appear with color C1.
It does not work assigning colors in design time nor in run time.
And in the legend still appear original colors.

Hi,

Can you make a simple testcase?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...