Project

General

Profile

Feature #6193

Disable lightening non-selected curve color

Added by Apivan Tuntakurn over 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
12/21/2017
Due date:
% Done:

0%

Estimated time:

Description

I wish there is a way to disable lightening non-selected curve color.

Reasons

  1. The color of non-selected curves is half hard-codded. If the background is dark, the non-selected curves are instead standout.
  2. Lighten color only is only activated when setSeriesSelectedEnable(true) and selectedSeries() != nullptr. In some use cases, we wish to keep the selected curve state and disable selecting other series setSeriesSelectedEnable(false)
  3. We can specify the selected curve pen by subscribing seriesSelected(). This conflict lightening color feature.

I add a patch here.

diff --git a/src/Wt/Chart/WCartesianChart b/src/Wt/Chart/WCartesianChart
index 947a77d9..ab9ac9b8 100644
--- a/src/Wt/Chart/WCartesianChart
+++ b/src/Wt/Chart/WCartesianChart
@@ -1184,6 +1184,8 @@ public:
    * will be shown in a lighter color.
    */
   void setSeriesSelectionEnabled(bool enabled = true);
+ 
+  void setLightenNonSelectedSeriesEnabled(bool enabled = true);

   /*! \brief Returns whether series selection is enabled.
    *
@@ -1287,6 +1289,7 @@ private:
   const WDataSeries *followCurve_;
   bool curveManipulationEnabled_;
   bool cObjCreated_;
+  bool shouldLightenNonSelectedSeries_;
   JSignal<> xTransformChanged_;
   JSignal<> yTransformChanged_;

diff --git a/src/Wt/Chart/WCartesianChart.C b/src/Wt/Chart/WCartesianChart.C
index 6a958293..95ac4e2e 100644
--- a/src/Wt/Chart/WCartesianChart.C
+++ b/src/Wt/Chart/WCartesianChart.C
@@ -438,7 +438,8 @@ public:
     WBrush brush = series_.brush();
     if (chart_.seriesSelectionEnabled() &&
         chart_.selectedSeries() != 0 &&
-        chart_.selectedSeries() != &series_) {
+        chart_.selectedSeries() != &series_ &&
+        chart_.shouldLightenNonSelectedSeries_) {
       brush.setColor(WCartesianChart::lightenColor(brush.color()));
     }
     painter_.fillPath(transform.map(fill_), brush); // FIXME: support curve transforms
@@ -474,7 +475,8 @@ public:
     WPen pen = series_.pen();
     if (chart_.seriesSelectionEnabled() &&
         chart_.selectedSeries() != 0 &&
-        chart_.selectedSeries() != &series_) {
+        chart_.selectedSeries() != &series_ &&
+        chart_.shouldLightenNonSelectedSeries_) {
       pen.setColor(WCartesianChart::lightenColor(pen.color()));
     }
     painter_.strokePath((transform * ct).map(*curve), pen);
@@ -979,7 +981,8 @@ public:
     SeriesIterator::setPenColor(pen, series, xRow, xColumn, yRow, yColumn, MarkerPenColorRole);
     if (chart_.seriesSelectionEnabled() &&
         chart_.selectedSeries() != 0 &&
-        chart_.selectedSeries() != &series) {
+        chart_.selectedSeries() != &series &&
+        chart_.shouldLightenNonSelectedSeries_) {
       pen.setColor(WCartesianChart::lightenColor(pen.color()));
     }

@@ -988,7 +991,8 @@ public:
     double scale = calculateMarkerScale(series, xRow, xColumn, yRow, yColumn, series.markerSize());
     if (chart_.seriesSelectionEnabled() &&
         chart_.selectedSeries() != 0 &&
-        chart_.selectedSeries() != &series) {
+        chart_.selectedSeries() != &series &&
+        chart_.shouldLightenNonSelectedSeries_) {
       brush.setColor(WCartesianChart::lightenColor(brush.color()));
     }

@@ -4170,5 +4174,11 @@ void WCartesianChart::loadTooltip(double x, double y)
   }
 }

+void WCartesianChart::setLightenNonSelectedSeriesEnabled(bool enabled)
+{
+    shouldLightenNonSelectedSeries_ = enabled;
+}
+
+
   }
 }

No data to display

Also available in: Atom PDF