2017-06-22 6 views

答えて

2

私はあなたの要件を見て、その共有するのが好きです。さまざまなシリーズデータポイントの異なる定義済みマーカー記号またはカスタムマーカー記号(画像形式)を表示できるLineWithMarkerグラフをサポートしています。 Aspose.SlidesとMSOチャートを使用して、以下のサンプルコードを使用してオプションを試してみてください。

public static void TestScatter() 
{ 
    var location = System.Reflection.Assembly.GetExecutingAssembly().Location; 

    //Open a presentation 
    Presentation pres = new Presentation(); 
    IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.StackedLineWithMarkers, 10, 10, 400, 400); 
    //populating cycle 
    var serie = chart.ChartData.Series[0]; 
    var wbk = chart.ChartData.ChartDataWorkbook; 
    chart.ChartData.Series.RemoveAt(1); 
    chart.ChartData.Series.RemoveAt(1); 

    serie.Marker.Format.Fill.FillType = FillType.Picture; 
    serie.Marker.Size = 20; 

    // Set the picture 
    System.Drawing.Image img = (System.Drawing.Image)new Bitmap(@"C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg"); 
    IPPImage imgx = pres.Images.AddImage(img); 
    serie.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx; 

    //For individual data point 
    serie.DataPoints[0].Marker.Format.Fill.FillType = FillType.Solid; 
    serie.DataPoints[0].Marker.Format.Fill.SolidFillColor.Color = Color.Red; 
    serie.DataPoints[0].Marker.Size = 20; 
    serie.DataPoints[0].Marker.Symbol = MarkerStyleType.Triangle; 

    serie.DataPoints[0].Label.DataLabelFormat.ShowValue = true; 
    serie.DataPoints[1].Label.DataLabelFormat.ShowValue = true; 
    serie.DataPoints[2].Label.DataLabelFormat.ShowValue = true; 
    serie.DataPoints[3].Label.DataLabelFormat.ShowValue = true; 

    pres.Save(Path.Combine(Path.GetDirectoryName(location), "Result2.pptx"), SaveFormat.Pptx); 

} 

私はAsposeのSupport developer/Evangelistとして働いています。私はさらにあなたの要件を観察してきた

+0

おかげで、しかし、私は私は私が一緒に行く権利marker.Ifの位置だけでデータラベルとそのシンボルを示した図上記marker.inにデータラベルとそのシンボルをする必要はありません私はこのようなデザインを正確に作ることができますか? – user3501613

+0

私は画像をマーカーで置き換えました(上の画像を確認してください)。私がマーカーを変えて画像を置くと上記の解決策に従うと、位置が間違っています。 – user3501613

+0

私は両方のマーカー(菱形)とデータラベルが必要ですので、マーカを編集すると必要なデザインが間違っています – user3501613

1

多くのおかげで、あなたも同様Aspose.Slides official support forumで同様の要件を掲載していることを観察しました。目的に合うように、最後に次のサンプルコードを使用してみてください。

public static void TestLineChart() 
{ 
var location = System.Reflection.Assembly.GetExecutingAssembly().Location; 

//Open a presentation 
Presentation pres = new Presentation(); 
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.StackedLineWithMarkers, 10, 10, 400, 400); 
//populating cycle 
var serie = chart.ChartData.Series[0]; 
var wbk = chart.ChartData.ChartDataWorkbook; 
chart.ChartData.Series.RemoveAt(1); 
chart.ChartData.Series.RemoveAt(1); 

serie.Marker.Format.Fill.FillType = FillType.Picture; 
serie.Marker.Size = 20; 


serie.Marker.Symbol = MarkerStyleType.Diamond; 
serie.Marker.Format.Fill.FillType = FillType.Solid; 
serie.Marker.Format.Fill.SolidFillColor.Color=Color.Orange; 
serie.Marker.Format.Line.FillFormat.FillType = FillType.Solid; 
serie.Marker.Format.Line.FillFormat.SolidFillColor.Color=Color.Red; 
serie.Marker.Format.Line.Width=1.0F; 

serie.Format.Line.Width = 3.0f; 
serie.Format.Line.FillFormat.FillType=FillType.Solid; 
serie.Format.Line.FillFormat.SolidFillColor.Color = Color.FromArgb(209,225,91) ; 

for(int i=0;i<serie.DataPoints.Count;i++) 
{ 
serie.DataPoints[i].Label.DataLabelFormat.ShowValue = true; 
    IDataLabel label=serie.Labels[i]; 
    chart.ValidateChartLayout(); 
    IAutoShape ashp=chart.UserShapes.Shapes.AddAutoShape(ShapeType.Triangle,chart.X + label.ActualX + 5, chart.Y + label.ActualY + 5, 20,20); 
    ashp.FillFormat.FillType = FillType.Solid; 

    ashp.LineFormat.FillFormat.FillType = FillType.NoFill; 
    if (i % 2 == 0)//even data points 
    { 
     ashp.FillFormat.SolidFillColor.Color = Color.Green; 
    } 
    else 
    { 
     ashp.Rotation = 180; 
     ashp.FillFormat.SolidFillColor.Color = Color.Red; 
    } 
} 

pres.Save(Path.Combine(Path.GetDirectoryName(location), "Result2.pptx"), Aspose.Slides.Export.SaveFormat.Pptx); 

} 

私はAsposeのSupport developer/Evangelistとして働いています。

多くのおかげで、あなたのサポートのための

+0

私はこのコードを実装しようとしたときに2つの問題が発生しています 1. Chart.Xとlabel.XはNaN(ActualXの代わりにXを使用) 2. ActualXはラベルのプロパティに入っていません 2番目の問題がASPOSEのバージョンと関連しているかどうか? – user3501613

関連する問題