Loading ...
Sorry, an error occurred while loading the content.
 

Re: [ydn-javascript] Charts multiple series

Expand Messages
  • Vishal Patel
    thanks eric. i have done the restructuring. i have one other doubt. my application needs to save (sometimes though) the generated graph as an image. so that it
    Message 1 of 3 , Dec 29, 2007
      thanks eric.
      i have done the restructuring.
      i have one other doubt. my application needs to save (sometimes though) the generated graph as an image. so that it can be sent over mail or something. i could not find any such option. (e.g. save as image or like)
      can anyone help with it..

       
      regards,
      vishal patel



      ----- Original Message ----
      From: Eric Miraglia <miraglia@...>
      To: ydn-javascript@yahoogroups.com
      Sent: Friday, 28 December, 2007 11:26:12 PM
      Subject: Re: [ydn-javascript] Charts multiple series

      Vishal,


      The way to do what you're trying for here is to restructure your data a bit.  Your series here are grouped by date: You're measuring VP, Sahil, and Dray's "val" across three moments in time specified as dates.  So, your data can be structured as follows:

      var c_data=[
      {exp_date: "2007-10-02" ,vp:95, sahil:5, dray:320},
      {exp_date: "2007-10-03" ,vp:120, sahil:220, dray:120},
      {exp_date: "2007-10-04" ,vp:100, sahil:200, dray:10}
      ];

      You can then tell the Charts Control that you're interested in treating vp, sahil and dray as separate series on the chart:

      var seriesDef = 
      [
      { displayName: "Dray", yField: "dray" },
      { displayName: "Sahil", yField: "sahil"},
      { displayName: "VP", yField: "vp" }
      ];

      Now, instantiate the chart, passing in the exp_date field as the master field for the X axis and your seriesDef groupings:

      var myChart = new YAHOO.widget. LineChart( "chartdiv", Chart_DS, {
      xField: "exp_date",
      series: seriesDef
      });

      That will get you something that looks like this:


      Regards,
      Eric



      ____________ _________ _________ _________ _______
      Eric Miraglia
      Yahoo! User Interface Library


      On Dec 27, 2007, at 10:05 PM, Vishal Patel wrote:

      hi

      i tried using Charts. its awesome ppl. but i have few doubts. 

      here is my datasource def

      [[code]]

      var c_data=[

      {name: "vp",exp_date: "2007-10-02" ,val: 95},

      {name: "vp",exp_date: "2007-10-03" ,val: 120},

      {name: "vp",exp_date: "2007-10-04" ,val: 100},

      {name: "sahil",exp_ date: "2007-10-02" ,val: 5},

      {name: "sahil",exp_ date: "2007-10-03" ,val: 220},

      {name: "sahil",exp_ date: "2007-10-04" ,val: 200},

      {name: "sahil",exp_ date: "2007-10-05" ,val: 55},

      {name: "dray",exp_date: "2007-10-02" ,val: 320},

      {name: "dray",exp_date: "2007-10-03" ,val: 120},

      {name: "dray",exp_date: "2007-10-04" ,val: 10},

      ];

      var Chart_DS = new YAHOO.util.DataSour ce( c_data );

      Chart_DS.responseTy pe = YAHOO.util.DataSour ce.TYPE_JSARRAY;

      Chart_DS.responseSc hema =

      {

      fields: [ "name","exp_ date","val" ]

      };

      YAHOO.widget. Chart.SWFURL = "http://yui.yahooapi s.com/2.4. 0/build/charts/ assets/charts. swf";

      //right now this shows all values in one line and goes crazy :)
      var myChart = new YAHOO.widget. LineChart( "chartdiv", Chart_DS,

      {

      xField: "exp_date",

      yField: "val"

      });

      [[/code]]

      i want to use multiple series with different lines for "vp", "sahil" and "dray" with y-axis as expenses and x-axis as date

      but from the example 

      http://developer. yahoo.com/ yui/examples/ charts/charts- quickstart. html

      i am not able to seperate series based on value in datastore..

      can anyone help me with it..

      thanks

      ------------

      vishal patel

      Yahoo! India

      Unlimited freedom, unlimited storage. Get it now, on http://help. yahoo.com/ l/in/yahoo/ mail/yahoomail/ tools/tools- 08.html/





      Why delete messages? Unlimited storage is just a click away.
    Your message has been successfully submitted and would be delivered to recipients shortly.