Hi,
I'm using the code below to make a smooth pallette indicating the colors on the poinseries...
1) How do I locate the legend to the far right so isn't located on top of the chart, hiding the chart below the legend??
2) How do I control the formating of the text inside the legend? also, the number of digits after the punctuation mark (for instance, 100,0 instead of 99.99)?
3) How do i control it so that only one column of numbers is shown in the legend?
private void Form1_Load(object sender, EventArgs e)
{
NChart chart = (NChart)(nChartControl1.Charts[0]);
chart.Series.Clear();
NPointSeries point1 = (NPointSeries)chart.Series.Add(SeriesType.Point);
point1.Name = "Point 1";
point1.PointShape = PointShape.Bar;
point1.Size = new NLength(15, NGraphicsUnit.Point);
point1.FillStyle = new NColorFillStyle(Color.Red);
point1.BorderStyle.Color = Color.Pink;
point1.DataLabelStyle.Visible = false;
point1.UseXValues = true;
point1.InflateMargins = true;
NLegend legend = new NLegend();
legend.Header.Text = "Agubsa!!";
legend.Mode = LegendMode.Manual;
legend.Data.ExpandMode = LegendExpandMode.VertWrap;
legend.DockMode = PanelDockMode.Right;
legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);
legend.Margins = new NMarginsL(20, 20, 20, 20);
//chart.ChildPanels.Add(legend);
nChartControl1.Panels.Add(legend);
NPalette palette = new NPalette();
int i = 0;
for (i = 0; i <= 10; i++)
{
palette.Add(i*9.99,CoolColorCode(i*9.99));
}
palette.Mode = PaletteMode.Custom;
palette.SmoothPalette = true;
NLegendPaletteCellData m_PaletteCellData;
m_PaletteCellData = new NLegendPaletteCellData(palette, new NRange1DD(0, 100));
legend.Data.Items.Add(m_PaletteCellData);
i = 0;
for (i = 0; i < 10; i++)
{
point1.Values.Add(i);
point1.XValues.Add(i * 10.1);
point1.FillStyles[i] = new NColorFillStyle(CoolColorCode(i*10.1));
}
nChartControl1.Refresh();
}
private Color CoolColorCode(double ColorValue)
{
ColorValue = 100 - ColorValue;
if (ColorValue < 0)
ColorValue = 0;
else if (ColorValue > 100)
ColorValue = 100;
else if (double.IsNaN(ColorValue))
ColorValue = 0;
if (ColorValue < 25)
return Color.FromArgb(255, Convert.ToInt16(ColorValue / 25 * 255), 0);
else if (ColorValue < 50)
return Color.FromArgb(Convert.ToInt16(255 - ((ColorValue - 25) / 25 * 255)), 255, 0);
else if (ColorValue < 75)
return Color.FromArgb(0, 255, Convert.ToInt16((ColorValue - 50) / 25 * 255));
else
return Color.FromArgb(0, Convert.ToInt16(255 - Math.Round((ColorValue - 75) / 25 * 255)), 255);
}