Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 13th, 2007, 05:03 AM
Registered User
Join Date: Jun 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scatter chart using Java script

Dear all,
I have tried to create a scatter chart using Javascript and Microsoft OWC. For some reason, this one fails. This does work for column charts . Can you pleae advise on this?


<script type='text/javascript'>

function create_chart() {

  var xlLineMarkers = 21;
  var xlColumns = 2;

  var chDimSeriesNames = 0;
  var chDimCategories = 1;
  var chDimValues = 2;
  var chDimXValues = 4;
  var chDimYValues = 4;


  chart.ChartType = xlLineMarkers;
    chart.DataSource = excel;//.Range("A1:B12");
    var s = chart.Charts(0).SeriesCollection;

    var data_series = s.Add();
    data_series.caption = 'Monkey'.

    data_series.SetData(4, 0, "A1:A12");
    data_series.SetData(3, 0, "B1:B12");

  return false;

function l() {

  excel.DisplayToolbar = false;

  excel.Selection.NumberFormat = 'mmm-yy';

  excel.range('a1' ).value = 'Jan-2004'
  excel.range('a2' ).value = 'Feb-2004'
  excel.range('a3' ).value = 'Mar-2004'
  excel.range('a4' ).value = 'Apr-2004'
  excel.range('a5' ).value = 'May-2004'
  excel.range('a6' ).value = 'Jun-2004'
  excel.range('a7' ).value = 'Jul-2004'
  excel.range('a8' ).value = 'Aug-2004'
  excel.range('a9' ).value = 'Sep-2004'
  excel.range('a10').value = 'Oct-2004'
  excel.range('a11').value = 'Nov-2004'
  excel.range('a12').value = 'Dec-2004'

  excel.range('b1' ).value = 10
  excel.range('b2' ).value = 15
  excel.range('b3' ).value = 18
  excel.range('b4' ).value = 17
  excel.range('b5' ).value = 20
  excel.range('b6' ).value = 23
  excel.range('b7' ).value = 22
  excel.range('b8' ).value = 24
  excel.range('b9' ).value = 27
  excel.range('b10').value = 27
  excel.range('b11').value = 29
  excel.range('b12').value = 32

<body onLoad='l();'>

  <input type=submit onclick='return create_chart()' value='Create Chart'>

  id = excel
  classid = 'clsid:0002E551-0000-0000-C000-000000000046'

 <param name=DisplayTitleBar value=false >
 <param name=ViewableRange value='a1:b12'>
 <param name=AutoFit value=true >

<object id= chart classid='clsid:0002E556-0000-0000-C000-000000000046' style="width:100%;height:350"></object>


Reply With Quote
  #2 (permalink)  
Old June 17th, 2007, 06:48 AM
Authorized User
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts

At first I should mention that you have a syntax error in your code (data_series.caption = 'Monkey'.)
What is that period after 'Monkey' string ? But after removing this little syntax error, your code still have some problems. You used 21 as a chart type number (meaning ScatterMarkers chart). The main problem raises when you try to call data_series.SetData(4, 0, "A1:A12"); or data_series.SetData(3, 0, "B1:B12");.

You are using number 3 and 4 as a first parameter of these methods and these are wrong number for charts like this. If you use 2 and 1 (instead of 3 and 4) correspondingly, you will have your little pretty chart without any problem.

Good luck
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Scatter Chart Programatically Odeh Naber Access VBA 2 February 12th, 2008 08:50 AM
scatter XY chart using Script madganesh VBScript 0 June 13th, 2007 05:05 AM
java script nalla ASP.NET 1.0 and 1.1 Professional 8 June 23rd, 2006 06:24 AM
Java vs Java Script functions joemorrison74 J2EE 0 July 6th, 2005 04:28 PM
java script zouky JSP Basics 1 September 27th, 2004 01:54 AM

All times are GMT -4. The time now is 07:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.