-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add directive chart-dataset-overload #391
Conversation
We could not set the options included in the chart dataset. We could only set the global options thanks to the directive chart-options. Therfore we could not set an option per chart like described in Issue jtblin#370 . I added a directive chart-dataset-overload. If it is present, createChart will merge both the dataset and the data set overload at the final step of the dataset creation.
This is great and gives flexibility how we can create charts. I was just about to add an issue regarding how one would be able to set colors for the bars in the bar chart based on values for of the dataset(s). This pull request should fix that since I can now create and array with colors based on data and then use the overload feature. Would be awesome if this could be merged asap. Thanks in advance |
Hello, No i don't have example. I use only chart-dataset-overload with the options which must be different between curves. For example : option available for each curve are there :
with a $index which belong to [0;3], options which are not identical for each curve are set with chart-dataset-overload :
Personally , I think this directive can be helpfull because angular-chart is a wrapper for chartjs. So, we can provide new ways to configure charts (char-colors, chart-data, chart-labels) and keep the native way thanks chart-chart-dataset-overload. It's as you want :-) and in all cases thank you for this project |
Thanks, makes sense and sounds like a good idea. A few things I'm wondering:
Example for the later, I could specify the y-axis using
Given the scope of changes, would you mind also do the following?
Thank you |
@@ -283,6 +285,9 @@ | |||
if (yaxis) { | |||
dataset.yAxisID = yaxis[i]; | |||
} | |||
if (datasetOverload) { | |||
angular.merge(dataset,datasetOverload[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: space after comma.
@jtblin In most cases the current api is great. Albeit this could be considered "advance" usage. Here is an example: var setColorBasedOnData = function (data) {
return data.map(function (value) {
return value > 0 ? '#2ecc71' : '#ee3226'; // green and red
});
};
$scope.dataAndConfig = [
{
label: "Override Series A",
backgroundColor: setColorBasedOnData([65, -59, 80, 81, -56, 55, -40]),
borderWidth: 1,
data: [65, -59, 80, 81, -56, 55, -40]
},
{
label: "Override Series B",
backgroundColor: setColorBasedOnData([28, 48, -40, 19, 86, 27, 90]),
borderColor: "rgba(255,99,132,1)",
borderWidth: 3,
hoverBackgroundColor: "rgba(255,99,132,0.4)",
hoverBorderColor: "rgba(255,99,132,1)",
data: [28, 48, -40, 19, 86, 27, 90]
}
]; Regards |
@nirre7 Totally agree, that would be helpful imo |
@MDO-OTB I'm cherry-picking your commit and making a few changes to integrate that into the library. It should be available soon. |
* add attribute `chart-dataset-overload` * complete support for `dataset-override` * rename `datasetOverload` to `datasetOverride` * use `datasetOverride` for pie and doughnut charts as well * add unit and integration tests * add examples * fix #370, #336, #391 * remove `y-axis` attribute as it can now be implemented using the `dataset-override` attribute * compile assets and minor fixes for jshint
Now merged. Thanks a ton for the original implementation @MDO-OTB. @nirre7 what you want to do cannot be implemented as-is for now, the data still needs to be passed separately. It was looking like it was going to make the process too complicated. However we should be close to what you wanted to do, maybe just have to pass the data separately. |
Thank very much for the merge, it is very nice. I must say sorry for not answering earlier but I have been really busy working on other projets. |
Great work, thank you all! Sorry for the late response .. |
We could not set the options included in the chart dataset. We could only set the global options thanks to the directive chart-options. Therfore we could not set an option per chart like described in Issue #370
I added a directive chart-dataset-overload. If it is present, createChart will merge both the dataset and the data set overload at the final step of the dataset creation.
That's my first pull request with github !