We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LineWithMarkers Chart

I would like to create a chart with DateAxis as X axis and Category as Y axis

with Linewith markers as charttype .

When i create one i always get dateaxis as Y and category as X …
is it possible to switch them

Regards

Hi,


Thanks for inquiring Aspose.Slides.

I have observed the problem statement shared by you and have not been able to completely understand the requirements shared. Can you please share the source sample code used along with generated output with us. Please also share the source and desired output presentations with us so that I may help you further in this regard.

Many Thanks,

Hi ,


The code i have used is below

actually i would like to have chart like the stackedbar.pptx with bars replaced by LineWithMarkers.

so tried

ChartEx chart = sld.getShapes().addChart(ChartTypeEx.StackedBar, 10, 60, 700, 400);
chart.getChartData().getSeries().clear();
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, “Red”), ChartTypeEx.LineWithMarkers );
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, “Green”), ChartTypeEx.LineWithMarkers);
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, “Yellow”), ChartTypeEx.LineWithMarkers);

the axis got reversed



PresentationEx pres = new PresentationEx();
SlideEx sld = pres.getSlides().get_Item(0);
ChartEx chart = sld.getShapes().addChart(ChartTypeEx.StackedBar, 10, 60, 700, 400);
// chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();

int defaultWorksheetIndex = 0;
ChartDataCellFactory fact = chart.getChartData().getChartDataCellFactory();

chart.getValueAxis().setSourceLinked (false);
chart.getValueAxis().setBaseUnitScale(TimeUnitType.Months);

chart.getValueAxis().setNumberFormat("[$-409]mmm-yy;@");

chart.getValueAxis().isAutomaticMajorUnit(false);
chart.getValueAxis().isAutomaticMaxValue(false);
chart.getValueAxis().isAutomaticMinorUnit(false);
chart.getValueAxis().isAutomaticMinValue(false);
chart.getValueAxis().isAutomaticMajorUnit(false);
chart.getValueAxis().isAutomaticMaxValue(false);
chart.getValueAxis().isAutomaticMinorUnit(false);
chart.getValueAxis().isAutomaticMinValue(false);
chart.getValueAxis().setMinValue((365.25f108)+163);
chart.getValueAxis().setMaxValue((365.25f110)+15);
chart.getValueAxis().setMajorUnit(30.5f);
chart.getValueAxis().setMajorUnitScale(TimeUnitType.Months);
chart.hasLegend(false);


/* chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, “Red”), ChartTypeEx.LineWithMarkers );
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, “Green”), ChartTypeEx.LineWithMarkers);
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, “Yellow”), ChartTypeEx.LineWithMarkers);/

chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, “Product 1”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, “Product 2”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, “Product 3”));

ChartSeriesEx series = chart.getChartData().getSeries().get_Item(0);
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 1,(365.25f108)+200));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 1, (365.25f108)+215));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 1,(365.25f108)+250));
series.setMarkerSymbol(MarkerStyleTypeEx.Circle);
series.setMarkerSize(10);

series = chart.getChartData().getSeries().get_Item(1);
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 2,(365.25f109)+15));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 2, (365.25f109)+95));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 2,(365.25f109)+195));
series.setMarkerSymbol(MarkerStyleTypeEx.Circle);
series.setMarkerSize(10);

//Take 3rd chart series
series = chart.getChartData().getSeries().get_Item(2);

//Now populating series data
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 3,(365.25f109)+95));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 3, (365.25f109)+75));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 3,(365.25f109)+60));
series.setMarkerSymbol(MarkerStyleTypeEx.Circle);
series.setMarkerSize(10);

chart.getCategoryAxis().getMajorGridLines().getFillFormat().setFillType(FillTypeEx.NoFill);
chart.getValueAxis().getMajorGridLines().getFillFormat().setFillType(FillTypeEx.NoFill);

//Setting Category Axis Text Properties
TextFrameEx txtCat = chart.getCategoryAxis().getTextProperties();
PortionFormatEx format=txtCat.getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat();
format.setFontBold(NullableBool.True);
format.setFontHeight (12);
format.setFontItalic( NullableBool.True);
format.getFillFormat().setFillType(FillTypeEx.Solid) ;
format.getFillFormat().getSolidFillColor().setPresetColor(PresetColorEx.Blue);
format.setLatinFont(new FontDataEx(“Arial”));

//Setting Category Axis Text Properties
TextFrameEx txtValue = chart.getValueAxis().getTextProperties();
PortionFormatEx formatValue=txtValue.getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat();
formatValue.setFontBold(NullableBool.True);
formatValue.setFontHeight (6);
formatValue.setFontItalic( NullableBool.True);
formatValue.getFillFormat().setFillType(FillTypeEx.Solid) ;
formatValue.getFillFormat().getSolidFillColor().setPresetColor(PresetColorEx.Blue);
formatValue.setLatinFont(new FontDataEx(“Arial”));

// Save presentation with chart
pres.write(“E:\Aspose.pptx”);

Thanks and Apprecxiate your help

Hi,


Thanks for sharing the sample charts. I would really appreciate if you may please share the desired output presentation. I have tried to understand the following requirement shared by you and have not been able to get the idea that what sort of output chart you are looking for.

"actually i would like to have chart like the stackedbar.pptx with bars replaced by LineWithMarkers."

Can you please share the sample output chart that you generate in PowerPoint and I will try my best to help you in generating the similar one by using Aspose.Slides for Java.

Many Thanks,

Hi ,


Highly appreciate your help on this …



Many Thanks

Hi,


Thanks for sharing the detailed information. I have observed the desired chart and have tried to generate the chart shared using PowerPoint. Unfortunately, I have not been able to generate chart by using PowerPoint even. Can you please share the desired output chart generated in PowerPoint and I may help you further in this regard. I have generate the only possible sample chart in using Aspose.Slides and PowerPoint. But, it does not serve your purpose. I have used the following sample code. I am afraid the required chart is not possible using PowerPoint.


PresentationEx pres = new PresentationEx();

SlideEx slide = pres.Slides[0];

//Creating the default chart
ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.ScatterWithMarkers, 0, 0, 400, 400);
pres.Write(“D:\Aspose Data\TestScatter.pptx”);
}

public static void GenBubbleChart()
{
PresentationEx pres = new PresentationEx();
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredBar, 10, 60, 700, 300);

ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
ChartSeriesEx series = chart.ChartData.Series[0];
String Sername=series.NameCells.GetConcateNameFromCells;
ChartDataCell cell = series.NameCells[0];//0 is series index


// chart.ChartData.Series.RemoveAt(1);
// chart.ChartData.Series.RemoveAt(1);

series.Type = ChartTypeEx.LineWithMarkers;
/////
//Add new point (1:3) there.
series.XValues.Add(fact.GetCell(0, 6, 1, 118));
series.YValues.Add(fact.GetCell(0, 6, 2, 307));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 7, 1, 215));
series.YValues.Add(fact.GetCell(0, 7, 2, 166));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 8, 1, 414));
series.YValues.Add(fact.GetCell(0, 8, 2, 213));

//Edit the type of series
series.Type = ChartTypeEx.ScatterWithStraightLinesAndMarkers;

//Changing the chart series marker
series.MarkerSize = 20;
series.MarkerSymbol = MarkerStyleTypeEx.Circle;


//////


series = chart.ChartData.Series[1];


series.Type = ChartTypeEx.LineWithMarkers;
/////
//Add new point (1:3) there.
series.XValues.Add(fact.GetCell(0, 6, 3, 110));
series.YValues.Add(fact.GetCell(0, 6, 4, 300));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 7, 3, 212));
series.YValues.Add(fact.GetCell(0, 7, 4, 163));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 8, 3, 411));
series.YValues.Add(fact.GetCell(0, 8, 4, 213));

//Edit the type of series
series.Type = ChartTypeEx.ScatterWithStraightLinesAndMarkers;

//Changing the chart series marker
series.MarkerSize =20;
series.MarkerSymbol = MarkerStyleTypeEx.Circle;



/////////
series = chart.ChartData.Series[2];


series.Type = ChartTypeEx.LineWithMarkers;
/////
//Add new point (1:3) there.
series.XValues.Add(fact.GetCell(0, 6, 5, 210));
series.YValues.Add(fact.GetCell(0, 6, 6, 400));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 7, 5, 312));
series.YValues.Add(fact.GetCell(0, 7, 6, 463));

//Add new point (2:10)
series.XValues.Add(fact.GetCell(0, 8, 5, 411));
series.YValues.Add(fact.GetCell(0, 8, 6, 513));

//Edit the type of series
series.Type = ChartTypeEx.ScatterWithStraightLinesAndMarkers;

//Changing the chart series marker
series.MarkerSize = 20;
series.MarkerSymbol = MarkerStyleTypeEx.Circle;


//////

chart.ValueAxis.SourceLinked = false;
chart.ValueAxis.BaseUnitScale = TimeUnitType.Months;
//
//[$-409]mmm-yy;@
chart.ValueAxis.NumberFormat = “[$-409]mmm-dd;@”;
chart.ValueAxis.IsAutomaticMajorUnit = false;
chart.ValueAxis.IsAutomaticMinorUnit = false;
chart.ValueAxis.IsAutomaticMaxValue = false;
chart.ValueAxis.IsAutomaticMinValue = false;
//Starting day number
chart.ValueAxis.MinValue = 13;
//Ending day number
chart.ValueAxis.MaxValue = 365;

//Setting month wise interval
chart.ValueAxis.MajorUnit = 30.5f;

//setting minor unit to 10 days
chart.ValueAxis.MinorUnit = 10;

chart.ValueAxis.MinorUnitScale = TimeUnitType.Days;
chart.ValueAxis.MajorUnitScale = TimeUnitType.Months;

// chart.ValueAxis.DisplayUnit = DisplayUnitType.Millions;
chart.HasLegend = false;
pres.Write(“D:\Aspose Data\Bar.pptx”);


Many Thanks,