datavisualization - Audiometric chart

Jun 18 2015 3:36 AM
Hello,
 
i need to build an Audiometric chart like this in c# .net 4
 
x values are: 125, 500, 1000, 2000, 4000, 8000
 
Consider that the series can have intermediate values, example 750, 3000, 6000.
 
i tried to use Datavisualization library, i suppose that values are logarithmic but I could not find the correct values.
 
 here's the code
 
 public MemoryStream DrawChart(double baseValue)
{
Chart chart = new Chart
{
Palette = ChartColorPalette.EarthTones,
Width = 1200,
Height = 800,
ForeColor = Color.Black,
BackColor = Color.White,
BorderlineDashStyle = ChartDashStyle.Solid,
BackSecondaryColor = Color.White,
BackGradientStyle = GradientStyle.None,
BorderWidth = 0
};

Series series = new Series("Right")
{
Color = Color.Red,
LabelForeColor = Color.Black,
ChartType = SeriesChartType.Line,
IsValueShownAsLabel = false,
XValueType = ChartValueType.Int32,
YValueType = ChartValueType.Int32,
MarkerStyle = MarkerStyle.None,
// gestione doppio asse x o asse y
XAxisType = AxisType.Primary,
YAxisType = AxisType.Primary,
};

// rende la linea più spessa e più visibile
series.BorderWidth = 6;
series.SmartLabelStyle.Enabled = true;
/*
* valori dell'orecchio destro
*/
series.Points.AddXY(125, 0);
series.Points.AddXY(250, 0);

series.Points.AddXY(500, 10);
series.Points.AddXY(1000, 120);
series.Points.AddXY(2000, 10);
series.Points.AddXY(3000, 0);
series.Points.AddXY(4000, 10);
series.Points.AddXY(6000, 10);
series.Points.AddXY(8000, 20);

chart.Series.Add(series);

//Aggiungo un'area di visualizzazione del grafico corrente
ChartArea area = new ChartArea("Default")
{
BorderDashStyle = ChartDashStyle.Solid,
BackSecondaryColor = Color.White,
ShadowColor = Color.Transparent,
BackGradientStyle = GradientStyle.TopBottom,
BackColor = Color.Transparent,
};

area.AxisY.Minimum = -10;
area.AxisY.Maximum = 120;
area.AxisY.IsReversed = true;
area.AxisY.Interval = 10;
//area.AxisY.Crossing = double.MaxValue;

//area.AxisX.Minimum = 200;
//area.AxisX.Maximum = 9000;
//area.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;

area.AxisX.IsLogarithmic = true;
//area.AxisX.Interval = 250;
area.AxisX.IntervalType = DateTimeIntervalType.Number;
area.AxisX.IntervalOffset = 0;
area.AxisX.IntervalOffsetType = DateTimeIntervalType.Auto;
area.AxisX.LogarithmBase = baseValue;

//area.AxisX.Interval = 1;
//area.AxisX.IsReversed = true;
//area.AxisX.MinorTickMark.Interval = 1;
//area.AxisX.MinorGrid.Interval = 1;
//area.AxisX.MinorGrid.Enabled = true;
//area.AxisX.MinorTickMark.Enabled = true;

//area.AxisX.CustomLabels.Add(0, 250, "250");
//area.AxisX.CustomLabels[0].GridTicks = GridTickTypes.All;

//area.AxisX.CustomLabels.Add(250, 500, "500");
//area.AxisX.CustomLabels[1].GridTicks = GridTickTypes.TickMark;

//area.AxisX.CustomLabels.Add(500, 1000, "1000");
//area.AxisX.CustomLabels[2].GridTicks = GridTickTypes.All;

//area.AxisX.CustomLabels.Add(1000, 2000, "2000");
//area.AxisX.CustomLabels[3].GridTicks = GridTickTypes.TickMark;

//area.AxisX.CustomLabels.Add(2000, 4000, "4000");
//area.AxisX.CustomLabels[4].GridTicks = GridTickTypes.All;

//area.AxisX.CustomLabels.Add(4000, 8000, "8000");
//area.AxisX.CustomLabels[3].GridTicks = GridTickTypes.TickMark;

//area.AxisX.CustomLabels.Add(8000, 16000, "16000");
//area.AxisX.CustomLabels[3].GridTicks = GridTickTypes.All;

Title titleObj = new Title
{
ForeColor = Color.Black,
Text = "Audiometry",
};

if (area.AxisX.IsLogarithmic)
{
titleObj.Text += " logarithmic base " + area.AxisX.LogarithmBase;
}

chart.ChartAreas.Add(area);
chart.Titles.Add(titleObj);

chart.AntiAliasing = AntiAliasingStyles.All;
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;

//Istanzio un memorystream che sarà utilizzato per la renderizzazione
MemoryStream stream = new MemoryStream();
//Eseguo il salvataggio dell'immagine del grafico nello stream
chart.SaveImage(stream, ChartImageFormat.Png);

//Riporto il cursore all'inizio dello stream
stream.Seek(0, SeekOrigin.Begin);

return stream;
}
 
 
heeeeelp!