morris charts set dynamically the ykeys and the labels

hi
moriss charts have setData to change the data dynamically. i have an ajax call and it works. when the ajax call is successful i have this:
multiline1.setData(data);

this is the object:
    var multiline1 = Morris.Area({
          element: 'trendsmultiline',
          behaveLikeLine: true,
          data: [], // Set initial data (ideally you would provide an array of default data)
          xkey: 'x',
          ykeys: ['y', 'z'],
          labels: ['air', 'lights'],
          pointSize: 0
        });

Open in new window


this works great. the thing is that i also need the ykeys and the labels dynamically, how do i do that?

the returned data array at the moment ( i am just simulating ):

        $multilinevalues = array(
            array( 'x' => "2011 Q1" , 'y' => 3, 'z' => 6 ) ,
            array( 'x' => "2011 Q2" , 'y' => 10, 'z' => 1 ) ,
            array( 'x' => "2011 Q3" , 'y' => 2 , 'z' => 4) ,
            array( 'x' => "2011 Q4" , 'y' => 3 , 'z' => 3) ,
        );
     
        echo json_encode($multilinevalues);

Open in new window


best reagrds
LVL 1
derridaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
you should be able to set the options like:
multiline1.options.labels = ['Other','Same'];

Open in new window

This should be done BEFORE you use the setData function. If you do it afterwards, you will have to redraw the chart using
multiline1.redraw();

Open in new window

HTH
Rainer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
derridaAuthor Commented:
great
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.