Jump to content

How to change series color in TUniChart


andreyka

Recommended Posts

  • 7 months later...
On 8/14/2018 at 7:00 PM, sertatar76 said:

FMSoft_uniGUI_Professional_1.50.0.1475

 

I change color for TUniBarSeries. What am I doing wrong?

post-5580-0-22657100-1534262108_thumb.png

ChartsBarChart.zip

TUniGaugeSeries has no Brush and Pen property at all.  What am I doing wrong? :) Farshad, please fix the TUniGaugeSeries, bug is opened from august. And nothing was changed, I try on the latest version.

Link to comment
Share on other sites

  • 8 months later...

[Pt-Br] Estou passando por um problema semelhante. Estou tentando criar um gráfico pra mostrar o progresso de uma operação para o usuário, só que empaquei no ponto onde queria que a cor que eu definir para cada fatia seja respeitada em tempo de execução, porém ele só esta obedecendo as cores definidas no componente em tempo de desenvolvimento mesmo eu dando clear nas cores (tentei remover todas as cores no componente e dá na mesma) e opção DefaultColors já está desmarcada... 

[En] I'm going through a similar problem. I am trying to create a graph to show the progress of an operation to the user, but I stuck at the point where I wanted the color I set for each slice to be respected at runtime, but it is only obeying the colors defined in the component in development time even though I clear the colors (I tried to remove all colors in the component and give it) and DefaultColors option is already unchecked ...

 

Example Code:

procedure TMainForm.DoRefreshChart;
  function InterGetColor: string;
  var vStatus: string;
  begin
    vStatus := DataSource3.DataSet.FieldByName('STATUS').AsString;
    if vStatus = 'PENDENTE' then
      Result := '#000000'
    else if vStatus = 'GERADO' then
      Result := '#0000FF'
    else if vStatus = 'ENVIADO' then
      Result := '#008080'
    else if vStatus = 'RECEBIDO' then
      Result := '#800080'
    else if vStatus = 'PROCESSADO' then
      Result := '#008000'
    else if vStatus = 'ERRO' then
      Result := '#FF0000'
    else if vStatus = 'CANCELADO' then
      Result := '#800000'
    else if vStatus = 'IGNORADO' then
      Result := '#808000';
  end;
begin
//  UniChart1.BeginUpdate;
  UniPie3DSeries1.Clear;
  UniPie3DSeries1.Colors.Clear;

  with DataSource3.DataSet do
  begin
    First;
    while not Eof do
    begin
      UniPie3DSeries1.Colors.Add(InterGetColor);
      UniPie3DSeries1.Add('1', FieldByName('FONEC_NAME').AsString);

      Next;
    end;
  end;
//  UniChart1.Update;
//  UniChart1.EndUpdate;

  UniChart1.RefreshData;
end;

 

Link to comment
Share on other sites

1 hour ago, brunomf01 said:

I'm going through a similar problem. I am trying to create a graph to show the progress of an operation to the user, but I stuck at the point where I wanted the color I set for each slice to be respected at runtime, but it is only obeying the colors defined in the component in development time even though I clear the colors (I tried to remove all colors in the component and give it) and DefaultColors option is already unchecked ...

Hello,

Which build of UniGUI are you using?

Can you make a simple testcase for check?

Link to comment
Share on other sites

3 hours ago, Sherzod said:

Hello,

Which build of UniGUI are you using?

Can you make a simple testcase for check?

I'm using Version 1.70.0.1485

 

[Pr-BR] Segue anexo projeto de exemplo, onde preciso mudar de cor a fatia sempre que o campo STATUS mudar de valor.

[En] Here's an example project attachment, where I need to change the slice color whenever the STATUS field changes value.

 

ProjetoDashBoardExample.zip

Link to comment
Share on other sites

19 hours ago, brunomf01 said:

[En] Here's an example project attachment, where I need to change the slice color whenever the STATUS field changes value.

Also, you can try to use this approach:

1. Uses ... UniStrUtils;

2.

procedure TMainForm.DoRefreshChart;
  function InterGetColor: string;
  var vStatus: string;
  begin
    vStatus := DataSource3.DataSet.FieldByName('STATUS').AsString;
    if vStatus = 'PENDENTE' then
      Result := '#9c9c9c'
    else if vStatus = 'GERADO' then
      Result := '#0000FF'
    else if vStatus = 'ENVIADO' then
      Result := '#008080'
    else if vStatus = 'RECEBIDO' then
      Result := '#800080'
    else if vStatus = 'PROCESSADO' then
      Result := '#008000'
    else if vStatus = 'ERRO' then
      Result := '#FF0000'
    else if vStatus = 'CANCELADO' then
      Result := '#800000'
    else if vStatus = 'IGNORADO' then
      Result := '#808000';
  end;

var
  I: Integer;
  ColorsStr: string;
begin
  UniPie3DSeries1.Clear;
  UniPie3DSeries1.Colors.Clear;

  with DataSource3.DataSet do
  begin
    First;
    while not Eof do
    begin
      UniPie3DSeries1.Colors.Add(InterGetColor);
      UniPie3DSeries1.Add('1', FieldByName('ID_DETAIL').AsString);
      Next;
    end;

    ColorsStr := '[';
    with UniPie3DSeries1 do
      for I := 0 to Colors.Count - 1 do
      ColorsStr := ColorsStr + '"'+Colors[I]+'",';
    ColorsStr := RemoveTrailingChar(ColorsStr, ',');
    ColorsStr := ColorsStr + ']';
  end;

  with UniChart1 do
  begin
    JSInterface.JSAssign('colors', [JSInterface.JSStatement(ColorsStr)]);
    JSInterface.JSCall('chart.series[0].setRenderer', [JSInterface.JSFunction('sprite, record, attributes, index, store',
      '    if (record) {'+
      '        if ('+ JSName +'.colors[index]) {'+
      '            attributes.fill = '+ JSName +'.colors[index];'+
      '        }'+
      '    }'+
      '    return attributes;'
    )]);
  end;
  UniChart1.RefreshData;

