private void ChartListBox_SelectedValueChanged(object sender, EventArgs e) { for (int i = 0; i < ChartListBox.Items.Count; i++) { NetworkChart.Series[i].Enabled = ChartListBox.GetItemChecked(i); } // Reset scale based on visible graphs. NetworkChart.ChartAreas["DefaultChartArea"].RecalculateAxesScale(); NetworkChart.ResetAutoValues(); }
private void ChartListBox_SelectedValueChanged(object sender, EventArgs e) { // Save old scroll position double OldPosition = NetworkChart.ChartAreas["DefaultChartArea"].AxisX.ScaleView.Position; for (int i = 0; i < ChartListBox.Items.Count; i++) { NetworkChart.Series[i].Enabled = ChartListBox.GetItemChecked(i); } // Reset scale based on visible graphs. NetworkChart.ChartAreas["DefaultChartArea"].RecalculateAxesScale(); NetworkChart.ResetAutoValues(); // Restore scroll position NetworkChart.ChartAreas["DefaultChartArea"].AxisX.ScaleView.Position = OldPosition; }