SparklineAxisMinMax.Group not functioning

Posted by: bcroteau on 11 August 2021, 12:50 am EST

    • Post Options:
    • Link

    Posted 11 August 2021, 12:50 am EST - Updated 30 September 2022, 4:17 am EST

    Either SparklineAxisMinMax.Group is not working OR I’ve missed something in my configuration…

    I’ve created sparklines for both rows in this table:

    As you can see from the data, the range of row 1 should be ~-1.3 to 83.5 and row 2 is ~79.8 to 83.5

    When I set both MinAxisType and MaxAxisType to SparklineAxisMinMax.Individual everything works as expected:

    When I set the axis types to SparklineAxisMinMax.Custom and then set the ManualMin and ManualMax to -2 and 100 respectively I also get expected results:

    However when I set to SparklineAxisMinMax.Group I get this:

    I would have expected that my Group variant would have produced sparklines similar to my Manual method where row 2 has a much narrower range (flatter line) however it doesn’t seem to be calculating the range properly (or not applying it). Instead these look identical to the Individual case…

    I have ensured that I’ve properly called SheetView.GroupSparkline() (as evidenced by the fact that the settings are applied properly when changing between Individual and Manual) and I’ve also ensured that I’m setting ManualMin and ManualMax to 0 in the case of both Group and Individual (not clear if this is necessary as the documentation is slightly vague).

    Have I missed something in the configuration to get this working as expected or is this a bug?

    I’m using Spread for WinForms v14.45.20201.0

    Thanks!

    Bill

  • Posted 12 August 2021, 10:09 pm EST

    Hi Bill,

    Have you tried selecting the Sparkline cell to which you are trying to group?

    For example:

    sheet.SetActiveCell(3, 5); // This is the Custom MinMaxAxis Sparkline cell
    
    sheet.GroupSparkline(new CellRange[]
    {
        new CellRange(6, 5, 2, 1) // Cell Range for the Group MinMaxAxis Sparkline cells
    });
    

    The GroupSparkline method groups the given cell range with the last selected Sparkline Group, which is why we need to set it as the active cell.

    Let me know if this does not work for you.

    Regards,

    Jitender

  • Posted 13 August 2021, 12:35 am EST - Updated 30 September 2022, 4:17 am EST

    Hi Jitender,

    Thanks for your reply!

    Your solution kinda solves my problem - by activating a sparkline THEN grouping the OTHER sparklines it achieves the correct common Y-axis range:

    I have a few comments and suggestions however…

    1. By setting an active cell I lose the user’s previous selection
    2. I wind up with an unsightly blue box (I presume that this is the Group)

    To solve #1 I suppose that I could track the active cells before the grouping call then could restore the user’s selection AFTER grouping.

    I haven’t investigated but I presume there’s some way to either ungroup OR hide the blue box?

    Ultimately what I’m trying to achieve is to ensure that all my sparklines (in this example there are only 2 but in my REAL world application there can be hundreds…) share a common Y-axis range. I don’t otherwise wish to annotate the sparklines, highlight them, visually show the group or alter the user’s selection in any way.

    As a work-around I have achieved this by manually tracking overall min/max values and setting a custom range for all sparklines… It’s ugly code but it seems to achieve the expected result.

  • Posted 15 August 2021, 5:58 pm EST

    Hi Bill,

    For (1), you can group Sparklines by using the SparklineContainer. Here, you would explicitly need to specify the Sparkline Group so changing the selection is not required.

    For example:

    sheet.SparklineContainer.GetSparkline(3, 5, out ISparklineGroup group, out _);
    
    sheet.SparklineContainer.GetSparkline(6, 5, out _, out ISparkline sparkline);
    sheet.SparklineContainer.AddSparklineToGroup(sparkline, group);
    

    For (2), currently it’s not possible to hide the Sparkline Group indicator. We will consider this as an enhancement [SPNET-19650].

    Regards,

    Jitender

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels