[ 2 posts ]

Lilliam Fernández

  • Username: lilliam
  • Joined: Fri Jul 06, 2012 7:12 am
  • Posts: 5
  • Location: Habana, Cuba.
  • Offline
  • Profile
Tags:

Legend colors don't change when changing series colors

Post Posted: Mon Jul 16, 2012 8:19 am
+0-
Hi, I'm changing my series colors how Tripp explained in viewtopic.php?f=92&t=10316&e=0 , but my legend colors are not changing, someone can help me?

This is my code:

var myChart = new Y.Chart({
type: typeChart,
legend: {
position: "right",
width: 300,
height: 300,
styles: {
hAlign: "center",
hSpacing: 4
}
},
axes: {
category: {
keys: [pCategoryKey],
type: "category",
styles: {
label: {
rotation: -45
}

}
}
},
categoryKey: pCategoryKey,
dataProvider:dataSource,
horizontalGridlines: true,
verticalGridlines: true,
render:renderId
});

myChart.set("styles", {
series: [
{
fill: {
color: "#41ab5d"
}
},
{
fill: {
color: "#4eb3d3"
}
},
{
fill: {
color: "#ef6548"
}
}
]});

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Legend colors don't change when changing series colors

Post Posted: Mon Jul 16, 2012 10:24 am
+1-
There is currently bug when using the global style object and a legend.
http://yuilibrary.com/projects/yui3/ticket/2532235

Manually forcing a redraw after updating your styles should workaround this issue.
Code:
myChart.set("styles", {
    series: [
    {
        fill: {
            color: "#41ab5d"
        }
    },
    {
        fill: {
            color: "#4eb3d3"
        }
    },
    {
        fill: {
            color: "#ef6548"
        }
    }
]});
myChart.get("legend")._drawLegend();


Alternatively, you can set your colors when instantiating your chart.
Code:
var myChart = new Y.Chart({
    type: typeChart,
    ...
    seriesCollection: [
   {
       xKey: pCategoryKey,
       yKey: seriesKey1,
       styles: {
      fill: {
          color: "#41ab5d"
      }
       }
   },
   ...
    ],
    ...
});


Thanks,
Tripp
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum