Jump to content

Is It Possible To Hide A Series Of A TUniChart?


Frederick

Recommended Posts

Let's say that I have two TUniBar3DSeries in a TUniChart. Is it possible to hide one of them so that it does not display in the chart? There does not seem to be a Visible property for the series control.

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1549)

 

hideseries.png

Link to comment
Share on other sites

8 hours ago, Frederick said:

Let's say that I have two TUniBar3DSeries in a TUniChart. Is it possible to hide one of them so that it does not display in the chart? There does not seem to be a Visible property for the series control.

Is the following solution acceptable to you?

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  Indx: Byte;
begin
  Indx := chtTran.SeriesList.IndexOf(UniBar3DSeries1);
  if Indx > -1 then
    chtTran.JSInterface.JSCall('chart.legendStore.getAt('+ Indx.ToString() +').set', ['disabled', True]);

end;

procedure TMainForm.UniButton2Click(Sender: TObject);
var
  Indx: Byte;
begin
  Indx := chtTran.SeriesList.IndexOf(UniBar3DSeries1);
  if Indx > -1 then
    chtTran.JSInterface.JSCall('chart.legendStore.getAt('+ Indx.ToString() +').set', ['disabled', False]);

end;

 

Link to comment
Share on other sites

6 hours ago, Sherzod said:

Is the following solution acceptable to you?

The solution is definitely acceptable to me. Thank you.

I had to change the variable declaration from "Byte" to "Integer" though to avoid the following Delphi compiler messages at the "If Indx > -1 then" line.

[dcc64 Warning] Main.pas(1544): W1022 Comparison always evaluates to True
[dcc64 Warning] Main.pas(1544): W1023 Comparing signed and unsigned types - widened both operands

Link to comment
Share on other sites

1 hour ago, Sherzod said:

Hello, 

You can also try to hide the legend completely I think. 

I could but that means the legend for the remaining visible bar is also hidden. Wouldn't it be more logical for the hidden status for the legend apply to the bar series that is/are hidden?

Link to comment
Share on other sites

  • 2 weeks later...
On 6/17/2021 at 7:43 AM, Frederick said:

chart2.zip 7.65 MB · 0 downloads

Hello,

One possible solution, can you try?

1. chtTran - ClientEvents -> UniEvents -> Ext.chart.CartesianChart[chart]

function chart.beforeInit(sender, config)
{
    config.legend = {
        toggleable: false,
        docked: 'right'
    }
}

2. 

procedure TMainForm.cmdHideshowClick(Sender: TObject);
var
  Indx : Integer;
  lHide : Boolean;
begin
  lHide:=TUniButton(Sender).Caption='Hide Max';
  if lHide then
    TUniButton(Sender).Caption:='Show Max'
  else
    TUniButton(Sender).Caption:='Hide Max';
  Indx := chtTran.SeriesList.IndexOf(barMax);
  if Indx > -1 then
  begin
    chtTran.JSInterface.JSCode('if ('#1'.chart.getLegendStore().filters) {'#1'.chart.getLegendStore().filters.clear(); '#1'.chart.refreshLegendStore()};');
    chtTran.JSInterface.JSCall('chart.getLegendStore().getAt('+ Indx.ToString() +').set', ['disabled', lHide]);
    chtTran.JSInterface.JSCode(#1'.chart.getLegendStore().filterBy(function(rec, id) {if(rec.get("disabled") === false){return true}else{return false}});');
  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...