Frederick Posted June 16, 2021 Share Posted June 16, 2021 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) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 16, 2021 Share Posted June 16, 2021 Hello, We will check. Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 16, 2021 Author Share Posted June 16, 2021 Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 16, 2021 Share Posted June 16, 2021 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; Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 16, 2021 Author Share Posted June 16, 2021 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 Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 16, 2021 Author Share Posted June 16, 2021 One thing though, although I can hide the series, its title still appears as a legend in the chart. How do I hide that as well? Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 17, 2021 Author Share Posted June 17, 2021 Here is the testcase and a screenshot of the legend that should be hidden when the bar itself is hidden. chart2.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 17, 2021 Share Posted June 17, 2021 Hello, You can also try to hide the legend completely I think. Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 17, 2021 Author Share Posted June 17, 2021 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? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 18, 2021 Share Posted June 18, 2021 On 6/17/2021 at 10:54 AM, Frederick said: Wouldn't it be more logical for the hidden status for the legend apply to the bar series that is/are hidden? By design, this is not the case. Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 18, 2021 Author Share Posted June 18, 2021 2 hours ago, Sherzod said: By design, this is not the case. Would it be possible then, to delete a series of a TUniChart instead of hiding it? Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 21, 2021 Author Share Posted June 21, 2021 I was doing more research on hiding legends for individual series and Sencha has a property called showInLegend (https://docs.sencha.com/extjs/6.2.0/modern/Ext.chart.series.Series.html#cfg-showInLegend) that appears to do what I need. How do I get it to work in UniGUI? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 21, 2021 Share Posted June 21, 2021 Hello, I will check. Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 21, 2021 Author Share Posted June 21, 2021 Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 30, 2021 Share Posted June 30, 2021 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; Quote Link to comment Share on other sites More sharing options...
Frederick Posted June 30, 2021 Author Share Posted June 30, 2021 Thank you. This works as expected. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.