7 Replies Latest reply on Feb 22, 2007 5:44 AM by Arthur@aginova

    SHOW / HIDE -  line series using checkbox

    Arthur@aginova Level 1
      how do i show & hide a line series based on checkboxes?
      tried applying series id- doesn't seem to work!
      Any Body!
        • 1. Re: SHOW / HIDE -  line series using checkbox
          rexralph
          Try the following

          if your line series is

          <LineSeries id="id1"......

          In your action script, try writing

          "id1.visible = true;" to make it visible.
          Set it to false to hide it.
          • 2. Re: SHOW / HIDE -  line series using checkbox
            rexralph Level 1
            By the way, i forgot to mention.

            try using click event in check box.

            You can set the property in the following way.

            click="handleSeries(event)"
            • 3. Re: SHOW / HIDE -  line series using checkbox
              Arthur@aginova Level 1
              Hi Rexralph,
              i create dynamic line series & tried this

              ls= new LineSeries();
              ls.dataProvider=dp
              var stroke:Stroke = new Stroke()
              ls.yField=yField
              ls.xField="ts"
              ls.visible=false
              ls.id="1" // 2,3, so on

              but it does not show / hide when i tried

              any help! Thanks

              series.push(ls);
              • 4. Re: SHOW / HIDE -  line series using checkbox
                Oddsy Level 1
                I just noticed that last line in your post "series.push(ls);"

                If that is how you are adding the series then it won't work because Arrays don't dispatch any events when they are updated. The best way to do it is:

                var temp:Array = series;
                temp.push(ls);
                series = temp;

                Assigning a new value to the series property will ensure the change is noticed.
                • 5. Re: SHOW / HIDE -  line series using checkbox
                  Arthur@aginova Level 1
                  Hi Oddsy
                  Sorry, a typo, below is the correct code:

                  ls= new LineSeries();
                  ls.dataProvider=dp
                  var stroke:Stroke = new Stroke()
                  ls.yField=yField
                  ls.xField="ts"
                  ls.visible=false
                  ls.id="1" // 2,3, so on
                  series.push(ls);

                  by adding this, will it help me achieve show / hide:

                  var temp:Array = series;
                  temp.push(ls);
                  series = temp;
                  • 6. Re: SHOW / HIDE -  line series using checkbox
                    Oddsy Level 1
                    if you replace

                    series.push(ls);

                    with

                    var temp:Array = series;
                    temp.push(ls);
                    series = temp;

                    Then your chart will be updated with the new series data.

                    To actually show/hide a series with a checkbox, if you have a reference to the series you can just set the visibility using the checkbox's click.
                    • 7. SHOW / HIDE -  line series using checkbox
                      Arthur@aginova Level 1
                      thanks that worked oddsy,
                      now im facing problem to show the hidden series through actionscript
                      im doing something like this:
                      while generation i hide the series
                      pasting the function for reference:
                      public function addSeries(series:Array, yField:String, id:String, color:uint,dp:ArrayCollection,vis:Boolean):void
                      {

                      var ls:LineSeries= new LineSeries();
                      var stroke:Stroke = new Stroke()
                      ls.yField = yField;
                      ls.xField="ts"
                      ls.dataProvider=dp
                      stroke.color = color;
                      stroke.weight = 1.5;
                      ls.setStyle("lineStroke", stroke);
                      ls.alpha=.8
                      ls.visible=vis
                      ls.id=id
                      var temp:Array = series;
                      temp.push(ls);
                      series = temp;
                      mychart.series = series;

                      }

                      thru action script i try this : if checkbox selected do - > mychart.series[0].visible=true , mychart.series[1].visible=true....so on

                      but it doesn't show the series! what shud i do?