Permalink
Browse files

Solved issue #8: New series are now shown in the legends even if not …

…refreshed
  • Loading branch information...
1 parent 7cf887d commit 4ac09a319d8fb7e8bb0fe0e1cfec4ddba780a89f @sinairv committed Jan 1, 2012
View
BIN Bin/MSChartWrapper.UI.exe
Binary file not shown.
View
BIN Bin/MSChartWrapper.dll
Binary file not shown.
View
2 MSChartWrapper.UI/FormMain.cs
@@ -6,7 +6,7 @@ namespace MSChartWrapper.UI
{
public partial class FormMain : Form
{
- private const int ArraySize = 10;
+ private const int ArraySize = 20;
private static readonly Random s_rnd = new Random();
private int m_numCharts = 1;
View
18 MSChartWrapper/ChartWrapper.cs
@@ -243,7 +243,7 @@ public bool LegendVisible
{
mainChart.Legends.Add(name);
}
-
+
mainChart.ChartAreas[0].Position.Width = 80.0f;
}
@@ -368,6 +368,10 @@ public void AddColumnPlot<T>(string name, string[] labels, T[] values)
for (int i = 0; i < labels.Length; i++)
curSeries.Points.AddXY(labels[i], values[i]);
+ // this will force the empty legend to show the initial plot
+ if (m_isLegendVisible && m_seriesNames.Count == 1)
+ mainChart.Legends.Add(serName);
+
if (m_seriesNames.Count > 1)
{
AddSideLegend(serName);
@@ -388,6 +392,7 @@ public void AddLinePlot(string name, double[] values)
string serName = name;
Series curSeries = mainChart.Series.Add(serName);
+
curSeries.LegendText = serName;
m_seriesNames.Add(serName);
curSeries.ChartType = SeriesChartType.FastLine;
@@ -426,6 +431,17 @@ public void AddLinePlot(string name, double[] values)
for (int i = 0; i < values.Length; i += markerFreq)
ptSeriesPoints.AddXY(i + 1, values[i]);
}
+ ptSeries.IsVisibleInLegend = true;
+
+ // this will force the empty legend to show the initial plot
+ if (m_isLegendVisible && m_seriesNames.Count == 1)
+ mainChart.Legends.Add(serName);
+ }
+ else
+ {
+ // this will force the empty legend to show the initial plot
+ if (m_isLegendVisible && m_seriesNames.Count == 1)
+ mainChart.Legends.Add(serName);
}
if (m_seriesNames.Count > 1)

0 comments on commit 4ac09a3

Please sign in to comment.