jeudi 31 décembre 2020

How to Show a Series in a Chart if a Checkbox is Checked, How to Hide a Series if a Checkbox is Unchecked (VB.NET)

I have a chart that displays different data based on which user is using the program. In their interface, they can only see the series that includes their information in the chart TotalCompletedDetailsCHRT. They cannot see anyone else's information.

The exception to this general practice is the Detailing Lead. They will have access to see everyone else's information. Currently I have a checkbox that toggles the detailing lead view (which just hides one groupbox and shows another). Below is a screenshot of the checkbox, as well as it's code. enter image description here

For reference, "DetailingLead" is a username.

Private Sub AdminViewDetailingLead() Handles DetailingLeadViewCHKB.CheckedChanged

        If DetailingLead AndAlso DetailingLeadViewCHKB.Checked = True Then
            CareerCompletedDetailsGRPB.Visible = False
            DetailLeadGRPB.Visible = True
            DetailLeadGRPB.Location = New Point(611, 409)
        ElseIf DetailingLead AndAlso DetailingLeadViewCHKB.Checked = False Then
            CareerCompletedDetailsGRPB.Visible = True
            DetailLeadGRPB.Visible = False
        End If
    End Sub

This code successfully hides the unneeded groupbox, and displays the DetailingLead's Groupbox. The interface now looks like this: enter image description here

My problem is that even whenever the checkboxes are checked, I can only see the series/information associated with my username, not the other's. Below is the code I have for the checkboxes' logic.

Private Sub AdminViewTotalDetailsCHRT() Handles MyBase.Load

        If UserName = DetailingLead AndAlso BDStatsCHKB.Checked = True Then

            TotalCompletedDetailsCHRT.Series(1).Enabled = True
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Maximum = 12
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Interval = 1
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Maximum = 1000
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Interval = 50
        End If
        If UserName = DetailingLead AndAlso KBStatsCHKB.Checked = True Then

            TotalCompletedDetailsCHRT.Series(2).Enabled = True
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Maximum = 12
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Interval = 1
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Maximum = 1000
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Interval = 50
        End If
        If UserName = DetailingLead AndAlso MVStatsCHKB.Checked = True Then

            TotalCompletedDetailsCHRT.Series(0).Enabled = True
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Maximum = 12
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisX.Interval = 1
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Minimum = 0.0
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Maximum = 1000
            TotalCompletedDetailsCHRT.ChartAreas(0).AxisY.Interval = 50
        End If
    End Sub

Does anyone have any idea of to why the other series' wouldn't be displaying? Thanks for the input.




Aucun commentaire:

Enregistrer un commentaire