Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
C#: XYScatter chart with smooth lines and no markers
I hv been working on a Office 2007 App level add-in project using VS2005,
..Net 2.0, VSTO for Office 2007 and Office 2007 Interopps. I want to draw a XYScatter chart with smooth lines nad no markers. Here is a sample from my code....(NB: Im just copy and paste the code from IDE here...so there are variables appear here, but defined outside the this code sample....so plz ignore them) Microsoft.Office.Interop.Excel.ChartObjects charts = (Microsoft.Office.Interop.Excel.ChartObjects)ws.Ch artObjects(Type.Missing); Microsoft.Office.Interop.Excel.ChartObject chart = charts.Add(110, 40, 600, 300); Microsoft.Office.Interop.Excel.Chart xlChart = chart.Chart; Microsoft.Office.Interop.Excel.Range rg; int end = values.Length + 1; rg = ws.get_Range("A2", "B" + end.ToString()); xlChart.Legend.Clear(); Microsoft.Office.Interop.Excel.Axis x; x = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlCatego ry, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); x.HasTitle = true; x.AxisTitle.Text = "Time"; Microsoft.Office.Interop.Excel.Axis y; y = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); y.HasTitle = true; y.AxisTitle.Text = "Forecasted Value"; xlChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlXYSca tterSmoothNoMarkers; xlChart.SetSourceData(rg, Type.Missing); The above code always draws a XYScatter with smmoth lnes but with markers? What could be the problem? How to programatically specify the thickness of the scatter line? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
C#: XYScatter chart with smooth lines and no markers
OK...Nobody has replied thus far. But, I could get this problem solved after
trying any combinations. The above code actually draws the chart but with markers. We can remove markers by taking a reference to the series and then formatting it. Microsoft.Office.Interop.Excel.Series s = (Microsoft.Office.Interop.Excel.Series)xlChart.Ser iesCollection(1); ..MarkerStyle = Microsoft.Office.Interop.Excel.XlMarkerStyle.xlMar kerStyleNone; OR We can use Chart.ChartWizard() method, where in parameters we can mention the chart type we want. Using Chart.ChartWizard() really reduces the amount of code lines to be written. Changing the thickness of the line is possible after obtaining a reference to the line in the series. Microsoft.Office.Interop.Excel.Series s = (Microsoft.Office.Interop.Excel.Series)xlChart.Ser iesCollection(1); s.Format.Line.Weight = (float)0.25; "Thilina Dampahala" wrote: I hv been working on a Office 2007 App level add-in project using VS2005, .Net 2.0, VSTO for Office 2007 and Office 2007 Interopps. I want to draw a XYScatter chart with smooth lines nad no markers. Here is a sample from my code....(NB: Im just copy and paste the code from IDE here...so there are variables appear here, but defined outside the this code sample....so plz ignore them) Microsoft.Office.Interop.Excel.ChartObjects charts = (Microsoft.Office.Interop.Excel.ChartObjects)ws.Ch artObjects(Type.Missing); Microsoft.Office.Interop.Excel.ChartObject chart = charts.Add(110, 40, 600, 300); Microsoft.Office.Interop.Excel.Chart xlChart = chart.Chart; Microsoft.Office.Interop.Excel.Range rg; int end = values.Length + 1; rg = ws.get_Range("A2", "B" + end.ToString()); xlChart.Legend.Clear(); Microsoft.Office.Interop.Excel.Axis x; x = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlCatego ry, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); x.HasTitle = true; x.AxisTitle.Text = "Time"; Microsoft.Office.Interop.Excel.Axis y; y = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); y.HasTitle = true; y.AxisTitle.Text = "Forecasted Value"; xlChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlXYSca tterSmoothNoMarkers; xlChart.SetSourceData(rg, Type.Missing); The above code always draws a XYScatter with smmoth lnes but with markers? What could be the problem? How to programatically specify the thickness of the scatter line? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
C#: XYScatter chart with smooth lines and no markers
We can use Chart.ChartWizard() method, where in parameters we can mention the
chart type we want. Using Chart. Changing the thickness of the line is possible after obtaining a reference to the line in the series. Microsoft.Office.Interop.Excel.Series s = (Microsoft.Office.Interop.Excel.Series)xlChart.Ser iesCollection(1); s.Format.Line.Weight = (float)0.25; "Thilina Dampahala" wrote: "Thilina Dampahala" wrote: I hv been working on a Office 2007 App level add-in project using VS2005, .Net 2.0, VSTO for Office 2007 and Office 2007 Interopps. I want to draw a XYScatter chart with smooth lines nad no markers. Here is a sample from my code....(NB: Im just copy and paste the code from IDE here...so there are variables appear here, but defined outside the this code sample....so plz ignore them) Microsoft.Office.Interop.Excel.ChartObjects charts = (Microsoft.Office.Interop.Excel.ChartObjects)ws.Ch artObjects(Type.Missing); Microsoft.Office.Interop.Excel.ChartObject chart = charts.Add(110, 40, 600, 300); Microsoft.Office.Interop.Excel.Chart xlChart = chart.Chart; Microsoft.Office.Interop.Excel.Range rg; int end = values.Length + 1; rg = ws.get_Range("A2", "B" + end.ToString()); xlChart.Legend.Clear(); Microsoft.Office.Interop.Excel.Axis x; x = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlCatego ry, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); x.HasTitle = true; x.AxisTitle.Text = "Time"; Microsoft.Office.Interop.Excel.Axis y; y = (Microsoft.Office.Interop.Excel.Axis)xlChart.Axes( Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrima ry); y.HasTitle = true; y.AxisTitle.Text = "Forecasted Value"; xlChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlXYSca tterSmoothNoMarkers; xlChart.SetSourceData(rg, Type.Missing); The above code always draws a XYScatter with smmoth lnes but with markers? What could be the problem? How to programatically specify the thickness of the scatter line? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
C#: XYScatter chart with smooth lines and no markers | Charts and Charting in Excel | |||
How does Excel smooth chart data when smooth option is selected? | Charts and Charting in Excel | |||
How do print a chart with smooth lines? | Charts and Charting in Excel | |||
How do I smooth the lines around a pie chart? | Charts and Charting in Excel | |||
How do I make the lines "smooth" in my 3-d pie chart? | Charts and Charting in Excel |