私はpdfファイルを生成するためにasp.netを使用しています。 pdfで私はプロットを表示する必要があります。私は、pngでそれをエクスポートし、pdfに挿入して、oxyplotを使用することに決めました。ドキュメンテーションには、PlotModelを使ってシリーズと軸で塗りつぶして、単純にPngExportingオブジェクトを使って書き出します。しかし、私がそれを生成しようとしているときは、軸を除いて何も表示されません。asp.net phojectのOxyPlotチャートをpngにエクスポート
コード私が使用しています:
var _plotModel = new OxyPlot.PlotModel()
{
PlotAreaBorderColor = OxyPlot.OxyColors.Transparent,
LegendBorder = OxyPlot.OxyColors.Transparent,
TitleToolTip = "Temperature",
Culture = new System.Globalization.CultureInfo("ru-Ru"),
Series =
{
new OxyPlot.Series.LineSeries()
{
ItemsSource = new List<SimplePointModel>
{
new SimplePointModel { Date = DateTime.Now, Temperature = 36.6f },
new SimplePointModel { Date = DateTime.Now.AddDays(1), Temperature = 42.6f },
new SimplePointModel { Date = DateTime.Now.AddDays(2), Temperature = 48.6f },
},
MarkerFill = OxyPlot.OxyColor.Parse("#A9CF9C"),
MarkerType = OxyPlot.MarkerType.Circle,
MarkerSize = item.ListSegments[0].Count() == 1 ? 2 : 1,
DataFieldX = "Date",
DataFieldY = "Temperature",
XAxisKey = "Date",
YAxisKey = "Temperature",
Color = OxyPlot.OxyColor.Parse("#A9CF9C"),
}
},
Axes =
{
new OxyPlot.Axes.DateTimeAxis()
{
Position = OxyPlot.Axes.AxisPosition.Bottom,
Key = "Date",
ToolTip = "Temperature",
AbsoluteMinimum = OxyPlot.Axes.Axis.ToDouble(DateTime.Now.Date),
AbsoluteMaximum = OxyPlot.Axes.Axis.ToDouble(DateTime.Now.AddDays(10000))
},
new OxyPlot.Axes.LinearAxis()
{
Position = OxyPlot.Axes.AxisPosition.Left,
Key = "Temperature",
ToolTip = "Temperature",
IsZoomEnabled = false,
IsPanEnabled = false,
}
}
};
using (var stream = System.IO.File.Create(Path.Combine(folder, "temp.png")))
{
PngExporter.Export(_plotModel, stream, 800, 400, OxyPlot.OxyColors.Transparent);
}
私は何ができますか?
DateTime.Now.AddDays(10000)? 10日のような値を試してみてください。私はX軸のスケールに起因する問題かもしれないと思う。 – kennyzx
@kennyzx私はこれをやろうとしましたが、何も変わりません。それは単にズームプロパティです。 –