Bernie07 Posted March 29, 2017 Share Posted March 29, 2017 Hello, I'm trying to change the Visible state of the UniChart Legend at Runtime like ChartEinsaetzeStatistik.Legend.Visible := CheckEinsaetzeStatistikLegendeAnzeigen.Checked; But nothing happens. What can I do to Change the Legend Visible state of a Chart at Runtime? Best wishes Bernhard Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 29, 2017 Share Posted March 29, 2017 Hi, Can you try to use this approach for now: ?! 1. In DesignTime: UniChart1 -> Legend -> Visible -> [True] 2. In RunTime, try to use a toggle method. For example: procedure TMainForm.UniFormReady(Sender: TObject); begin with UniChart1.JSInterface do begin JSCall('chart.legend.toggle', [False]); // Hide //JSCall('chart.redraw', []); end; end; ... with UniChart1.JSInterface do begin JSCall('chart.legend.toggle', [True]); // Show JSCall('chart.redraw', []); end; Best regards. Quote Link to comment Share on other sites More sharing options...
Bernie07 Posted March 30, 2017 Author Share Posted March 30, 2017 Thanks for your answer. this works, but the place of the legend isn't reused for the chart, if I make the legend invisible. This means, that the chart isn't drawed bigger. I want that the chart is also using the place of the legend because the legend isn't shown anymore. Is there a way to redraw the chart so it is using also the empty place where was the legend drawn before? My Code is now : if CheckEinsaetzeStatistikLegendeAnzeigen.Checked then begin ChartEinsaetzeStatistik.JSInterface.JSCall('chart.legend.toggle', [true]); ChartEinsaetzeStatistik.JSInterface.JSCall('chart.redraw', []); end else begin ChartEinsaetzeStatistik.JSInterface.JSCall('chart.legend.toggle', [false]); ChartEinsaetzeStatistik.JSInterface.JSCall('chart.redraw', []); end; Best wishes Bernhard Best wishes Bernhard Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 30, 2017 Share Posted March 30, 2017 Hi, Ok, need to analyze. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 30, 2017 Share Posted March 30, 2017 Hi, Can you try this approach ?!: Show: with UniChart1.JSInterface do begin JSCode(#1'.chart.legend.width='#1'.chart.legend.originalWidth;'); JSCall('chart.legend.toggle', [True]); JSCall('chart.redraw', []); end; Hide: with UniChart1.JSInterface do begin JSCode(#1'.chart.legend.originalWidth='#1'.chart.legend.width;'); JSAssign('chart.legend.width', [0]); JSCall('chart.legend.toggle', [False]); JSCall('chart.redraw', []); end; Quote Link to comment Share on other sites More sharing options...
Bernie07 Posted December 4, 2018 Author Share Posted December 4, 2018 Hello, I have now installed the newest version of unigui. And now the function chart.legend.toggle don't work anymore. I get the error "toggle is no function". I have also tried it with JSProperty instead of JSCall, but then nothing happens. The legend is still visible. Can I solve this with another code? Best wishes Bernhard Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 4, 2018 Share Posted December 4, 2018 Hello, Which build have you installed ?! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 4, 2018 Share Posted December 4, 2018 30 minutes ago, Bernie07 said: Can I solve this with another code? Try this: UniChart1.JSInterface.JSCall('chart.legend.setHidden', [True]); 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.