Minor changes (StyleCop code style, comments) (#1275) · oxyplot/oxyplot@f9cebf3 · GitHub
Skip to content

Commit f9cebf3

Browse files
author
Oystein Bjorke
authored
Minor changes (StyleCop code style, comments) (#1275)
1 parent bee7026 commit f9cebf3

12 files changed

Lines changed: 837 additions & 817 deletions

File tree

‎README.md‎

Lines changed: 15 additions & 15 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Drawing.Common" Version="4.6.0-preview.19073.11" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\..\OxyPlot.Core.Drawing\OxyPlot.Core.Drawing.csproj" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
namespace Example1
2+
{
3+
using System;
4+
using System.Drawing;
5+
using System.IO;
6+
using System.Linq;
7+
using OxyPlot;
8+
using OxyPlot.Axes;
9+
using OxyPlot.Core.Drawing;
10+
using OxyPlot.Series;
11+
12+
class Program
13+
{
14+
static void Main(string[] args)
15+
{
16+
var outputUsingMemStream = "test-oxyplot-memstream.png";
17+
var outputToFile = "test-oxyplot-file.png";
18+
var outputExportFileStream = "test-oxyplot-stream-export.png";
19+
var outputExportFileOOP = "test-oxyplot-ExportToFile.png";
20+
21+
var width = 1024;
22+
var height = 768;
23+
24+
var model = BuildPlotModel();
25+
26+
27+
PngExporter.Export(model, outputToFile, width, height, Brushes.White);
28+
29+
using (var stream = new MemoryStream())
30+
{
31+
PngExporter.Export(model, stream, width, height, OxyColors.White, 96);
32+
System.IO.File.WriteAllBytes(outputUsingMemStream, stream.ToArray());
33+
}
34+
35+
using (var pngStream = PngExporter.ExportToStream(model, width, height, OxyColors.White))
36+
{
37+
var fileStream = new System.IO.FileStream(outputExportFileStream, FileMode.Create);
38+
pngStream.CopyTo(fileStream);
39+
fileStream.Flush();
40+
}
41+
42+
var stream2 = new MemoryStream();
43+
var pngExporter = new PngExporter { Width = width, Height = height, Background = OxyColors.White };
44+
pngExporter.Export(model, stream2);
45+
46+
// Write to a file, OOP
47+
var pngExporter2 = new PngExporter { Width = width, Height = height, Background = OxyColors.White };
48+
pngExporter2.ExportToFile(model, outputExportFileOOP);
49+
}
50+
51+
private static IPlotModel BuildPlotModel()
52+
{
53+
var rand = new Random();
54+
55+
var model = new PlotModel { Title = "Cake Type Popularity" };
56+
57+
var cakePopularity = Enumerable.Range(1, 5).Select(i => rand.NextDouble()).ToArray();
58+
var sum = cakePopularity.Sum();
59+
var barSeries = new BarSeries
60+
{
61+
ItemsSource = cakePopularity.Select(cp => RandomBarItem(cp, sum)),
62+
LabelPlacement = LabelPlacement.Base,
63+
LabelFormatString = "{0:.00}%"
64+
};
65+
66+
model.Series.Add(barSeries);
67+
68+
model.Axes.Add(new CategoryAxis
69+
{
70+
Position = AxisPosition.Left,
71+
Key = "CakeAxis",
72+
ItemsSource = new[]
73+
{
74+
"Apple cake",
75+
"Baumkuchen",
76+
"Bundt Cake",
77+
"Chocolate cake",
78+
"Carrot cake"
79+
}
80+
});
81+
return model;
82+
}
83+
84+
private static BarItem RandomBarItem(double cp, double sum)
85+
=> new BarItem { Value = cp / sum * 100, Color = RandomColor() };
86+
87+
private static OxyColor RandomColor()
88+
{
89+
var r = new Random();
90+
return OxyColor.FromRgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
91+
}
92+
}
93+
}

‎Source/Examples/Core.drawing/Core.Drawing.Example.csproj‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎Source/Examples/Core.drawing/Program.cs‎

Lines changed: 0 additions & 101 deletions
This file was deleted.

‎Source/OxyPlot.AppVeyor.sln‎

Lines changed: 31 additions & 2 deletions

0 commit comments

Comments
 (0)