Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to hide select series from legend in HTML5 charts?


    nbochenko
    • Features: Charts Version: v5.0 Product: iReport Designer

    Q: Legend settings for selected series should be hidden based on a parameter selection. How should we achieve that?

    [toc on_off::hide=1]

    A: You can use a series property contributor that sets the showInLegend for each series.

    The solution is rather convoluted because series contributors can only access bucket and measure values and cannot directly reference dataset values such as parameters. For that reason a dummy column level is required to make the values available for the chart.

    For example:

    <dataaxis axis="Columns">
        <axislevel name="root">
            <labelexpression>"root"</labelexpression>
            <axislevelbucket>
                <bucketexpression>""</bucketexpression>
         <bucketproperty name="showCategory1">
                    ($P{showSeries}.indexOf("All") != -1)
                     || ($P{showSeries}.indexOf("Category1") != -1)
                </bucketproperty>
                <bucketproperty name="showCategory2">
                    ($P{showSeries}.indexOf("All") != -1)
                     || ($P{showSeries}.indexOf("Category2") != -1)
                </bucketproperty>
                <bucketproperty name="showCategory3">
                    ($P{showSeries}.indexOf("All") != -1)
                     || ($P{showSeries}.indexOf("Category3") != -1)
                </bucketproperty>
            </axislevelbucket>
        </axislevel>
    </dataaxis>
    

    and

    <hc:series name="Category1">
        <hc:contributor name="SeriesProperty">
            <hc:contributorproperty name="showInLegend" value="root.showCategory1" valuetype="Bucket" />
        </hc:contributor>
    </hc:series>
    <hc:series name="Category2">
        <hc:contributor name="SeriesProperty">
            <hc:contributorproperty name="showInLegend" value="root.showCategory2" valuetype="Bucket" />
        </hc:contributor>
    </hc:series>
    <hc:series name="Category3">
        <hc:contributor name="SeriesProperty">
            <hc:contributorproperty name="showInLegend" value="root.showCategory3" valuetype="Bucket" />
        </hc:contributor>
    </hc:series>
    

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...