FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oxyplot/Source/Examples/Core.Drawing/Example1/Program.cs at develop · oxyplot/oxyplot · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
oxyplot
/
oxyplot
Public
Notifications
You must be signed in to change notification settings
Fork
976
Star
3.5k
Code
Issues
618
Pull requests
11
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
oxyplot
/
Source
/
Examples
/
Core.Drawing
/
Example1
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (73 loc) · 2.94 KB
Breadcrumbs
oxyplot
/
Source
/
Examples
/
Core.Drawing
/
Example1
/
Program.cs
Copy path
File metadata and controls
86 lines (73 loc) · 2.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
namespace
Example1
{
using
System
;
using
System
.
IO
;
using
System
.
Linq
;
using
OxyPlot
;
using
OxyPlot
.
Axes
;
using
OxyPlot
.
Core
.
Drawing
;
using
OxyPlot
.
Series
;
class
Program
{
static
void
Main
(
string
[
]
args
)
{
var
outputToFile
=
"test-oxyplot-static-export-file.png"
;
var
outputExportStreamOOP
=
"test-oxyplot-ExportToStream.png"
;
var
outputExportFileOOP
=
"test-oxyplot-ExportToFile.png"
;
var
width
=
1024
;
var
height
=
768
;
var
background
=
OxyColors
.
LightGray
;
var
resolution
=
96d
;
var
model
=
BuildPlotModel
(
)
;
// export to file using static methods
PngExporter
.
Export
(
model
,
outputToFile
,
width
,
height
,
resolution
)
;
// export using the instance methods
using
(
var
stream
=
new
MemoryStream
(
)
)
{
var
pngExporter
=
new
PngExporter
{
Width
=
width
,
Height
=
height
,
Resolution
=
resolution
}
;
pngExporter
.
Export
(
model
,
stream
)
;
System
.
IO
.
File
.
WriteAllBytes
(
outputExportStreamOOP
,
stream
.
ToArray
(
)
)
;
}
var
pngExporter2
=
new
PngExporter
{
Width
=
width
,
Height
=
height
,
Resolution
=
resolution
}
;
var
bitmap
=
pngExporter2
.
ExportToBitmap
(
model
)
;
bitmap
.
Save
(
outputExportFileOOP
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Png
)
;
bitmap
.
Save
(
Path
.
ChangeExtension
(
outputExportFileOOP
,
".gif"
)
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Gif
)
;
}
private
static
IPlotModel
BuildPlotModel
(
)
{
var
rand
=
new
Random
(
21
)
;
var
model
=
new
PlotModel
{
Title
=
"Cake Type Popularity"
}
;
var
cakePopularity
=
Enumerable
.
Range
(
1
,
5
)
.
Select
(
i
=>
rand
.
NextDouble
(
)
)
.
ToArray
(
)
;
var
sum
=
cakePopularity
.
Sum
(
)
;
var
barItems
=
cakePopularity
.
Select
(
cp
=>
RandomBarItem
(
cp
,
sum
)
)
.
ToArray
(
)
;
var
barSeries
=
new
BarSeries
{
ItemsSource
=
barItems
,
LabelPlacement
=
LabelPlacement
.
Base
,
LabelFormatString
=
"{0:.00}%"
}
;
model
.
Series
.
Add
(
barSeries
)
;
model
.
Axes
.
Add
(
new
CategoryAxis
{
Position
=
AxisPosition
.
Left
,
Key
=
"CakeAxis"
,
ItemsSource
=
new
[
]
{
"Apple cake"
,
"Baumkuchen"
,
"Bundt Cake"
,
"Chocolate cake"
,
"Carrot cake"
}
}
)
;
return
model
;
}
private
static
BarItem
RandomBarItem
(
double
cp
,
double
sum
)
=>
new
BarItem
{
Value
=
cp
/
sum
*
100
,
Color
=
RandomColor
(
)
}
;
private
static
OxyColor
RandomColor
(
)
{
var
r
=
new
Random
(
)
;
return
OxyColor
.
FromRgb
(
(
byte
)
r
.
Next
(
255
)
,
(
byte
)
r
.
Next
(
255
)
,
(
byte
)
r
.
Next
(
255
)
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL