Created
March 1, 2024 10:50
-
-
Save smoothdeveloper/cbd57d86242c8525cfac7ffe29db319c to your computer and use it in GitHub Desktop.
DevExpress XtraCharts: How to: Export a Chart to Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dev Express documentation is lacking F# interactive samples | |
// https://docs.devexpress.com/WindowsForms/2508/controls-and-libraries/chart-control/examples/producing-output/how-to-export-a-chart-to-image | |
#r @"paket: nuget DevExpress.XtraCharts.v21.1" | |
open System.IO | |
open System.Windows.Forms | |
open DevExpress.XtraCharts | |
let pieChart = ChartControl(Width=1600,Height=1000) | |
let series = | |
new Series( | |
"title" | |
, ViewType.Pie | |
, DataSource = | |
[ | |
{| Label = "Mother Russia" ; Value = 17.0752 |} | |
{| Label = "Father Canada" ; Value = 9.984467 |} | |
{| Label = "Father USA" ; Value = 9.63142 |} | |
{| Label = "Mother China" ; Value = 9.59696 |} | |
{| Label = "Father Brazil" ; Value = 8.511965 |} | |
{| Label = "Mother Australia" ; Value = 7.68685 |} | |
{| Label = "Mother India" ; Value = 108.108 |} | |
{| Label = "Others" ; Value = 81.2 |} | |
] | |
) | |
series.ArgumentDataMember <- "Label" | |
series.ValueDataMembers.AddRange [|"Value"|] | |
series.Label.TextPattern <- "{VP:p0} ({V:.###}M km²)" | |
series.LegendTextPattern <- "{A}" | |
pieChart.Dock <- DockStyle.Fill | |
pieChart.Series.Add series | |
pieChart.ExportToImage(Path.Combine(__SOURCE_DIRECTORY__, "piechart.png"), System.Drawing.Imaging.ImageFormat.Png) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment