本文整理汇总了C#中SeriesCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SeriesCollection.Add方法的具体用法?C# SeriesCollection.Add怎么用?C# SeriesCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SeriesCollection
的用法示例。
在下文中一共展示了SeriesCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicLine
public BasicLine()
{
InitializeComponent();
//we create a new SeriesCollection
Series = new SeriesCollection();
//create some LineSeries
var charlesSeries = new LineSeries
{
Title = "Charles",
Values = new ChartValues<double> {10, 5, 7, 5, 7, 8}
};
var jamesSeries = new LineSeries
{
Title = "James",
Values = new ChartValues<double> { 5, 6, 9, 10, 11, 9 }
};
//add our series to our SeriesCollection
Series.Add(charlesSeries);
Series.Add(jamesSeries);
//that's it, LiveCharts is ready and listening for your data changes.
DataContext = this;
}
示例2: ComboHorizontal
public static void ComboHorizontal(dotnetCHARTING.Chart chart, int width, int height, string title, DataTable table, string xColumn, string yColumn)
{
SeriesCollection SC = new SeriesCollection();
Series s = new Series();
foreach (DataRow row in table.Rows)
{
string telType = row[xColumn].ToString();
Element e = new Element();
e.Name = telType;
e.LabelTemplate = "%PercentOfTotal";
e.YValue = Convert.ToDouble(row[yColumn].ToString());
s.Elements.Add(e);
}
SC.Add(s);
chart.TempDirectory = "temp";
chart.Use3D = false;
chart.DefaultAxis.Interval = 10;
chart.DefaultAxis.CultureName = "zh-CN";
chart.Palette = new Color[] { Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), Color.FromArgb(255, 99, 49), Color.FromArgb(0, 156, 255) };
chart.DefaultElement.SmartLabel.AutoWrap = true;
chart.Type = ChartType.ComboHorizontal;
chart.Size = width + "x" + height;
chart.DefaultElement.SmartLabel.Text = "";
chart.Title = title;
chart.DefaultElement.ShowValue = true;
chart.PieLabelMode = PieLabelMode.Outside;
chart.ShadingEffectMode = ShadingEffectMode.Three;
chart.NoDataLabel.Text = "û��������ʾ";
chart.SeriesCollection.Add(SC);
}
示例3: FilterChart
public FilterChart()
{
InitializeComponent();
//create a configuration for City class
var config = new SeriesConfiguration<City>()
.Y(city => city.Population); // use Population an Y
// X will use default config, a zero based index
//create a series collection with this config
Series = new SeriesCollection(config);
//lets pull some initials results
var results = DataBase.Cities.OrderByDescending(city => city.Population).Take(15).ToArray();
PopulationSeries = new BarSeries
{
Title = "Population by city 2015",
Values = results.AsChartValues(),
DataLabels = true
};
//there are 2 types of labels, when we use a formatter, and a strong array mapping
//in this case instead of a label formatter we use a strong array labels
//since X is a zero based index LiveCharts automatically maps this array with X
//so when X = 0 label will be labels[0], when X = 1 labels[1], X = 2 labels[2], X = n labels[n]
Labels = results.Select(city => city.Name).ToArray();
Series.Add(PopulationSeries);
DataContext = this;
}
示例4: BasicLineExample
public BasicLineExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new LineSeries
{
Title = "Series 1",
Values = new ChartValues<double> { 4, 6, 5, 2 ,7 }
},
new LineSeries
{
Title = "Series 2",
Values = new ChartValues<double> { 6, 7, 3, 4 ,6 }
}
};
Labels = new[] {"Jan", "Feb", "Mar", "Apr", "May"};
YFormatter = value => value.ToString("C");
//modifying the series collection will animate and update the chart
SeriesCollection.Add(new LineSeries
{
Values = new ChartValues<double> {5, 3, 2, 4},
LineSmoothness = 0 //straight lines, 1 really smooth lines
});
//modifying any series values will also animate and update the chart
SeriesCollection[2].Values.Add(5d);
DataContext = this;
}
示例5: HighPerformanceLine
public HighPerformanceLine()
{
InitializeComponent();
//First you need to install LiveCharts.Optimizations
//from Nuget:
//Install-Package LiveCharts.Optimizations
//LiveCharts.Optimization contains a class called ChartOptimizations where you can find
//algorithms according to your chart type, they also have a good description, indicating
//which is the best according to your case, using a wrong algorithm could not display data
//to an optimized quality.
//var algorithm = ChartOptimizations.Lines.RegularX<double>()
// // low quality is the default, but it is really accurate, it could fail only for +-3 pixels
// .WithQuality(DataQuality.Low);
//create a configuration in this case we will use X as a zero based index,
//and Y as the stored value in Series.Values
//we will also attach the algorithm we just selected.
var config = new SeriesConfiguration<double>()
.X((val, index) => index)
.Y(val => val);
//.HasHighPerformanceMethod(algorithm);
//create a SeriesCollection with this configuration
Series = new SeriesCollection(config);
//create a new line series
var line = new LineSeries {Values = new ChartValues<double>()};
//add some random values to test
var r = new Random();
var trend = 0d;
for (var i = 0; i < 1000000; i++)
{
if (i%1000 == 0) trend += r.Next(-500, 500);
line.Values.Add(trend + r.Next(-10, 10));
}
Series.Add(line);
//some format
var now = DateTime.Now.ToOADate();
XFormat = val => DateTime.FromOADate(now + val/100).ToShortDateString();
YFormat = val => Math.Round(val) + " ms";
//set zooming if needed.
ZoomingMode = ZoomingOptions.XY;
DataContext = this;
}
示例6: FillData
/// <summary>метод который формирует данные для chart-а на основе колекции серий,
/// поинтов и их пересечений </summary>
private SeriesCollection FillData(
Dictionary<string, float> seriesDef,
Dictionary<string, float> pointDef,
Dictionary<Intersection, float> intersections)
{
SeriesCollection result = new SeriesCollection();
if (!subDiagramMode)
{
switch (this.DiagramType)
{
case DiagramTypeEnum.Graph:
result.Add(CreateDataForFullDiagram(seriesDef, pointDef, intersections, true));
break;
case DiagramTypeEnum.ColumnDetail:
result.Add(CreateDataForFullDiagram(seriesDef, pointDef, intersections, false));
break;
case DiagramTypeEnum.ColumnGeneral:
result.Add(CreateDataForColumnGeneral(seriesDef));
break;
case DiagramTypeEnum.PieGeneral:
result.Add(CreateDataForPieGeneral(seriesDef));
break;
case DiagramTypeEnum.Speedometer:
case DiagramTypeEnum.TrafficLight:
if (seriesDef.Any( s => s.Key.Equals(defaultSeries)))
result.Add(FillSeriesData(seriesDef.First(s => s.Key.Equals(defaultSeries))));
break;
case DiagramTypeEnum.PieDetail:
if (seriesDef.Any(s => s.Key.Equals(defaultSeries)))
result.Add(FillPointsData(seriesDef.First(s => s.Key.Equals(defaultSeries)),
pointDef, intersections, false));
break;
}
}
else
{
if (string.IsNullOrEmpty(detalizedSeriesName)) detalizedSeriesName = this.defaultSeries;
if (seriesDef.Any(s => s.Key.Equals(detalizedSeriesName)))
{
switch (this.SubDiagramType)
{
case SubDiagramTypeEnum.Graph:
case SubDiagramTypeEnum.ColumnDetail:
case SubDiagramTypeEnum.PieDetail:
result.Add(FillPointsData(seriesDef.First(s => s.Key.Equals(detalizedSeriesName)),
pointDef, intersections, false));
break;
}
}
}
FillEmptyVisibleSeries(seriesDef.Keys.ToList());
return result;
}
示例7: AutoSeriesColors
public void AutoSeriesColors()
{
var testguy = new CartesianChart();
testguy.MockIt(new CoreSize(200, 200));
var seriesCollection = new SeriesCollection();
for (var i = 0; i < 100; i++)
{
seriesCollection.Add(new LineSeries {Values = new ChartValues<double> {1, 2, 3}});
}
testguy.Series = seriesCollection;
}
示例8: BasicLine
public BasicLine()
{
InitializeComponent();
Series = new SeriesCollection();
var charlesSeries = new LineSeries
{
Title = "Charles",
Values = new ChartValues<double> {10, 5, 7, 5, 7, 8}
};
var jamesSeries = new LineSeries
{
Title = "James",
Values = new ChartValues<double> {5, 6, 9, 10, 11, 9}
};
Series.Add(charlesSeries);
Series.Add(jamesSeries);
DataContext = this;
}
示例9: PointPropertyChangedBar
public PointPropertyChangedBar()
{
InitializeComponent();
StoresCollection = new SeriesCollection(new SeriesConfiguration<StoreViewModel>().Y(y => y.Income));
StoresCollection.Add(new BarSeries
{
Title = "Apple Store",
Values = new ChartValues<StoreViewModel>
{
new StoreViewModel {Income = 15, Collection = StoresCollection}
}
});
StoresCollection.Add(new BarSeries
{
Title = "Google Play",
Values = new ChartValues<StoreViewModel>
{
new StoreViewModel {Income = 5, Collection = StoresCollection}
}
});
DataContext = this;
}
示例10: load
private SeriesCollection load(ObservableCollection<Model> tmpCollection)
{
ObservableCollection<Model> Collection;
SeriesCollection LineSeries;
LineSeries = new SeriesCollection();
Collection = new ObservableCollection<Model>();
//readClimateAnomaly(Collection);
Collection = tmpCollection;
LineSeries Series1 = new LineSeries();
Series1.XPath = "XData";
Series1.YPath = "YValue";
Series1.PointsSource = Collection;
LineSeries.Add(Series1);
return LineSeries;
}
示例11: BuildBurndownChart
public static ChartViewModel BuildBurndownChart(Iteration iteration, List<Assignable> tasks)
{
SeriesCollection sc;
Series s;
sc = new SeriesCollection();
s = new Series();
s.Name = "Effort";
s.Type = SeriesType.Bar;
//s.DefaultElement.ShowValue = true;
for (var day = iteration.StartDate.Date; day.Date <= iteration.EndDate.AddDays(1).Date; day = day.AddDays(1))
{
var remainingTime = 0.0;
//Do not show values for future dates.
if (day <= DateTime.Today.AddDays(1))
{
foreach (var task in tasks)
{
if (task.Times.Items.Count == 0)
{
remainingTime += task.Effort;
}
else
{
//NOTE: The Remain property on a Time object represents only the remaining time for that role (ie/ developer/qa) so we can't use it here.
var timeSpent = task.Times.Items.Where(t => t.Date.Date < day).Sum(t => t.Spent);
remainingTime += task.Effort - timeSpent;
}
}
}
s.AddElements(new Element(day.ToShortDateString(), remainingTime));
}
sc.Add(s);
var chart = InitializeBarGraph(sc, "Time Remaining");
return new ChartViewModel
{
ImageFileName = string.Format("{0:s}/{1:s}.png", chart.TempDirectory, chart.FileName)
};
}
示例12: EmployeesHiredAndDismissedViewModel
public EmployeesHiredAndDismissedViewModel()
{
SeriesCollection = new SeriesCollection
{
new ColumnSeries
{
Title = "Contratados",
Values = new ChartValues<double> { 8, 10, 12, 10, 13, 18, 14, 16, 19, 21, 18, 17 }
}
};
SeriesCollection.Add(new ColumnSeries
{
Title = "Despedidos",
Values = new ChartValues<double> { 8, 10, 12, 10, 13, 18, 14, 16, 19, 21, 18, 17 }
});
Labels = new[] { "Ago", "Sep", "Oct", "Nov", "Dic", "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul" };
}
示例13: backgroundWorker1_DoWork
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
SeriesCollection sc = new SeriesCollection();
foreach (object o in ethnicities)
{
if (o is EthnicityFrequency.EthnicityStat)
{
Series theSeries = new Series();
EthnicityFrequency.EthnicityStat stat = (EthnicityFrequency.EthnicityStat)o;
Element elem = new Element();
theSeries.Name = stat.racialBackground;
elem.Name = stat.racialBackground;
elem.YValue = stat.frequency;
total += stat.frequency;
theSeries.AddElements(elem);
sc.Add(theSeries);
}
}
e.Result = sc;
}
示例14: DoCreateChartImage
protected override Image DoCreateChartImage()
{
var chart = new Chart();
chart.Type = ChartType.Combo;
chart.Width = Parameters.ChartWidth;
chart.Height = Parameters.ChartHeight;
chart.Series.Data = Parameters.SeriaData;
var seriesCollection = new SeriesCollection();
var s = new Series("", SeriesType.Line);
foreach (var pair in Parameters.SeriaData)
{
s.Elements.Add(new Element()
{
YValue = pair.Key,
XValue = pair.Value
});
}
seriesCollection.Add(s);
chart.SeriesCollection.Add(seriesCollection);
return chart.GetChartBitmap();
}
示例15: getChartData
private SeriesCollection getChartData(DataTable dt)
{
SeriesCollection SC = new SeriesCollection();
Series s = new Series();
Random ro = new Random();
for (int i = 0; i < dt.Rows.Count; i++)
{
Element e = new Element();
e.Name = dt.Rows[i][0].ToString();
e.YValue = Convert.ToDouble(dt.Rows[i][1].ToString());
e.ShowValue = true;
s.Elements.Add(e);
}
SC.Add(s);
return SC;
}