end;

 

Link to comment
Share on other sites

[Pt-BR] Obrigado, está parte deu certo.
Um problema que eu notei com a legenda é que se eu definir em um alinhamento/posição diferente da padrão o sistema trava. Isso Ocorre desde versões anteriores (inclusive na versão mobile), por isso geralmente retiro a legenda.
Outra coisa é que não consegui achar nenhuma opção que fizesse o gráfico ficar com os Labels sempre dentro da área de exibição (imagem em anexo).

[En] Thank you, this part worked.
One problem I noticed with the Legend is that if I set at a different alignment / position than the default system crashes. This has occurred since earlier versions (including the mobile version), so I usually remove the caption.
Another thing is that I could not find any option that would make the graphic always have the Labels within the display area (attached image).

 

1776959953_Anotao2019-12-30161336.png.988fc1ce61ac929f2be5527449be667d.png

Link to comment
Share on other sites

On 12/31/2019 at 12:15 AM, brunomf01 said:

One problem I noticed with the Legend is that if I set at a different alignment / position than the default system crashes.

 

20 minutes ago, brunomf01 said:

Do you have any position on what I sent in the last post?

Hello,

Can you please explain in more detail?

Link to comment
Share on other sites

[Pr-Br]O problema do label, você pode ver na imagem em anexo como no post anterior onde estes ficam fora da tela.
No caso é possivel fazer com que os labels fiquem dentro do gráfico? 


Outra coisa, como faço para alinhar a cor da Legenda com a cor do gráfico?

Outra coisa é que apenas a primeira fatia possui animação. Está certo isso?


(Segue exemplo novamente em anexo)

Nota:
O problema do alinhamento da Legend eu não consegui reproduzir ainda, mas assim que ocorrer novamente te mando um exemplo em um novo post.

 

[En] The label problem, you can see in the attached image as in the previous post where they are off screen.
In case it is possible to make the labels stay inside the chart?


Another thing, how do I align the color of the Caption with the color of the chart?

Another thing is that only the first slice has animation. Is this right?


(Follows example again attached)

note:
Legend alignment problem I haven't been able to reproduce yet, but as soon as it happens again I'll send you an example in a new post.

 

image.png.3721cf4e5344febf3fccad31056790eb.png

ProjetoDashBoardExample.zip

Link to comment
Share on other sites

On 1/10/2020 at 2:08 PM, brunomf01 said:

[Pr-Br]O problema do label, você pode ver na imagem em anexo como no post anterior onde estes ficam fora da tela.
No caso é possivel fazer com que os labels fiquem dentro do gráfico? 


Outra coisa, como faço para alinhar a cor da Legenda com a cor do gráfico?

Outra coisa é que apenas a primeira fatia possui animação. Está certo isso?


(Segue exemplo novamente em anexo)

Nota:
O problema do alinhamento da Legend eu não consegui reproduzir ainda, mas assim que ocorrer novamente te mando um exemplo em um novo post.

 

[En] The label problem, you can see in the attached image as in the previous post where they are off screen.
In case it is possible to make the labels stay inside the chart?


Another thing, how do I align the color of the Caption with the color of the chart?

Another thing is that only the first slice has animation. Is this right?


(Follows example again attached)

note:
Legend alignment problem I haven't been able to reproduce yet, but as soon as it happens again I'll send you an example in a new post.

 

image.png.3721cf4e5344febf3fccad31056790eb.png

ProjetoDashBoardExample.zip

Boa noite voce tem esse exemplo ainda pode me enviar

 

Link to comment
Share on other sites

On 1/10/2020 at 10:08 PM, brunomf01 said:

Another thing, how do I align the color of the Caption with the color of the chart?

If I understand you correctly:

  ...
  with UniChart1 do
  begin
    JSInterface.JSAssign('colors', [JSInterface.JSStatement(ColorsStr)]);
    JSInterface.JSCall('chart.series[0].setColors', [JSInterface.JSStatement(ColorsStr)]); //<----------

    //JSInterface.JSCall('chart.series[0].setRenderer', [JSInterface.JSFunction('sprite, record, attributes, index, store',
    //  '    if (record) {'+
    //  '        if ('+ JSName +'.colors[index]) {'+
    //  '            attributes.fill = '+ JSName +'.colors[index];'+
    //  '        }'+
    //  '    }'+
    //  '    return attributes;'
    //)]);
  end;
  ...

 

Link to comment
Share on other sites

5 hours ago, Renato Aquino said:

Another thing is that only the first slice has animation. Is this right?

UniChart1.ClientEvents.ExtEvents -> Ext.chart.PolarChart[chart] -> function chart.redraw:

function chart.redraw(sender, eOpts)
{
    this.series[0].setAnimation(true);
    this.series[0].setHighlight(true);
}

 

Link to comment
Share on other sites

  • 1 year later...
20 minutes ago, Tokay said:

You have soon closed the FSD-692 tiket with resolution Done. I've just download test sample and nothing was changed in version 1.90.0.1545 of UniGUI. Where is possible to find done solution?

Hi,

I reopened the ticket.

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...