Book a Demo

Author Topic: [Script] Toggle on/off a legend  (Read 7035 times)

iri

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
[Script] Toggle on/off a legend
« on: December 05, 2019, 12:05:04 am »
Hello,

I'm generating a document by scripting, but there is a diagram that I want to show a diagram twice, once with the legend toggled on and one with a the legend toggle off, but I don't find a way to to it by script.
Is it possible?

Thanks  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #1 on: December 05, 2019, 04:25:15 am »
I don't know of a way to toggle visibility of any diagram elements. You would need to remove it from the diagram, save it and restore the element (by adding a diagram element with the same location and attributes). Than can be done by scripting but I have no idea about EA's doc generator.

q.

iri

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #2 on: December 05, 2019, 09:57:43 pm »
It's not really to toggle the visibility of an element; but to toggle the "Apply auto Color" of the legend element that you can place on a diagram.

But anyway I think that with what you said, I think it's a possible way to achieve almost what I want so thanks.

But if anyone have another idea on how the still have the legend element on the diagram but just to toggle the "Apply auto color" of it.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #3 on: December 06, 2019, 12:54:52 am »
I know how to do that. Will reply later (currently not at home).

q.

iri

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #4 on: December 06, 2019, 06:27:12 pm »
Ok thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #5 on: December 06, 2019, 07:59:58 pm »
Back again. So here's what you need to do. The EAElement for the legend contains some string in its StyleEx property where you have to look for LegendOpts=<n>; where <n> is a decimal number. Looking at the binary presentation you have to turn on/off the MSB to en-/disable the Apply auto color. E.g. if it contains 63 you have to replace it by 31 (so it would be LegendOpts=31;)

q.

iri

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: [Script] Toggle on/off a legend
« Reply #6 on: December 06, 2019, 08:45:01 pm »
Thank you really much!
It works perfectly :)