View Issue Details

IDProjectCategoryView StatusLast Update
0025523mantisbtplug-inspublic2019-08-02 13:46
Reporterdregad Assigned Todregad  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Target Version2.20.0Fixed in Version2.20.0 
Summary0025523: MantisGraph: improve handling of colors in Pie charts
Description

Currently, the color for Pie Chart slices are defined based on $g_status_colors config.

This potentially has fewer colors defined than the number of slices on the chart, resulting in a pie where only the first few slices are colored, and the remaining ones are shown in a default gray, as shown in attached screenshot by_category_pie_chart.png.

Using $g_status_colors only makes sense for By Status charts, we should use a wider color palette for other pie charts.

Additional Information

Follows discussion in https://github.com/mantisbt/mantisbt/pull/1467#issuecomment-467175008

TagsNo tags attached.
Attached Files
by_category_pie_chart.png (48,241 bytes)   
by_category_pie_chart.png (48,241 bytes)   

Relationships

related to 0025522 closeddregad MantisGraph: limit number of slices in By Category pie chart 
related to 0025524 closeddregad MantisGraph: improve display of By Category Bar chart 
related to 0025951 closeddregad MantisGraph: update Chart.js library to v2.8.0 

Activities

cproensa

cproensa

2019-02-26 12:46

developer   ~0061577

Using $g_status_colors only makes sense for By Status charts,

Note that even in Status chart, the colors applied don't match the status colors. This happens when not all status are represented in the graph. Easily reproducible with a filtered summary.

dregad

dregad

2019-02-27 03:33

developer   ~0061586

Note that even in Status chart, the colors applied don't match the status colors. This happens when not all status are represented in the graph. Easily reproducible with a filtered summary.

Very good point, I never realized that as in my tests I always had a data set covering all statuses. Shouldn't be too difficult to adjust the color list to match the dataset though.

dregad

dregad

2019-02-27 07:28

developer   ~0061589

PR https://github.com/mantisbt/mantisbt/pull/1472

dregad

dregad

2019-02-27 07:29

developer   ~0061592

Shouldn't be too difficult to adjust the color list to match the dataset though.

@cproensa This should be fixed in above-mentioned PR.

Related Changesets

MantisBT: master 4e3aca87

2019-02-26 05:50

dregad


Details Diff
Add chartjs-plugin-colorschemes

This Chart.js plugins defines a number of preset color schemes
https://github.com/nagix/chartjs-plugin-colorschemes

Requires Chart.js 2.5.0 or later.

Issue 0025523
Affected Issues
0025523
mod - library/README.md Diff File
mod - plugins/MantisGraph/MantisGraph.php Diff File
add - plugins/MantisGraph/files/chartjs-plugin-colorschemes.min.js Diff File

MantisBT: master 29fe7122

2019-02-26 06:43

dregad


Details Diff
Set color scheme for Pie charts

Add a new optional boolean parameter to graph_pie() API, so that the
caller can decide whether they want to use the default color scheme, or
the configured MantisBT colors.

When the data attribute is undefined, Chart.js uses the colors from
chartjs-plugin-colorschemes, otherwise

This allows using a wider palette for Pie charts that potentially have
more values than defined by $g_status_colors such as By Category.

Additionally as a small optimization, there is no need to define two
sets of color data attributes (for border and background), since they
are identical

Fixes 0025523
Affected Issues
0025523
mod - plugins/MantisGraph/core/graph_api.php Diff File
mod - plugins/MantisGraph/files/MantisGraph.js Diff File
mod - plugins/MantisGraph/pages/status_graph.php Diff File

MantisBT: master a10cb8e6

2019-02-27 00:35

dregad


Details Diff
New helper function to get status color by label

Issue 0025523
Affected Issues
0025523
mod - core/helper_api.php Diff File

MantisBT: master 0012edaf

2019-02-27 00:52

dregad


Details Diff
Only get status colors matching the graph's data

Prior to this, the whole set of status colors was returned, resulting in
colors sometimes not matching the actual status when some of them are
not present in the chart's dataset (as mentioned in 0025523:0061577).

Fixes 0025523
Affected Issues
0025523
mod - plugins/MantisGraph/core/graph_api.php Diff File

MantisBT: master 45dca872

2019-02-27 00:59

dregad


Details Diff
Allow custom fallback status color

When no color is defined in $g_status_color for a given status,
get_status_color() falls back to a hardcoded pure white (#ffffff).

This lets the caller specify which color to use in this case.

Issue 0025523
Affected Issues
0025523
mod - core/helper_api.php Diff File

MantisBT: master 00d3f831

2019-02-27 01:01

dregad


Details Diff
Use light gray as fallback for graph status color

The MantisBT default (white) causes the pie chart (or a part of it) to
become invisible unless the user hovers their mouse on top of them,
since the slices are displayed without border.

Issue 0025523
Affected Issues
0025523
mod - plugins/MantisGraph/core/graph_api.php Diff File