Plot a graph having two Y-axis and a single X-axis in excel using C#

Posted by Tiju.thomas under C# on 5/17/2009 | Views : 21391 | Status : [Member] | Replies : 3
Friends,
I am trying to write a program to plot a graph in an excel file using the datas available from the same excel file.

Till now I am able to write a program to plot a normal graph with a single x-axis and with single y-axis.

But my requirement is to plot a graph having two Y-axis (i.e one primary axis and another as secondary axis) and a single X-axis in excel i.e X-axis should be common and one Y-axis should be in the extreme left (as primary axis) and another one in extreme right (secondary axis) of the X-axis.

Can any one please help?




Responses

Posted by: Vuyiswamb on: 5/18/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Tiju.thomas

Please check the Following Links

http://www.smallguru.com/2009/01/zedgraph-csharp-graph-plot-example-application/

http://www.codeproject.com/KB/cs/ExcelCSharp.aspx

http://peltiertech.com/Excel/Charts/ParallelCoord.html

Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Tiju.thomas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashoknalam on: 5/18/2009 [Member] Starter

Up
0
Down
using series collection u can done with two graphs in single chart the code below can useful for u....let me know anything missed out
  ChartObjects charts = (ChartObjects)_excelSheet.ChartObjects(Type.Missing);

ChartObject objChart = charts.Add(200, 470, 285, 180);

Microsoft.Office.Interop.Excel.Series s;
objChart.Chart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLineMarkers;
SeriesCollection seriesCollection = (SeriesCollection)objChart.Chart.SeriesCollection(Type.Missing);


s = seriesCollection.NewSeries();
s.XValues = _excelSheet.get_Range("A14", "A37");
s.Values = _excelSheet.get_Range("C14", "C37");
s.Name = "graph1";

s = seriesCollection.NewSeries();
s.XValues = _excelSheet.get_Range("A14", "A37");
s.Name = "graph2";
s.Values = _excelSheet.get_Range("B14","B37");
objChart.Chart.Legend.Position = XlLegendPosition.xlLegendPositionTop;
objChart.Chart.HasTitle = true;
objChart.Chart.ChartTitle.Text = "Test Tilte";
objChart.Chart.ChartTitle.Font.Bold = false;


Ashok Nalam

Tiju.thomas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tiju.thomas on: 5/18/2009 [Member] Starter

Up
0
Down
Thanks Ashoknalam.
But my requirement is that in a single graph itself I need two y-axis i.e. one y-axis as primary axis and another y-axis as secondary axis.
I have updated my question also.

Tiju.thomas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response