Using the -distribution of a dataset dataset in angular -chart.js

I am writing a budget management application and I am using angular -chart.js.

I want to use a dataset to redefine the original data (basically, to add new data to the chart and provide different colors for each bar, label, etc.) and set labels and colors according to the data value. I am currently trying to make it hardcoded, but only the first value is overridden.

here is the code i use:

angular.module("app2", ["chart.js"]).controller("MixedChartCtrl",
function($scope) {
    $scope.colors = ['#45b7cd', '#ff6384', '#ff8e72'];

    $scope.labels = ['', ''];
    $scope.data = [65, 11];
    $scope.datasetOverride = [

        {
            label: 'Override Series A',
            borderWidth: 1,
            type: 'bar',
            data: [345]
        },
        {
            label: "Bar chart1",
            borderWidth: 1,
            type: 'bar',
            data: [45]
        }

    ];
});
+4
source share
1 answer

Hoping that your proposal, you want the color / fill label / something to indicate separate data (for each bar).

() , .
String, , Array [String] - . (, ).

$scope.data = [65,11];
$scope.datasetOverride = [
{
  label: ['something', 'otherthing'],
  borderWidth: [1,2],
  backgroundColor: ['#FF4242','#2291ff']
}
]

, .
DATASET :

$scope.data.push(345);

, , ().

$scope.datasetOverride[0][label].push('someother thing');
$scope.datasetOverride[0][borderWidth].push(2);
$scope.datesetOverride[0][backgroundColor].push('#46bfb8');

//etc .

, , .

+3

Source: https://habr.com/ru/post/1649274/


All Articles