本文整理汇总了C#中System.Windows.Forms.DataVisualization.Charting.Chart.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.Invalidate方法的具体用法?C# Chart.Invalidate怎么用?C# Chart.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataVisualization.Charting.Chart
的用法示例。
在下文中一共展示了Chart.Invalidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPlot
public void AddPlot(List<double> values, string title = "")
{
Chart chart = new Chart();
Series series = new Series();
ChartArea chartArea1 = new ChartArea();
chartArea1.Name = "ChartArea1";
chart.ChartAreas.Add(chartArea1);
series.BorderWidth = 2;
series.BorderDashStyle = ChartDashStyle.Solid;
series.ChartType = SeriesChartType.Line;
series.Color = Color.Green;
for (int i = 0; i < values.Count; i++)
{
series.Points.AddXY(i, values[i]);
}
chart.BorderlineColor = Color.Red;
chart.BorderlineWidth = 1;
chart.Series.Add(series);
chart.Titles.Add(title);
chart.Invalidate();
chart.Palette = ChartColorPalette.Fire;
chartArea1.AxisY.Minimum = values.Min();
chartArea1.AxisY.Maximum = values.Max();
AddChartInRuntime(chart);
}
示例2: RenderChart
private void RenderChart(Chart chart, string chartName)
{
chart.Invalidate();
var path = Path.Combine(_directory, chartName.Replace(":", "-"));
path = Path.ChangeExtension(path, "png");
chart.SaveImage(path, ChartImageFormat.Png);
}
示例3: CreateGraph
//Creating a fun little graph
public static void CreateGraph(YearMap yearMap)
{
//Order the list of keys to get all of the years and find out how many years there were that someone lived in
var orderedList = yearMap.YearVals.Keys.OrderBy(x => x).ToArray();
var numberOfYears = orderedList.Count();
var xvals = new int[numberOfYears];
var yvals = new int[numberOfYears];
for (int i = 0; i < yvals.Length; i++)
{
yvals[i] = yearMap.YearVals[orderedList[i]];
xvals[i] = orderedList[i];
}
var chart = new Chart();
chart.Size = new Size(1000, 1000);
Title title = new Title("Number of people alive each year");
title.Font = new Font("Calibri", 16, System.Drawing.FontStyle.Bold);
chart.Titles.Add(title);
var chartArea = new ChartArea();
chartArea.AxisX.LabelStyle.Font = new Font("Calibri", 8);
chartArea.AxisY.LabelStyle.Font = new Font("Calibri", 8);
chartArea.AxisY.Minimum = 0;
chartArea.AxisX.Minimum = 1900;
chartArea.AxisX.Maximum = 2000;
chartArea.AxisX.Title = "Years";
chartArea.AxisX.TitleFont = new Font("Calibri", 14, System.Drawing.FontStyle.Bold);
chartArea.AxisY.Title = "Number of People Alive";
chartArea.AxisY.TitleFont = new Font("Calibri", 14, System.Drawing.FontStyle.Bold);
chartArea.AxisY.Interval = 1;
chartArea.AxisX.Interval = 5;
chart.ChartAreas.Add(chartArea);
var series = new Series();
series.Name = "Series";
series.ChartType = SeriesChartType.Bar;
chart.Series.Add(series);
chart.Series["Series"].Points.DataBindXY(xvals, yvals);
chart.Invalidate();
chart.SaveImage("../../Output/chart.png", ChartImageFormat.Png);
}
示例4: Main
//.........这里部分代码省略.........
file.Write(" " + trade_list.Last());
file.WriteLine(" " + EC1.Last());
}
*/
/*
//Console.Write(CurrentBar );
Console.Write(row.ItemArray[1]);
Console.Write(" Forecast is:" + _tree.Nearest(coords, MatchCount).Average(x => x.Node.Value));
Console.WriteLine(" True Return is:" + Convert.ToDouble(row.ItemArray[3]) + " ");
*/
//Console.WriteLine(row.ItemArray.Count());
}
}
file.Close();
totalprofit = trade_list.Sum();
mdd = MaxDrawdown(EC1.ToArray());
Console.WriteLine();
Console.WriteLine("trade_list Profit: " + totalprofit );
Console.WriteLine("MDD: " + mdd);
Console.WriteLine("Profit/MDD: " + Math.Round( totalprofit/mdd ,2) );
Console.WriteLine("Trades: " + trade_list.Count );
Console.WriteLine("EC1 Count: " + EC1.Count);
Console.WriteLine( "Total Rows: "+ dt.Rows.Count );
//Console.WriteLine( "Tree Count(Training Count): " + _tree.Count() );
/*
//KDTree<double> _tree2 =
KDTreeNodeCollection<double> kd_nodes;
Dictionary<KDTreeNodeCollection<double> , int> Dict= new Dictionary<KDTreeNodeCollection<double>,int>() ;
foreach (var nodes in _tree2 ){
kd_nodes= _tree.Nearest(nodes.Position , MatchCount) ;
//Console.WriteLine(nodes.Position +" " );
//Console.WriteLine(nodes.GetType() );
if (Dict.ContainsKey( kd_nodes ) )
{
}
else
{
Dict.Add(kd_nodes, 1);
}
}
Console.WriteLine("Dict count:" + Dict.Count );
*/
// EC1 畫圖輸出來觀察 create the chart
var chart = new Chart();
chart.Size = new Size(600, 600);
var chartArea = new ChartArea();
//chartArea.AxisX.LabelStyle.Format = "dd/MMM\nhh:mm";
chartArea.AxisX.Interval = 1;
chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisX.LabelStyle.Font = new Font("Consolas", 8);
chartArea.AxisY.LabelStyle.Font = new Font("Consolas", 8);
chart.ChartAreas.Add(chartArea);
var series = new Series();
series.Name = "Series1";
series.ChartType = SeriesChartType.FastLine;
series.XValueType = ChartValueType.DateTime;
chart.Series.Add(series);
/*
foreach (int i4 in EC1) {
series.Points.AddY(i4 );
} */
foreach (HistoricalStock stock in data)
{
//Console.WriteLine(string.Format("Date={0} High={1} Low={2} Open={3} Close={4}", stock.Date.ToShortDateString() , stock.High, stock.Low, stock.Open, stock.Close) );
//Console.WriteLine(stock.Date.ToShortDateString()+",");
series.Points.AddXY( stock.Date ,stock.Close );
}
// draw!
chart.Invalidate();
// write out a file
chart.SaveImage("c:\\chart.png", ChartImageFormat.Png);
Process.Start(@"c:\\chart.png");
Console.ReadLine();
}
示例5: LoadPieChart
private bool LoadPieChart(Chart pieChart, List<GeoSoft.Plugins.Interpolation.Classes.TempPIEChartData> pieChartData)
{
pieChart.Series.Clear();
pieChart.Palette = ChartColorPalette.Fire;
pieChart.ChartAreas[0].BackColor = Color.Transparent;
Series series1 = new Series
{
Name = "series1",
IsVisibleInLegend = true,
Color = System.Drawing.Color.Green,
ChartType = SeriesChartType.Pie
};
pieChart.Series.Add(series1);
foreach (var item in pieChartData)
{
var p = series1.Points.Add(item.Count);
p.Color = item.Color;
}
pieChart.Invalidate();
panelChart.Controls.Add(pieChart);
Bitmap bmp = new Bitmap(panelChart.Width, panelChart.Height);
pieChart.DrawToBitmap(bmp, panelChart.ClientRectangle);
return true;
}
示例6: ParseStreamIntoChart
public static void ParseStreamIntoChart( NetworkStream NetworkStream, Chart NetworkChart, string ActorFilter, string PropertyFilter, string RPCFilter )
{
var StartTime = DateTime.UtcNow;
NetworkChart.BeginInit();
// Reset existing data.
foreach( var Series in NetworkChart.Series )
{
Series.Points.Clear();
}
NetworkChart.ResetAutoValues();
NetworkChart.Invalidate();
int FrameCounter = 0;
foreach( PartialNetworkStream RawFrame in NetworkStream.Frames )
{
PartialNetworkStream Frame = RawFrame.Filter(ActorFilter,PropertyFilter,RPCFilter);
if( Frame.EndTime == Frame.StartTime )
{
throw new InvalidOperationException();
}
float OneOverDeltaTime = 1 / (Frame.EndTime - Frame.StartTime);
NetworkChart.Series["ActorCount"].Points.AddXY( FrameCounter, Frame.ActorCount );
NetworkChart.Series["ActorCountSec"].Points.AddXY(FrameCounter, Frame.ActorCount * OneOverDeltaTime);
NetworkChart.Series["PropertyCount"].Points.AddXY( FrameCounter, Frame.PropertyCount );
NetworkChart.Series["PropertyCountSec"].Points.AddXY( FrameCounter, Frame.PropertyCount * OneOverDeltaTime );
NetworkChart.Series["PropertySize"].Points.AddXY( FrameCounter, Frame.ReplicatedSizeBits / 8 );
NetworkChart.Series["PropertySizeSec"].Points.AddXY( FrameCounter, Frame.ReplicatedSizeBits / 8 * OneOverDeltaTime );
NetworkChart.Series["RPCCount"].Points.AddXY( FrameCounter, Frame.RPCCount );
NetworkChart.Series["RPCCountSec"].Points.AddXY( FrameCounter, Frame.RPCCount * OneOverDeltaTime );
NetworkChart.Series["RPCSize"].Points.AddXY( FrameCounter, Frame.RPCSizeBits / 8 );
NetworkChart.Series["RPCSizeSec"].Points.AddXY( FrameCounter, Frame.RPCSizeBits / 8 * OneOverDeltaTime );
NetworkChart.Series["SendBunchCount"].Points.AddXY( FrameCounter, Frame.SendBunchCount );
NetworkChart.Series["SendBunchCountSec"].Points.AddXY( FrameCounter, Frame.SendBunchCount * OneOverDeltaTime );
NetworkChart.Series["SendBunchSize"].Points.AddXY( FrameCounter, Frame.SendBunchSizeBits / 8 );
NetworkChart.Series["SendBunchSizeSec"].Points.AddXY( FrameCounter, Frame.SendBunchSizeBits / 8 * OneOverDeltaTime );
NetworkChart.Series["GameSocketSendSize"].Points.AddXY( FrameCounter, Frame.UnrealSocketSize );
NetworkChart.Series["GameSocketSendSizeSec"].Points.AddXY( FrameCounter, Frame.UnrealSocketSize * OneOverDeltaTime );
NetworkChart.Series["GameSocketSendCount"].Points.AddXY( FrameCounter, Frame.UnrealSocketCount );
NetworkChart.Series["GameSocketSendCountSec"].Points.AddXY( FrameCounter, Frame.UnrealSocketCount * OneOverDeltaTime );
NetworkChart.Series["MiscSocketSendSize"].Points.AddXY( FrameCounter, Frame.OtherSocketSize );
NetworkChart.Series["MiscSocketSendSizeSec"].Points.AddXY( FrameCounter, Frame.OtherSocketSize * OneOverDeltaTime );
NetworkChart.Series["MiscSocketSendCount"].Points.AddXY( FrameCounter, Frame.OtherSocketCount );
NetworkChart.Series["MiscSocketSendCountSec"].Points.AddXY( FrameCounter, Frame.OtherSocketCount * OneOverDeltaTime );
int OutgoingBandwidth = Frame.UnrealSocketSize + Frame.OtherSocketSize + NetworkStream.PacketOverhead * (Frame.UnrealSocketCount + Frame.OtherSocketCount);
NetworkChart.Series["OutgoingBandwidthSize"].Points.AddXY( FrameCounter, OutgoingBandwidth );
NetworkChart.Series["OutgoingBandwidthSizeSec"].Points.AddXY( FrameCounter, OutgoingBandwidth * OneOverDeltaTime );
NetworkChart.Series["ActorReplicateTimeInMS"].Points.AddXY(FrameCounter, Frame.ActorReplicateTimeInMS);
if( Frame.NumEvents > 0 )
{
NetworkChart.Series["Events"].Points.AddXY( FrameCounter, 0 );
}
FrameCounter++;
}
NetworkChart.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage,"30","GameSocketSendSizeSec","GameSocketSendSizeAvgSec");
NetworkChart.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage,"30","OutgoingBandwidthSizeSec","OutgoingBandwidthSizeAvgSec");
NetworkChart.ChartAreas["DefaultChartArea"].RecalculateAxesScale();
NetworkChart.EndInit();
Console.WriteLine("Adding data to chart took {0} seconds", (DateTime.UtcNow - StartTime).TotalSeconds);
}
示例7: tsmzoom_Click
private void tsmzoom_Click(object sender, EventArgs e)
{
//this.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
//this.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
Control c = this.Parent;
chartcopy = this;
ZoomedChart frm = new ZoomedChart(this);
frm.WindowState = FormWindowState.Maximized;
frm.ShowDialog();
c.Controls.Add(chartcopy);
chartcopy.Invalidate();
chartcopy.Show();
}
示例8: UpdateChart
private void UpdateChart(Chart c, Series s, History hs)
{
s.Points.Clear();
foreach (var h in hs)
{
s.Points.AddXY(h.Item1.Ticks, h.Item2);
}
c.Invalidate();
}
示例9: addGraphicsPoint
/// <summary>
/// Add graphics point overload method - Series Name instead of Series Num
/// </summary>
/// <param name="CurChart"></param>
/// <param name="serName">Series name</param>
/// <param name="XVal"></param>
/// <param name="YVal"></param>
private void addGraphicsPoint(Chart CurChart, string serName, DateTime XVal, double YVal)
{
//curX=DateTime.Now;
CurChart.Series[serName].Points.AddXY(XVal, YVal);
// Keep a constant number of points by removing them from the left
if (CurChart.Series[serName].Points.Count > maxNumberOfPointsInChart)
{
// Remove data points on the left side
while (CurChart.Series[serName].Points.Count > maxNumberOfPointsInChart)
{
CurChart.Series[serName].Points.RemoveAt(0);
}
// Adjust X axis scale
//CurChart.ChartAreas[0].AxisX.Minimum = curX - maxNumberOfPointsInChart;
//CurChart.ChartAreas[0].AxisX.Maximum = CurChart.ChartAreas[0].AxisX.Minimum + maxNumberOfPointsInChart;
}
// Adjust Y & X axis scale
CurChart.ResetAutoValues();
// Invalidate chart
CurChart.Invalidate();
}
示例10: ParseStreamIntoChart
public static void ParseStreamIntoChart( MainWindow InMainWindow, NetworkStream NetworkStream, Chart NetworkChart, FilterValues InFilterValues )
{
var StartTime = DateTime.UtcNow;
InMainWindow.ShowProgress( true );
// Save old scroll position
double OldPosition = NetworkChart.ChartAreas["DefaultChartArea"].AxisX.ScaleView.Position;
NetworkChart.BeginInit();
// Reset existing data.
for ( int i = 0; i < NetworkChart.Series.Count; i++ )
{
float Percent = ( float )i / ( float )NetworkChart.Series.Count;
InMainWindow.UpdateProgress( ( int )( Percent * 100 ) );
NetworkChart.Series[i].Points.Clear();
}
InMainWindow.ShowProgress( true );
NetworkChart.ResetAutoValues();
NetworkChart.Invalidate();
NetworkChart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;
NetworkChart.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
NetworkChart.ChartAreas[0].AxisX.ScrollBar.Size = 15;
NetworkChart.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.LightGray;
NetworkChart.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = false;
NetworkChart.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
NetworkChart.ChartAreas[0].AxisY.ScrollBar.Size = 15;
NetworkChart.ChartAreas[0].AxisY.ScrollBar.ButtonColor = Color.LightGray;
int FrameCounter = 0;
foreach( PartialNetworkStream RawFrame in NetworkStream.Frames )
{
if ( FrameCounter % 1000 == 0 )
{
float Percent = ( float )FrameCounter / ( float )NetworkStream.Frames.Count;
InMainWindow.UpdateProgress( ( int )( Percent * 100 ) );
}
PartialNetworkStream Frame = RawFrame.Filter( InFilterValues );
if( Frame.EndTime == Frame.StartTime )
{
throw new InvalidOperationException();
}
float OneOverDeltaTime = 1 / (Frame.EndTime - Frame.StartTime);
int OutgoingBandwidth = Frame.UnrealSocketSize + Frame.OtherSocketSize + NetworkStream.PacketOverhead * ( Frame.UnrealSocketCount + Frame.OtherSocketCount );
InMainWindow.AddChartPoint( SeriesType.OutgoingBandwidthSize, FrameCounter, OutgoingBandwidth );
InMainWindow.AddChartPoint( SeriesType.OutgoingBandwidthSizeSec, FrameCounter, OutgoingBandwidth * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.ActorCount, FrameCounter, Frame.ActorCount );
InMainWindow.AddChartPoint( SeriesType.PropertySize, FrameCounter, Frame.ReplicatedSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.PropertySizeSec, FrameCounter, Frame.ReplicatedSizeBits / 8 * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.RPCSize, FrameCounter, Frame.RPCSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.RPCSizeSec, FrameCounter, Frame.RPCSizeBits / 8 * OneOverDeltaTime );
#if true
InMainWindow.AddChartPoint( SeriesType.ActorCountSec, FrameCounter, Frame.ActorCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.PropertyCount, FrameCounter, Frame.PropertyCount );
InMainWindow.AddChartPoint( SeriesType.PropertyCountSec, FrameCounter, Frame.PropertyCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.RPCCount, FrameCounter, Frame.RPCCount );
InMainWindow.AddChartPoint( SeriesType.RPCCountSec, FrameCounter, Frame.RPCCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.ExportBunchCount, FrameCounter, Frame.ExportBunchCount );
InMainWindow.AddChartPoint( SeriesType.ExportBunchSize, FrameCounter, Frame.ExportBunchSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.MustBeMappedGuidsCount, FrameCounter, Frame.MustBeMappedGuidCount / 8 );
InMainWindow.AddChartPoint( SeriesType.MustBeMappedGuidsSize, FrameCounter, Frame.MustBeMappedGuidSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.SendAckCount, FrameCounter, Frame.SendAckCount );
InMainWindow.AddChartPoint( SeriesType.SendAckCountSec, FrameCounter, Frame.SendAckCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.SendAckSize, FrameCounter, Frame.SendAckSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.SendAckSizeSec, FrameCounter, Frame.SendAckSizeBits / 8 * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.ContentBlockHeaderSize, FrameCounter, Frame.ContentBlockHeaderSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.ContentBlockFooterSize, FrameCounter, Frame.ContentBlockFooterSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.PropertyHandleSize, FrameCounter, Frame.PropertyHandleSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.SendBunchCount, FrameCounter, Frame.SendBunchCount );
InMainWindow.AddChartPoint( SeriesType.SendBunchCountSec, FrameCounter, Frame.SendBunchCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.SendBunchSize, FrameCounter, Frame.SendBunchSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.SendBunchSizeSec, FrameCounter, Frame.SendBunchSizeBits / 8 * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.SendBunchHeaderSize, FrameCounter, Frame.SendBunchHeaderSizeBits / 8 );
InMainWindow.AddChartPoint( SeriesType.GameSocketSendSize, FrameCounter, Frame.UnrealSocketSize );
InMainWindow.AddChartPoint( SeriesType.GameSocketSendSizeSec, FrameCounter, Frame.UnrealSocketSize * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.GameSocketSendCount, FrameCounter, Frame.UnrealSocketCount );
InMainWindow.AddChartPoint( SeriesType.GameSocketSendCountSec, FrameCounter, Frame.UnrealSocketCount * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.ActorReplicateTimeInMS, FrameCounter, Frame.ActorReplicateTimeInMS);
#endif
#if false
InMainWindow.AddChartPoint( SeriesType.MiscSocketSendSize, FrameCounter, Frame.OtherSocketSize );
InMainWindow.AddChartPoint( SeriesType.MiscSocketSendSizeSec, FrameCounter, Frame.OtherSocketSize * OneOverDeltaTime );
InMainWindow.AddChartPoint( SeriesType.MiscSocketSendCount, FrameCounter, Frame.OtherSocketCount );
InMainWindow.AddChartPoint( SeriesType.MiscSocketSendCountSec, FrameCounter, Frame.OtherSocketCount * OneOverDeltaTime );
#endif
//.........这里部分代码省略.........
示例11: UpdateChartData
/// <summary>
/// Pre: graph contains a series named "Series1"
/// Adjusts "Series1"
/// </summary>
/// <param name="chart">The chart that needs updating</param>
/// <param name="newDataPoint">The new point that needs to be added to the chart</param>
private void UpdateChartData(Chart chart, double newDataPoint, TimeSpan currentSessionTime)
{
// Update chart
Series series = chart.Series["Series1"];
int point = series.Points.AddXY(Math.Floor(currentSessionTime.TotalSeconds), newDataPoint);
int pointsCounter = series.Points.Count;
chart.ChartAreas[0].AxisX.Minimum = series.Points[0].XValue;
chart.ChartAreas[0].AxisX.Maximum = series.Points[0].XValue + ((double)(60) * (TIME_WINDOW));
chart.Invalidate(); //redraw
// Remove old datapoints
double removeBefore = Math.Floor(currentSessionTime.TotalSeconds - ((60) * (TIME_WINDOW)));
while (series.Points[0].XValue < removeBefore)
{
series.Points.RemoveAt(0);
}
}
示例12: VoltageRangeTest
public void VoltageRangeTest(double ampStart, double ampStop, double ampStep)
{
try
{
functiongenerator.OutputOff();
}
catch (System.ArgumentException)
{
MessageBox.Show("This test is not available without a connection to the signal generator.");
return;
}
double[] fourierHisto;
AdcData data;
Chart voltagechart = new Chart();
Series enobdata;
ResetGui();
filePath += "Nevis14_" + chipNumBox.Text.PadLeft(5, '0') + "/";
filePath += CreateNewDirectory("Volt");
StreamWriter voltagedata = new StreamWriter(filePath + "voltage_data.txt");
// --Chart Formatting--
voltagechart.Size = new Size(690, 595);
voltagechart.ChartAreas.Add(new ChartArea());
voltagechart.ChartAreas[0].AxisX.Title = "Signal Amplitude [V]";
voltagechart.ChartAreas[0].AxisX.Minimum = 0;
voltagechart.ChartAreas[0].AxisX.Maximum = (ampStop - ampStart) / ampStep;
voltagechart.ChartAreas[0].AxisY.Minimum = 9.5;
voltagechart.ChartAreas[0].AxisY.Maximum = 10.5;
voltagechart.ChartAreas[0].AxisY.Title = "ENOB";
enobdata = new Series{
Color = Color.Red,
IsVisibleInLegend = false,
IsXValueIndexed = true,
MarkerStyle = MarkerStyle.Square,
MarkerColor = Color.Red,
MarkerBorderWidth = 0,
ChartArea = chart1.ChartAreas[0].Name,
ChartType = SeriesChartType.Point
};
voltagechart.Series.Add(enobdata);
// End chart formatting
double[] signalhisto;
functiongenerator.SetShape("SIN");
functiongenerator.SetFreq(signalFreq);
for (double amp = ampStart; amp <= ampStop; amp += ampStep)
{
functiongenerator.OutputOn();
TakeData(false);
functiongenerator.OutputOff();
signalhisto = ReadData()[0];
functiongenerator.SetVolt(amp);
fourierHisto = DoFFT(signalhisto);
data = DoQACalculations(fourierHisto, 0);
enobdata.Points.AddXY(amp, data.enob);
voltagedata.WriteLine(string.Format("{0}, {1}", amp, data.enob));
}
voltagedata.Close();
voltagechart.Invalidate();
voltagechart.SaveImage(filePath + "ENOB_vs_amplitude.png", ChartImageFormat.Png);
}
示例13: Test
public void Test(string testSetFile, string outputFile, Chart resultsChart)
{
List<double[]> originalTestValues = LoadTestData(testSetFile);
string resultString = string.Empty;
//klasyfikacja
if (problemType == ProblemType.Classification)
{
resultsChart.Visible = true;
List<Color> colors = new List<Color>() { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Violet, Color.Orange, Color.Beige, Color.Brown };
for (int i = 0; i < outputSize; i++)
{
var serie = new System.Windows.Forms.DataVisualization.Charting.Series
{
Name = ("klasa " + (i + 1)),
Color = colors[i],
ChartType = SeriesChartType.FastPoint
};
resultsChart.Series.Add(serie);
}
for (int j = 0; j < testData.Count; j++)
{
var d = network.Compute(testData[j]);
int cls = 1;
for (int i = 1; i < outputSize; i++)
{
if (d[i] > d[i - 1])
cls++;
}
resultsChart.Series["klasa " + cls].Points.AddXY(originalTestValues[j][0], originalTestValues[j][1]);
resultsChart.Invalidate();
foreach (double val in originalTestValues[j])
resultString += (val + ",");
resultString += (cls + Environment.NewLine);
}
}
else //regresja
{
resultsChart.Visible = true;
var serie = new System.Windows.Forms.DataVisualization.Charting.Series
{
Name = ("regresja"),
Color = Color.Blue,
ChartType = SeriesChartType.FastPoint
};
resultsChart.Series.Add(serie);
double minVal = (activationFunType == ActivationFunctionType.Bipolar) ? -1.0 : 0.0;
double maxVal = 1.0;
double normSize = (maxVal - minVal) * normParam;
for (int j = 0; j < testData.Count; j++)
{
var res = network.Compute(testData[j])[0];
//denormalizacja
double dSize = idealMax[0] - idealMin[0];
res = idealMin[0] + ((res - minVal) * dSize / normSize);
resultsChart.Series["regresja"].Points.AddXY(originalTestValues[j][0], res);
resultsChart.Invalidate();
foreach (double val in originalTestValues[j])
resultString += (val + ",");
resultString += (res + Environment.NewLine);
}
}
using (StreamWriter outfile = new StreamWriter(outputFile))
{
outfile.Write(resultString);
}
}
示例14: ChargeGraphique
/// <summary>
/// charge le graphique, définit les parts du cammembert et le nom des catégories
/// </summary>
/// <param name="motif">Crédit ou Débit</param>
/// <param name="zone">Panel dans lequel le graphique sera affiché</param>
/// <param name="cammembert">Chart</param>
void ChargeGraphique(string motif, Panel zone, Chart cammembert)
{
//supprime toutes les parts du cammembert
cammembert.Series.Clear();
switch (PaletteStyle)
{
case "Bright":
cammembert.Palette = ChartColorPalette.Bright;
break;
case "Grayscale":
cammembert.Palette = ChartColorPalette.Grayscale;
break;
case "Excel":
cammembert.Palette = ChartColorPalette.Excel;
break;
case "Light":
cammembert.Palette = ChartColorPalette.Light;
break;
case "Pastel":
cammembert.Palette = ChartColorPalette.Pastel;
break;
case "EarthTones":
cammembert.Palette = ChartColorPalette.EarthTones;
break;
case "SemiTransparent":
cammembert.Palette = ChartColorPalette.SemiTransparent;
break;
case "Berry":
cammembert.Palette = ChartColorPalette.Berry;
break;
case "Chocolate":
cammembert.Palette = ChartColorPalette.Chocolate;
break;
case "Fire":
cammembert.Palette = ChartColorPalette.Fire;
break;
case "SeaGreen":
cammembert.Palette = ChartColorPalette.SeaGreen;
break;
case "BrightPastel":
cammembert.Palette = ChartColorPalette.BrightPastel;
break;
default:
cammembert.Palette = ChartColorPalette.Excel;
break;
}
cammembert.BackColor = BackColor;
//titre du graphique
cammembert.Titles.Add("Etat des " + motif);
cammembert.ChartAreas[0].BackColor = Color.Transparent;
//crée la serie
Series series1 = new Series
{
Name = motif,
IsVisibleInLegend = true,
Color = System.Drawing.Color.Blue,
ChartType = SeriesChartType.Pie
};
cammembert.Series.Add(series1);
string[,] maserie = RecupereInfo(motif);
for (int i = 0; i < maserie.Length / 2; i++)
{
series1.Points.Add(System.Convert.ToDouble(maserie[i, 1]));
var point = series1.Points[i];
if (System.Convert.ToDouble(maserie[i, 1]) > 0)
{
point.AxisLabel = maserie[i, 1];
}
point.LegendText = maserie[i, 0];
}
cammembert.Invalidate();
zone.Controls.Add(cammembert);
}
示例15: DesignChart
private void DesignChart(Chart chart1)
{
//
// chart1
//
chart1.BackColor = System.Drawing.Color.WhiteSmoke;
chart1.BackSecondaryColor = System.Drawing.Color.White;
chart1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.DiagonalLeft;
chart1.BorderlineColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
chart1.BorderSkin.BackColor = System.Drawing.Color.CornflowerBlue;
chart1.BorderSkin.BackSecondaryColor = System.Drawing.Color.CornflowerBlue;
chart1.BorderSkin.PageColor = System.Drawing.SystemColors.Control;
chart1.BorderSkin.SkinStyle = System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.Emboss;
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisX.MinorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisX2.MajorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisX2.MinorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisY.MinorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisY2.MajorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].AxisY2.MinorGrid.LineColor = System.Drawing.Color.Silver;
chart1.ChartAreas[0].BackColor = System.Drawing.Color.White;
chart1.ChartAreas[0].BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
chart1.ChartAreas[0].BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
chart1.ChartAreas[0].ShadowOffset = 2;
chart1.Invalidate();
}