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

Remote DataSource with StackedChart

Expand Messages
  • dtgmeta
    Hi, I m trying to adapt the polling chart example to use a stacked chart and am having trouble getting the data to appear. Is there an example of stacked chart
    Message 1 of 9 , Jan 4, 2009
      Hi,
      I'm trying to adapt the polling chart example to use a stacked chart
      and am having trouble getting the data to appear. Is there an example
      of stacked chart with remote JSON somewhere?

      I've tried formatting my JSON the same as the stacked chart array
      example, but it still doesn't show.

      Thanks for any tips!
      Darren
    • tripp.bridges
      Hi Darren, Do you have a test link or some sample code (including the data source) that I could take a look at? Thanks, Tripp
      Message 2 of 9 , Jan 5, 2009
        Hi Darren,
        Do you have a test link or some sample code (including the data
        source) that I could take a look at?

        Thanks,
        Tripp
        --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@...> wrote:
        >
        > Hi,
        > I'm trying to adapt the polling chart example to use a stacked chart
        > and am having trouble getting the data to appear. Is there an example
        > of stacked chart with remote JSON somewhere?
        >
        > I've tried formatting my JSON the same as the stacked chart array
        > example, but it still doesn't show.
        >
        > Thanks for any tips!
        > Darren
        >
      • Darren Govoni
        Hi Tripp, Thanks for taking a look. Here is my datasource PHP. [ { year : 2004 ,
        Message 3 of 9 , Jan 5, 2009
          Hi Tripp,
          Thanks for taking a look. Here is my datasource PHP.

          <?php
          header('Content-Type: application/json; charset=utf-8');
          ?>
          [
          { "year": "2004", "internetsales": "246852", "printsales": "2523359",
          "tvsales": "3123493" }
          ]

          And here is how I modified the stacked chart demo.

          var jsonData = new
          YAHOO.util.DataSource( "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
          jsonData.connMethodPost = true;
          jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
          jsonData.responseSchema =
          {
          fields: ["year","internetsales","printsales","tvsales"]

          };

          ....

          var mychart = new YAHOO.widget.StackedBarChart( "chart",
          jsonData,
          {
          series: seriesDef,
          yField: "year",
          xAxis: currencyAxis,
          polling: 2000,
          //only needed for flash player express install
          expressInstall: "assets/expressinstall.swf"
          });

          Thanks for any tips!

          Darren

          On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
          > Hi Darren,
          > Do you have a test link or some sample code (including the data
          > source) that I could take a look at?
          >
          > Thanks,
          > Tripp
          > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@...> wrote:
          > >
          > > Hi,
          > > I'm trying to adapt the polling chart example to use a stacked chart
          > > and am having trouble getting the data to appear. Is there an
          > example
          > > of stacked chart with remote JSON somewhere?
          > >
          > > I've tried formatting my JSON the same as the stacked chart array
          > > example, but it still doesn't show.
          > >
          > > Thanks for any tips!
          > > Darren
          > >
          >
          >
          >
          >
          >
        • tripp.bridges
          Hi Darren, I would change a couple of things. First, change your php so that it returns an object that contains an array. See below: { Results : [ { year :
          Message 4 of 9 , Jan 5, 2009
            Hi Darren,
            I would change a couple of things. First, change your php so that it
            returns an object that contains an array. See below:
            {
            "Results" :
            [
            { "year": "2004", "internetsales": "246852", "printsales":
            "2523359", "tvsales": "3123493" }
            ]
            }

            Next, since you are using an xhr data source, you will need to change
            the structure of your data source so that it will parse out the
            numbers as documented here:
            http://developer.yahoo.com/yui/datasource/#parsers

            It would look like this:

            var jsonData = new YAHOO.util.DataSource( "assets/stack.php?" );
            //use POST so that IE doesn't cache the data
            jsonData.connMethodPost = true;
            jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
            jsonData.responseSchema =
            {
            resultsList: "Results",
            fields:
            [
            {key:"year",parser:"number"},
            {key:"internetsales", parser:"number"},
            {key:"printsales",parser:"number"},
            {key:"tvsales", parser:"number"}
            ]

            };

            Also be sure that you are including all of the necessary javascript
            files.

            Thanks,
            Tripp
            --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...> wrote:
            >
            > Hi Tripp,
            > Thanks for taking a look. Here is my datasource PHP.
            >
            > <?php
            > header('Content-Type: application/json; charset=utf-8');
            > ?>
            > [
            > { "year": "2004", "internetsales": "246852", "printsales": "2523359",
            > "tvsales": "3123493" }
            > ]
            >
            > And here is how I modified the stacked chart demo.
            >
            > var jsonData = new
            > YAHOO.util.DataSource(
            "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
            > jsonData.connMethodPost = true;
            > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
            > jsonData.responseSchema =
            > {
            > fields: ["year","internetsales","printsales","tvsales"]
            >
            > };
            >
            > ....
            >
            > var mychart = new YAHOO.widget.StackedBarChart( "chart",
            > jsonData,
            > {
            > series: seriesDef,
            > yField: "year",
            > xAxis: currencyAxis,
            > polling: 2000,
            > //only needed for flash player express install
            > expressInstall: "assets/expressinstall.swf"
            > });
            >
            > Thanks for any tips!
            >
            > Darren
            >
            > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
            > > Hi Darren,
            > > Do you have a test link or some sample code (including the data
            > > source) that I could take a look at?
            > >
            > > Thanks,
            > > Tripp
            > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@> wrote:
            > > >
            > > > Hi,
            > > > I'm trying to adapt the polling chart example to use a stacked chart
            > > > and am having trouble getting the data to appear. Is there an
            > > example
            > > > of stacked chart with remote JSON somewhere?
            > > >
            > > > I've tried formatting my JSON the same as the stacked chart array
            > > > example, but it still doesn't show.
            > > >
            > > > Thanks for any tips!
            > > > Darren
            > > >
            > >
            > >
            > >
            > >
            > >
            >
          • Darren Govoni
            Hey Tripp, yeah, I went down that path at first. Didn t work for me. Basically, I ve gotten the stacked demo to where I only change the the datasource entry:
            Message 5 of 9 , Jan 5, 2009
              Hey Tripp,
              yeah, I went down that path at first. Didn't work for me.

              Basically, I've gotten the stacked demo to where I only change the
              the datasource entry:


              //var jsonData = new YAHOO.util.DataSource( "data.php"); // This doesn't
              var jsonData = new YAHOO.util.DataSource( annualSales); // This works

              When I use the javascript declared object:

              var annualSales =
              {"Results": [
              { year: 2004, internetsales: 246852, printsales:
              2523359, tvsales: 3123493 },
              { year: 2005, internetsales: 851876, printsales:
              1084952, tvsales: 3166920 },
              { year: 2006, internetsales: 3917246, printsales:
              587151, tvsales: 2330095 },
              { year: 2007, internetsales: 5318185, printsales:
              307456, tvsales: 1830729 }
              ]};

              It works fine.

              When I use the same object from a URL in place of 'annualSales', it
              doesn't show up.

              Darren


              On Mon, 2009-01-05 at 18:03 +0000, tripp.bridges wrote:
              > Hi Darren,
              > I would change a couple of things. First, change your php so that it
              > returns an object that contains an array. See below:
              > {
              > "Results" :
              > [
              > { "year": "2004", "internetsales": "246852", "printsales":
              > "2523359", "tvsales": "3123493" }
              > ]
              > }
              >
              > Next, since you are using an xhr data source, you will need to change
              > the structure of your data source so that it will parse out the
              > numbers as documented here:
              > http://developer.yahoo.com/yui/datasource/#parsers
              >
              > It would look like this:
              >
              > var jsonData = new YAHOO.util.DataSource( "assets/stack.php?" );
              > //use POST so that IE doesn't cache the data
              > jsonData.connMethodPost = true;
              > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
              > jsonData.responseSchema =
              > {
              > resultsList: "Results",
              > fields:
              > [
              > {key:"year",parser:"number"},
              > {key:"internetsales", parser:"number"},
              > {key:"printsales",parser:"number"},
              > {key:"tvsales", parser:"number"}
              > ]
              >
              > };
              >
              > Also be sure that you are including all of the necessary javascript
              > files.
              >
              > Thanks,
              > Tripp
              > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...>
              > wrote:
              > >
              > > Hi Tripp,
              > > Thanks for taking a look. Here is my datasource PHP.
              > >
              > > <?php
              > > header('Content-Type: application/json; charset=utf-8');
              > > ?>
              > > [
              > > { "year": "2004", "internetsales": "246852", "printsales":
              > "2523359",
              > > "tvsales": "3123493" }
              > > ]
              > >
              > > And here is how I modified the stacked chart demo.
              > >
              > > var jsonData = new
              > > YAHOO.util.DataSource(
              > "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
              > > jsonData.connMethodPost = true;
              > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
              > > jsonData.responseSchema =
              > > {
              > > fields: ["year","internetsales","printsales","tvsales"]
              > >
              > > };
              > >
              > > ....
              > >
              > > var mychart = new YAHOO.widget.StackedBarChart( "chart",
              > > jsonData,
              > > {
              > > series: seriesDef,
              > > yField: "year",
              > > xAxis: currencyAxis,
              > > polling: 2000,
              > > //only needed for flash player express install
              > > expressInstall: "assets/expressinstall.swf"
              > > });
              > >
              > > Thanks for any tips!
              > >
              > > Darren
              > >
              > > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
              > > > Hi Darren,
              > > > Do you have a test link or some sample code (including the data
              > > > source) that I could take a look at?
              > > >
              > > > Thanks,
              > > > Tripp
              > > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@> wrote:
              > > > >
              > > > > Hi,
              > > > > I'm trying to adapt the polling chart example to use a stacked
              > chart
              > > > > and am having trouble getting the data to appear. Is there an
              > > > example
              > > > > of stacked chart with remote JSON somewhere?
              > > > >
              > > > > I've tried formatting my JSON the same as the stacked chart
              > array
              > > > > example, but it still doesn't show.
              > > > >
              > > > > Thanks for any tips!
              > > > > Darren
              > > > >
              > > >
              > > >
              > > >
              > > >
              > > >
              > >
              >
              >
              >
              >
              >
            • tripp.bridges
              Hi Darren, Could you send me the full source of your code (or a link) so that I can investigate further? Thanks, Tripp
              Message 6 of 9 , Jan 5, 2009
                Hi Darren,
                Could you send me the full source of your code (or a link) so that I
                can investigate further?

                Thanks,
                Tripp
                --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...> wrote:
                >
                > Hey Tripp,
                > yeah, I went down that path at first. Didn't work for me.
                >
                > Basically, I've gotten the stacked demo to where I only change the
                > the datasource entry:
                >
                >
                > //var jsonData = new YAHOO.util.DataSource( "data.php"); // This doesn't
                > var jsonData = new YAHOO.util.DataSource( annualSales); // This works
                >
                > When I use the javascript declared object:
                >
                > var annualSales =
                > {"Results": [
                > { year: 2004, internetsales: 246852, printsales:
                > 2523359, tvsales: 3123493 },
                > { year: 2005, internetsales: 851876, printsales:
                > 1084952, tvsales: 3166920 },
                > { year: 2006, internetsales: 3917246, printsales:
                > 587151, tvsales: 2330095 },
                > { year: 2007, internetsales: 5318185, printsales:
                > 307456, tvsales: 1830729 }
                > ]};
                >
                > It works fine.
                >
                > When I use the same object from a URL in place of 'annualSales', it
                > doesn't show up.
                >
                > Darren
                >
                >
                > On Mon, 2009-01-05 at 18:03 +0000, tripp.bridges wrote:
                > > Hi Darren,
                > > I would change a couple of things. First, change your php so that it
                > > returns an object that contains an array. See below:
                > > {
                > > "Results" :
                > > [
                > > { "year": "2004", "internetsales": "246852", "printsales":
                > > "2523359", "tvsales": "3123493" }
                > > ]
                > > }
                > >
                > > Next, since you are using an xhr data source, you will need to change
                > > the structure of your data source so that it will parse out the
                > > numbers as documented here:
                > > http://developer.yahoo.com/yui/datasource/#parsers
                > >
                > > It would look like this:
                > >
                > > var jsonData = new YAHOO.util.DataSource( "assets/stack.php?" );
                > > //use POST so that IE doesn't cache the data
                > > jsonData.connMethodPost = true;
                > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
                > > jsonData.responseSchema =
                > > {
                > > resultsList: "Results",
                > > fields:
                > > [
                > > {key:"year",parser:"number"},
                > > {key:"internetsales", parser:"number"},
                > > {key:"printsales",parser:"number"},
                > > {key:"tvsales", parser:"number"}
                > > ]
                > >
                > > };
                > >
                > > Also be sure that you are including all of the necessary javascript
                > > files.
                > >
                > > Thanks,
                > > Tripp
                > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                > > wrote:
                > > >
                > > > Hi Tripp,
                > > > Thanks for taking a look. Here is my datasource PHP.
                > > >
                > > > <?php
                > > > header('Content-Type: application/json; charset=utf-8');
                > > > ?>
                > > > [
                > > > { "year": "2004", "internetsales": "246852", "printsales":
                > > "2523359",
                > > > "tvsales": "3123493" }
                > > > ]
                > > >
                > > > And here is how I modified the stacked chart demo.
                > > >
                > > > var jsonData = new
                > > > YAHOO.util.DataSource(
                > > "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
                > > > jsonData.connMethodPost = true;
                > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
                > > > jsonData.responseSchema =
                > > > {
                > > > fields: ["year","internetsales","printsales","tvsales"]
                > > >
                > > > };
                > > >
                > > > ....
                > > >
                > > > var mychart = new YAHOO.widget.StackedBarChart( "chart",
                > > > jsonData,
                > > > {
                > > > series: seriesDef,
                > > > yField: "year",
                > > > xAxis: currencyAxis,
                > > > polling: 2000,
                > > > //only needed for flash player express install
                > > > expressInstall: "assets/expressinstall.swf"
                > > > });
                > > >
                > > > Thanks for any tips!
                > > >
                > > > Darren
                > > >
                > > > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
                > > > > Hi Darren,
                > > > > Do you have a test link or some sample code (including the data
                > > > > source) that I could take a look at?
                > > > >
                > > > > Thanks,
                > > > > Tripp
                > > > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@> wrote:
                > > > > >
                > > > > > Hi,
                > > > > > I'm trying to adapt the polling chart example to use a stacked
                > > chart
                > > > > > and am having trouble getting the data to appear. Is there an
                > > > > example
                > > > > > of stacked chart with remote JSON somewhere?
                > > > > >
                > > > > > I've tried formatting my JSON the same as the stacked chart
                > > array
                > > > > > example, but it still doesn't show.
                > > > > >
                > > > > > Thanks for any tips!
                > > > > > Darren
                > > > > >
                > > > >
                > > > >
                > > > >
                > > > >
                > > > >
                > > >
                > >
                > >
                > >
                > >
                > >
                >
              • Darren Govoni
                Here are the links: http://ec2-67-202-7-181.compute-1.amazonaws.com/chart.html http://ec2-67-202-7-181.compute-1.amazonaws.com/data.json I moved the php to a
                Message 7 of 9 , Jan 5, 2009
                  Here are the links:

                  http://ec2-67-202-7-181.compute-1.amazonaws.com/chart.html
                  http://ec2-67-202-7-181.compute-1.amazonaws.com/data.json

                  I moved the php to a static json.

                  On Mon, 2009-01-05 at 18:56 +0000, tripp.bridges wrote:
                  > Hi Darren,
                  > Could you send me the full source of your code (or a link) so that I
                  > can investigate further?
                  >
                  > Thanks,
                  > Tripp
                  > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...>
                  > wrote:
                  > >
                  > > Hey Tripp,
                  > > yeah, I went down that path at first. Didn't work for me.
                  > >
                  > > Basically, I've gotten the stacked demo to where I only change the
                  > > the datasource entry:
                  > >
                  > >
                  > > //var jsonData = new YAHOO.util.DataSource( "data.php"); // This
                  > doesn't
                  > > var jsonData = new YAHOO.util.DataSource( annualSales); // This
                  > works
                  > >
                  > > When I use the javascript declared object:
                  > >
                  > > var annualSales =
                  > > {"Results": [
                  > > { year: 2004, internetsales: 246852, printsales:
                  > > 2523359, tvsales: 3123493 },
                  > > { year: 2005, internetsales: 851876, printsales:
                  > > 1084952, tvsales: 3166920 },
                  > > { year: 2006, internetsales: 3917246, printsales:
                  > > 587151, tvsales: 2330095 },
                  > > { year: 2007, internetsales: 5318185, printsales:
                  > > 307456, tvsales: 1830729 }
                  > > ]};
                  > >
                  > > It works fine.
                  > >
                  > > When I use the same object from a URL in place of 'annualSales', it
                  > > doesn't show up.
                  > >
                  > > Darren
                  > >
                  > >
                  > > On Mon, 2009-01-05 at 18:03 +0000, tripp.bridges wrote:
                  > > > Hi Darren,
                  > > > I would change a couple of things. First, change your php so that
                  > it
                  > > > returns an object that contains an array. See below:
                  > > > {
                  > > > "Results" :
                  > > > [
                  > > > { "year": "2004", "internetsales": "246852", "printsales":
                  > > > "2523359", "tvsales": "3123493" }
                  > > > ]
                  > > > }
                  > > >
                  > > > Next, since you are using an xhr data source, you will need to
                  > change
                  > > > the structure of your data source so that it will parse out the
                  > > > numbers as documented here:
                  > > > http://developer.yahoo.com/yui/datasource/#parsers
                  > > >
                  > > > It would look like this:
                  > > >
                  > > > var jsonData = new YAHOO.util.DataSource( "assets/stack.php?" );
                  > > > //use POST so that IE doesn't cache the data
                  > > > jsonData.connMethodPost = true;
                  > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
                  > > > jsonData.responseSchema =
                  > > > {
                  > > > resultsList: "Results",
                  > > > fields:
                  > > > [
                  > > > {key:"year",parser:"number"},
                  > > > {key:"internetsales", parser:"number"},
                  > > > {key:"printsales",parser:"number"},
                  > > > {key:"tvsales", parser:"number"}
                  > > > ]
                  > > >
                  > > > };
                  > > >
                  > > > Also be sure that you are including all of the necessary
                  > javascript
                  > > > files.
                  > > >
                  > > > Thanks,
                  > > > Tripp
                  > > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                  > > > wrote:
                  > > > >
                  > > > > Hi Tripp,
                  > > > > Thanks for taking a look. Here is my datasource PHP.
                  > > > >
                  > > > > <?php
                  > > > > header('Content-Type: application/json; charset=utf-8');
                  > > > > ?>
                  > > > > [
                  > > > > { "year": "2004", "internetsales": "246852", "printsales":
                  > > > "2523359",
                  > > > > "tvsales": "3123493" }
                  > > > > ]
                  > > > >
                  > > > > And here is how I modified the stacked chart demo.
                  > > > >
                  > > > > var jsonData = new
                  > > > > YAHOO.util.DataSource(
                  > > > "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
                  > > > > jsonData.connMethodPost = true;
                  > > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
                  > > > > jsonData.responseSchema =
                  > > > > {
                  > > > > fields: ["year","internetsales","printsales","tvsales"]
                  > > > >
                  > > > > };
                  > > > >
                  > > > > ....
                  > > > >
                  > > > > var mychart = new YAHOO.widget.StackedBarChart( "chart",
                  > > > > jsonData,
                  > > > > {
                  > > > > series: seriesDef,
                  > > > > yField: "year",
                  > > > > xAxis: currencyAxis,
                  > > > > polling: 2000,
                  > > > > //only needed for flash player express install
                  > > > > expressInstall: "assets/expressinstall.swf"
                  > > > > });
                  > > > >
                  > > > > Thanks for any tips!
                  > > > >
                  > > > > Darren
                  > > > >
                  > > > > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
                  > > > > > Hi Darren,
                  > > > > > Do you have a test link or some sample code (including the
                  > data
                  > > > > > source) that I could take a look at?
                  > > > > >
                  > > > > > Thanks,
                  > > > > > Tripp
                  > > > > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@>
                  > wrote:
                  > > > > > >
                  > > > > > > Hi,
                  > > > > > > I'm trying to adapt the polling chart example to use a
                  > stacked
                  > > > chart
                  > > > > > > and am having trouble getting the data to appear. Is there
                  > an
                  > > > > > example
                  > > > > > > of stacked chart with remote JSON somewhere?
                  > > > > > >
                  > > > > > > I've tried formatting my JSON the same as the stacked chart
                  > > > array
                  > > > > > > example, but it still doesn't show.
                  > > > > > >
                  > > > > > > Thanks for any tips!
                  > > > > > > Darren
                  > > > > > >
                  > > > > >
                  > > > > >
                  > > > > >
                  > > > > >
                  > > > > >
                  > > > >
                  > > >
                  > > >
                  > > >
                  > > >
                  > > >
                  > >
                  >
                  >
                  >
                  >
                  >
                • tripp.bridges
                  Hi Darren, You need to put the quotes back on your data source properties. { Results : [ { year : 2004 , internetsales : 246852 , printsales : 2523359 ,
                  Message 8 of 9 , Jan 5, 2009
                    Hi Darren,
                    You need to put the quotes back on your data source properties.
                    {"Results": [
                    { "year": "2004", "internetsales": "246852", "printsales": "2523359",
                    "tvsales": "3123493" },
                    { "year": "2005", "internetsales": "851876", "printsales": "1084952",
                    "tvsales": "3166920" },
                    { "year": "2006", "internetsales": "3917246", "printsales": "587151",
                    "tvsales": "2330095" },
                    { "year": "2007", "internetsales": "5318185", "printsales": "307456",
                    "tvsales": "1830729" }
                    ]}

                    Everything should work then.

                    Thanks,
                    Tripp
                    --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...> wrote:
                    >
                    > Here are the links:
                    >
                    > http://ec2-67-202-7-181.compute-1.amazonaws.com/chart.html
                    > http://ec2-67-202-7-181.compute-1.amazonaws.com/data.json
                    >
                    > I moved the php to a static json.
                    >
                    > On Mon, 2009-01-05 at 18:56 +0000, tripp.bridges wrote:
                    > > Hi Darren,
                    > > Could you send me the full source of your code (or a link) so that I
                    > > can investigate further?
                    > >
                    > > Thanks,
                    > > Tripp
                    > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                    > > wrote:
                    > > >
                    > > > Hey Tripp,
                    > > > yeah, I went down that path at first. Didn't work for me.
                    > > >
                    > > > Basically, I've gotten the stacked demo to where I only change the
                    > > > the datasource entry:
                    > > >
                    > > >
                    > > > //var jsonData = new YAHOO.util.DataSource( "data.php"); // This
                    > > doesn't
                    > > > var jsonData = new YAHOO.util.DataSource( annualSales); // This
                    > > works
                    > > >
                    > > > When I use the javascript declared object:
                    > > >
                    > > > var annualSales =
                    > > > {"Results": [
                    > > > { year: 2004, internetsales: 246852, printsales:
                    > > > 2523359, tvsales: 3123493 },
                    > > > { year: 2005, internetsales: 851876, printsales:
                    > > > 1084952, tvsales: 3166920 },
                    > > > { year: 2006, internetsales: 3917246, printsales:
                    > > > 587151, tvsales: 2330095 },
                    > > > { year: 2007, internetsales: 5318185, printsales:
                    > > > 307456, tvsales: 1830729 }
                    > > > ]};
                    > > >
                    > > > It works fine.
                    > > >
                    > > > When I use the same object from a URL in place of 'annualSales', it
                    > > > doesn't show up.
                    > > >
                    > > > Darren
                    > > >
                    > > >
                    > > > On Mon, 2009-01-05 at 18:03 +0000, tripp.bridges wrote:
                    > > > > Hi Darren,
                    > > > > I would change a couple of things. First, change your php so that
                    > > it
                    > > > > returns an object that contains an array. See below:
                    > > > > {
                    > > > > "Results" :
                    > > > > [
                    > > > > { "year": "2004", "internetsales": "246852", "printsales":
                    > > > > "2523359", "tvsales": "3123493" }
                    > > > > ]
                    > > > > }
                    > > > >
                    > > > > Next, since you are using an xhr data source, you will need to
                    > > change
                    > > > > the structure of your data source so that it will parse out the
                    > > > > numbers as documented here:
                    > > > > http://developer.yahoo.com/yui/datasource/#parsers
                    > > > >
                    > > > > It would look like this:
                    > > > >
                    > > > > var jsonData = new YAHOO.util.DataSource( "assets/stack.php?" );
                    > > > > //use POST so that IE doesn't cache the data
                    > > > > jsonData.connMethodPost = true;
                    > > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
                    > > > > jsonData.responseSchema =
                    > > > > {
                    > > > > resultsList: "Results",
                    > > > > fields:
                    > > > > [
                    > > > > {key:"year",parser:"number"},
                    > > > > {key:"internetsales", parser:"number"},
                    > > > > {key:"printsales",parser:"number"},
                    > > > > {key:"tvsales", parser:"number"}
                    > > > > ]
                    > > > >
                    > > > > };
                    > > > >
                    > > > > Also be sure that you are including all of the necessary
                    > > javascript
                    > > > > files.
                    > > > >
                    > > > > Thanks,
                    > > > > Tripp
                    > > > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                    > > > > wrote:
                    > > > > >
                    > > > > > Hi Tripp,
                    > > > > > Thanks for taking a look. Here is my datasource PHP.
                    > > > > >
                    > > > > > <?php
                    > > > > > header('Content-Type: application/json; charset=utf-8');
                    > > > > > ?>
                    > > > > > [
                    > > > > > { "year": "2004", "internetsales": "246852", "printsales":
                    > > > > "2523359",
                    > > > > > "tvsales": "3123493" }
                    > > > > > ]
                    > > > > >
                    > > > > > And here is how I modified the stacked chart demo.
                    > > > > >
                    > > > > > var jsonData = new
                    > > > > > YAHOO.util.DataSource(
                    > > > > "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
                    > > > > > jsonData.connMethodPost = true;
                    > > > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
                    > > > > > jsonData.responseSchema =
                    > > > > > {
                    > > > > > fields: ["year","internetsales","printsales","tvsales"]
                    > > > > >
                    > > > > > };
                    > > > > >
                    > > > > > ....
                    > > > > >
                    > > > > > var mychart = new YAHOO.widget.StackedBarChart( "chart",
                    > > > > > jsonData,
                    > > > > > {
                    > > > > > series: seriesDef,
                    > > > > > yField: "year",
                    > > > > > xAxis: currencyAxis,
                    > > > > > polling: 2000,
                    > > > > > //only needed for flash player express install
                    > > > > > expressInstall: "assets/expressinstall.swf"
                    > > > > > });
                    > > > > >
                    > > > > > Thanks for any tips!
                    > > > > >
                    > > > > > Darren
                    > > > > >
                    > > > > > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
                    > > > > > > Hi Darren,
                    > > > > > > Do you have a test link or some sample code (including the
                    > > data
                    > > > > > > source) that I could take a look at?
                    > > > > > >
                    > > > > > > Thanks,
                    > > > > > > Tripp
                    > > > > > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@>
                    > > wrote:
                    > > > > > > >
                    > > > > > > > Hi,
                    > > > > > > > I'm trying to adapt the polling chart example to use a
                    > > stacked
                    > > > > chart
                    > > > > > > > and am having trouble getting the data to appear. Is there
                    > > an
                    > > > > > > example
                    > > > > > > > of stacked chart with remote JSON somewhere?
                    > > > > > > >
                    > > > > > > > I've tried formatting my JSON the same as the stacked chart
                    > > > > array
                    > > > > > > > example, but it still doesn't show.
                    > > > > > > >
                    > > > > > > > Thanks for any tips!
                    > > > > > > > Darren
                    > > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > > >
                    > > > >
                    > > > >
                    > > > >
                    > > > >
                    > > > >
                    > > >
                    > >
                    > >
                    > >
                    > >
                    > >
                    >
                  • Darren Govoni
                    Awesome. It works now. Thank you!
                    Message 9 of 9 , Jan 5, 2009
                      Awesome. It works now. Thank you!

                      On Mon, 2009-01-05 at 19:19 +0000, tripp.bridges wrote:
                      > Hi Darren,
                      > You need to put the quotes back on your data source properties.
                      > {"Results": [
                      > { "year": "2004", "internetsales": "246852", "printsales": "2523359",
                      > "tvsales": "3123493" },
                      > { "year": "2005", "internetsales": "851876", "printsales": "1084952",
                      > "tvsales": "3166920" },
                      > { "year": "2006", "internetsales": "3917246", "printsales": "587151",
                      > "tvsales": "2330095" },
                      > { "year": "2007", "internetsales": "5318185", "printsales": "307456",
                      > "tvsales": "1830729" }
                      > ]}
                      >
                      > Everything should work then.
                      >
                      > Thanks,
                      > Tripp
                      > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@...>
                      > wrote:
                      > >
                      > > Here are the links:
                      > >
                      > > http://ec2-67-202-7-181.compute-1.amazonaws.com/chart.html
                      > > http://ec2-67-202-7-181.compute-1.amazonaws.com/data.json
                      > >
                      > > I moved the php to a static json.
                      > >
                      > > On Mon, 2009-01-05 at 18:56 +0000, tripp.bridges wrote:
                      > > > Hi Darren,
                      > > > Could you send me the full source of your code (or a link) so that
                      > I
                      > > > can investigate further?
                      > > >
                      > > > Thanks,
                      > > > Tripp
                      > > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                      > > > wrote:
                      > > > >
                      > > > > Hey Tripp,
                      > > > > yeah, I went down that path at first. Didn't work for me.
                      > > > >
                      > > > > Basically, I've gotten the stacked demo to where I only change
                      > the
                      > > > > the datasource entry:
                      > > > >
                      > > > >
                      > > > > //var jsonData = new YAHOO.util.DataSource( "data.php"); // This
                      > > > doesn't
                      > > > > var jsonData = new YAHOO.util.DataSource( annualSales); // This
                      > > > works
                      > > > >
                      > > > > When I use the javascript declared object:
                      > > > >
                      > > > > var annualSales =
                      > > > > {"Results": [
                      > > > > { year: 2004, internetsales: 246852, printsales:
                      > > > > 2523359, tvsales: 3123493 },
                      > > > > { year: 2005, internetsales: 851876, printsales:
                      > > > > 1084952, tvsales: 3166920 },
                      > > > > { year: 2006, internetsales: 3917246, printsales:
                      > > > > 587151, tvsales: 2330095 },
                      > > > > { year: 2007, internetsales: 5318185, printsales:
                      > > > > 307456, tvsales: 1830729 }
                      > > > > ]};
                      > > > >
                      > > > > It works fine.
                      > > > >
                      > > > > When I use the same object from a URL in place of 'annualSales',
                      > it
                      > > > > doesn't show up.
                      > > > >
                      > > > > Darren
                      > > > >
                      > > > >
                      > > > > On Mon, 2009-01-05 at 18:03 +0000, tripp.bridges wrote:
                      > > > > > Hi Darren,
                      > > > > > I would change a couple of things. First, change your php so
                      > that
                      > > > it
                      > > > > > returns an object that contains an array. See below:
                      > > > > > {
                      > > > > > "Results" :
                      > > > > > [
                      > > > > > { "year": "2004", "internetsales": "246852", "printsales":
                      > > > > > "2523359", "tvsales": "3123493" }
                      > > > > > ]
                      > > > > > }
                      > > > > >
                      > > > > > Next, since you are using an xhr data source, you will need to
                      > > > change
                      > > > > > the structure of your data source so that it will parse out
                      > the
                      > > > > > numbers as documented here:
                      > > > > > http://developer.yahoo.com/yui/datasource/#parsers
                      > > > > >
                      > > > > > It would look like this:
                      > > > > >
                      > > > > > var jsonData = new
                      > YAHOO.util.DataSource( "assets/stack.php?" );
                      > > > > > //use POST so that IE doesn't cache the data
                      > > > > > jsonData.connMethodPost = true;
                      > > > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
                      > > > > > jsonData.responseSchema =
                      > > > > > {
                      > > > > > resultsList: "Results",
                      > > > > > fields:
                      > > > > > [
                      > > > > > {key:"year",parser:"number"},
                      > > > > > {key:"internetsales", parser:"number"},
                      > > > > > {key:"printsales",parser:"number"},
                      > > > > > {key:"tvsales", parser:"number"}
                      > > > > > ]
                      > > > > >
                      > > > > > };
                      > > > > >
                      > > > > > Also be sure that you are including all of the necessary
                      > > > javascript
                      > > > > > files.
                      > > > > >
                      > > > > > Thanks,
                      > > > > > Tripp
                      > > > > > --- In ydn-javascript@yahoogroups.com, Darren Govoni <darren@>
                      > > > > > wrote:
                      > > > > > >
                      > > > > > > Hi Tripp,
                      > > > > > > Thanks for taking a look. Here is my datasource PHP.
                      > > > > > >
                      > > > > > > <?php
                      > > > > > > header('Content-Type: application/json; charset=utf-8');
                      > > > > > > ?>
                      > > > > > > [
                      > > > > > > { "year": "2004", "internetsales": "246852", "printsales":
                      > > > > > "2523359",
                      > > > > > > "tvsales": "3123493" }
                      > > > > > > ]
                      > > > > > >
                      > > > > > > And here is how I modified the stacked chart demo.
                      > > > > > >
                      > > > > > > var jsonData = new
                      > > > > > > YAHOO.util.DataSource(
                      > > > > > "http://ec2-67-202-7-181.compute-1.amazonaws.com/data.php?");
                      > > > > > > jsonData.connMethodPost = true;
                      > > > > > > jsonData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
                      > > > > > > jsonData.responseSchema =
                      > > > > > > {
                      > > > > > > fields: ["year","internetsales","printsales","tvsales"]
                      > > > > > >
                      > > > > > > };
                      > > > > > >
                      > > > > > > ....
                      > > > > > >
                      > > > > > > var mychart = new YAHOO.widget.StackedBarChart( "chart",
                      > > > > > > jsonData,
                      > > > > > > {
                      > > > > > > series: seriesDef,
                      > > > > > > yField: "year",
                      > > > > > > xAxis: currencyAxis,
                      > > > > > > polling: 2000,
                      > > > > > > //only needed for flash player express install
                      > > > > > > expressInstall: "assets/expressinstall.swf"
                      > > > > > > });
                      > > > > > >
                      > > > > > > Thanks for any tips!
                      > > > > > >
                      > > > > > > Darren
                      > > > > > >
                      > > > > > > On Mon, 2009-01-05 at 16:38 +0000, tripp.bridges wrote:
                      > > > > > > > Hi Darren,
                      > > > > > > > Do you have a test link or some sample code (including the
                      > > > data
                      > > > > > > > source) that I could take a look at?
                      > > > > > > >
                      > > > > > > > Thanks,
                      > > > > > > > Tripp
                      > > > > > > > --- In ydn-javascript@yahoogroups.com, "dtgmeta" <darren@>
                      > > > wrote:
                      > > > > > > > >
                      > > > > > > > > Hi,
                      > > > > > > > > I'm trying to adapt the polling chart example to use a
                      > > > stacked
                      > > > > > chart
                      > > > > > > > > and am having trouble getting the data to appear. Is
                      > there
                      > > > an
                      > > > > > > > example
                      > > > > > > > > of stacked chart with remote JSON somewhere?
                      > > > > > > > >
                      > > > > > > > > I've tried formatting my JSON the same as the stacked
                      > chart
                      > > > > > array
                      > > > > > > > > example, but it still doesn't show.
                      > > > > > > > >
                      > > > > > > > > Thanks for any tips!
                      > > > > > > > > Darren
                      > > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > > >
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > >
                      >
                      >
                      >
                      >
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.