score:5
You can use chart-dataset-override="datasetOverride"
HTML
<div ng-controller="BarCtrl">
<canvas id="bar" class="chart chart-bar"
chart-data="data"
chart-labels="labels"
chart-series="series"
chart-dataset-override="datasetOverride"></canvas>
</div>
Controller
ctrl.datasetOverride = [{
fill: true,
backgroundColor: [
"#ED402A",
"#36A2EB",
"#FFCE56"
]
}, {
fill: true,
backgroundColor: [
"#F0AB05",
"#36A2EB",
"#FFCE56"
]
}, {
fill: true,
backgroundColor: [
"#A0B421",
"#36A2EB",
"#FFCE56"
]
}, {
fill: true,
backgroundColor: [
"#00A39F",
"#36A2EB",
"#FFCE56"
]
},
];
score:0
Here are the codes that I have made to make a bar chart with custom settings. Use this attribute chart-dataset-override="datasetOverride" in the canvas html tag:
<canvas id="bar" class="chart chart-bar"
chart-data="expenseData" chart-labels="labels" chart-series="series"
chart-options="chartOptions" chart-dataset override="datasetOverride">
</canvas>
var setGraphDate = function () {
var xData = [];
var yData = [];
$scope.Data.ExpenseRecords.forEach(function (g) {
yData.push(g.PercentOfCompletion);
xData.push(g.TspShortName);
});
$scope.datasetOverride =
{
backgroundColor: "#4E4EFF",
borderColor: "#2E2E99"
};
$scope.labels = xData;
$scope.expenseData = yData;
$scope.series = ['Expense Graph'];
// more options
$scope.chartOptions = {
legend: {
display: false
},
},
title: {
display: true,
text: 'TSP Burn Rate'
},
events: false,
tooltips: {
enabled: false
},
hover: {
animationDuration: 0
}
};
score:0
Just use RGBA where A is Opacity and set it to 1 which defines the solid color.
Ex: backgroundColor: [ 'rgba(255, 99, 132, 1)']
score:1
I am using chart.js version 2 with angular wrapper, Doing the following edits helped me.
Changes - color takes argument in the form of rgba(R,G,B,alpha)
alpha = 1 : solid color,
alpha = 0 : Transparent color
In HTML :
<canvas id="bar" class="chart chart-bar" chart-data="barData"
chart-labels="filter" chart-series="barLabels" chart-options="baroptions" chart-colors="setColors" > </canvas>
In my Controller class, i defined setColors as follows :
In controller.js :
$scope.setColors = [{backgroundColor:'rgba(249,166,92,1)',pointBackgroundColor:'rgba(249,166,92,1),pointHoverBackgroundColor:'rgba(249,166,92,1)',borderColor:'rgba(249,166,92,1)',pointBorderColor:'rgba(249,166,92,1)',pointHoverBorderColor:'rgba(249,166,92,1)'},
{backgroundColor:'rgba(90,155,211,1)',pointBackgroundColor:'rgba(90,155,211,1)',pointHoverBackgroundColor:'rgba(90,155,211,1)',borderColor:'rgba(90,155,211,1)',pointBorderColor:'rgba(90,155,211,1)',pointHoverBorderColor:'rgba(90,155,211,1)'},
{backgroundColor:'rgba(120,194,107,1)',pointBackgroundColor:'rgba(120,194,107,1)',pointHoverBackgroundColor:'rgba(120,194,107,1)',borderColor:'rgba(120,194,107,1)',pointBorderColor:'rgba(120,194,107,1)',pointHoverBorderColor:'rgba(120,194,107,1)'}]
Source: stackoverflow.com
Related Query
- How to have solid colored bars in angular-chart bar chart
- Chart.js Bar Chart - how to chart bars from 0
- How to set single color on each bar in angular chart js
- How to make bar chart animation where all bars grow at the same speed?
- how to customize tool tip while mouse go over bars on Chart js bar chart
- Chart.js: How to get x-axis labels to show on top of bars in bar chart
- ng2 charts bar chart need spacing between 2 bars in series Angular
- How to prevent empty bars from taking up width in Chart.js bar chart
- How to draw multiple color bars in a bar chart along a Horizontal Line using chart.js
- How to show symbols after the label and before the numeric value using chart.js Bar chart in Angular
- How to align bars in bar chart - Chart.js
- How to set Solid label in bar chart using Chart JS
- how to highlight the bars in stacked bar chart of chart.js on clicking a legend
- How Can I Get An Instance of a ChartJS Bar Chart Using Angular
- How to reduce the gap between bars on bar chart
- How to set percentage value by default on each bars in horizontal bar chart js
- chart js 2 how to set bar width
- Chart.js Bar Chart: How to remove space between the bars in v2.3?
- How to prevent first/last bars from being cut off in a chart with time scale
- How to create rounded bars for Bar Chart.js v2?
- How to put rounded corners on a Chart.js Bar chart
- chartjs : how to set custom scale in bar chart
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- Hide empty bars in Grouped Stacked Bar Chart - chart.js
- How to display inline values in a stacked bar chart with Chart.js?
- ChartJs bar chart - keep bars left instead of equally spread across the width
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Angular chart.js onClick is not working - how to get all elements of a bar when it is clicked on
More Query from same tag
- How to create a multiline graph with differents labels
- Customizing Chart.js troubleshoot
- How to show labels above pie chart in chart.js
- Create space between legend and chart in charts.js
- Can't get data into my Javascript function using Django
- Chart.options returns "Property 'options' does not exist on type 'chart'"
- Make non-zero value as mid-point for horizontal bar chart?
- Chart.js, Can you override the legend label box color?
- Display two datasets from an array using chart.js in node.js
- How to increase the ghap between catergories or labels react-chartjs-2
- Chartjs populate data with Axios response
- chart.js 2 - Is it possible to format tick labels with HTML?
- Chart JS: Bar Chart to have min Length as value range is too big
- Chart.js chart doesn't render when using Angular 2
- create a multi line chart using Chart.js
- How to use generated HTML legends to enable or disable datasets in Chart.js
- Trigger bar/pie graph highlight when hovering over an external element [chart.js / chart js] [AngularJS] [angular-chart.js]
- ChartJS bar chart with legend which corresponds to each bar
- How do you get the width of a datalabel from the Chartjs plugin after the chart animates?
- Change dot size individually Scatter Chart -- ChartJS
- Chart.js - Increase spacing between legend and chart
- Show point values in Radar Chart using chart.js
- Use outside variables inside a TypeScript function.
- If date not in queryset add default value
- Creating mixed Bar Chart with ReactJS using recharts or react-chartjs-2
- How do I make the y-axis intersect the x-axis at 0 in chart.js
- Chartjs - How to get last 7 days on x-axis labels?
- How to make labels on both side from horizontal bar chart js
- How do I add an image in the middle of Donut Chart?(Chart.js)
- Why Primefaces donutChart is not working?