angular-chart.js icon indicating copy to clipboard operation
angular-chart.js copied to clipboard

Remove backgroundColor for line graph

Open caitecoll opened this issue 10 years ago • 4 comments

I love the ability to use the dynamic global colors, but I'm struggling to further customize the appearance of the graphs in my project. I'd like to remove the backgroundColor (or set opacity to 0) for line graphs but still have a background color for bar graphs.

Is there a way to do this that I'm overlooking? From what I see here, it looks like the backgroundColor value is always calculated based on the main color of that data series and can't be modified without completely removing background colors for all chart types:

 function getColor (color) {
      return {
        backgroundColor: rgba(color, 0.2), //This is the line I'd like to be able to customize
        pointBackgroundColor: rgba(color, 1),
        pointHoverBackgroundColor: rgba(color, 0.8),
        borderColor: rgba(color, 1),
        pointBorderColor: '#fff',
        pointHoverBorderColor: rgba(color, 1)
      };
    }

caitecoll avatar Jul 20 '16 16:07 caitecoll

You can pass the entire color object with whatever value you want for backgroundColor.

On 21 Jul 2016 2:45 AM, "Caitlin Collins" [email protected] wrote:

I love the ability to use the dynamic global colors, but I'm struggling to further customize the appearance of the graphs in my project. I'd like to remove the backgroundColor (or set opacity to 0) for line graphs but still have a background color for bar graphs.

Is there a way to do this that I'm overlooking? From what I see here, it looks like the backgroundColor value is always calculated based on the main color of that data series and can't be modified without completely removing background colors for all chart types:

function getColor (color) { return { backgroundColor: rgba(color, 0.2), //This is the line I'd like to be able to customize pointBackgroundColor: rgba(color, 1), pointHoverBackgroundColor: rgba(color, 0.8), borderColor: rgba(color, 1), pointBorderColor: '#fff', pointHoverBorderColor: rgba(color, 1) }; }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jtblin/angular-chart.js/issues/443, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUxrs97cEVucY196g4KwKMQPfIM1MFzks5qXlDEgaJpZM4JQ-l5 .

jtblin avatar Jul 20 '16 21:07 jtblin

Could you give an example of this please?

brogers7 avatar Jul 26 '16 19:07 brogers7

You see the search input box at the top of the page, it's as simple as searching for "backgroundColor" there: https://github.com/jtblin/angular-chart.js/search?utf8=%E2%9C%93&q=backgroundColor

jtblin avatar Jul 27 '16 05:07 jtblin

You can also use the datasetOverride to do this for each set of data inserted into the data array:

$scope.datasetOverride.push({backgroundColor: "rgba(0,0,0,0)"}); // TODO: This won't work in IE8, needs to be "rgb(0,0,0)"

<canvas class="chart chart-line"
        chart-data="data"
        chart-series="series"
        chart-colors="colors"
        chart-dataset-override="datasetOverride"
        chart-options="options">
</canvas>

bdwade100 avatar Nov 10 '16 22:11 bdwade100