public Color?OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata)
        {
            var defaultColor = rSeries.Stroke;

            if (rSeries.DataSeries == null)
            {
                return(defaultColor);
            }

            var xyzSeries = ((XyzDataSeries <double, double, double>)rSeries.DataSeries);

            double actualTime = xyzSeries.ZValues[index];
            double latestTime = (double)xyzSeries.Tag;

            // how old is the sample? 1.0 = New, 0.0 = Oldest
            double sampleAge = (actualTime - latestTime) / 10.0;

            // Clamp in ten steps, e.g.  0.1, 0.2 .... 0.9, 1.0
            // Why? Creating a new Pen for each single sample will slow down SciChart significantly
            sampleAge = Math.Round(sampleAge * 10.0, 0) * 0.1;

            // Ensure in the range 0.3 ... 1.0 always
            sampleAge = Math.Max(0.3, sampleAge);
            sampleAge = Math.Min(1.0, sampleAge);

            // Compute the Alpha based on sample age
            var modifiedColor = Color.FromArgb((byte)(sampleAge * 0xFF), defaultColor.R, defaultColor.G, defaultColor.B);

            return(modifiedColor);
        }
示例#2
0
        private IDataSeries CreateSeries()
        {
            var data = new double[_height, _width];
            IPointMetadata[,] metaDatas = new IPointMetadata[_height, _width];

            var zValues = FillZValues();

            for (int y = 0; y < _height; y++)
                for (int x = 0; x < _width; x++)
                {
                    var dataValue = zValues[y * _width + x];

                    //Metadata 
                    var metadata = new UniformHeatmapMetaData
                    {
                        IsSelected = false,
                        IsBody = dataValue > 0,
                        CellColor = (dataValue == 0) ? Colors.Transparent : Colors.DeepPink,
                        Tooltip = dataValue == 0 ? "Not Elephant" : "Elephant",
                    };

                    data[y, x] = dataValue;
                    metaDatas[y, x] = metadata;
                }
            return new UniformHeatmapDataSeries<int, int, double>(data, 0, 1, 0, 1, metaDatas);
        }
 public PointPaletteInfo?OverridePointMarker(IRenderableSeries series, int index, double xValue, double yValue,
                                             IPointMetadata metadata)
 {
     if (index % 2 == 0)
     {
         return(_palette);
     }
     return(null);
 }
        public Brush OverrideFillBrush(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            if (_yValues[index] > Threshold)
            {
                return(_overriddenFill);
            }

            // Returning null means use the default color when rendering
            return(null);
        }
        public Color?OverrideStrokeColor(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            if (_yValues[index] > Threshold)
            {
                return(_overriddenColor);
            }

            // Returning null means use the default color when rendering
            return(null);
        }
        public Color?OverrideStrokeColor(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            var isOverridden = IsColorOverridden(index);

            if (isOverridden)
            {
                return(StrokeOverride);
            }

            return(null);
        }
        public Brush OverrideFillBrush(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            var isOverridden = IsColorOverridden(index);

            if (isOverridden)
            {
                return(FillBrushOverride);
            }

            return(null);
        }
        /// <summary>
        /// Overrides the color of the outline on the attached <see cref="IRenderableSeries" />.
        /// Return null to keep the default series color.
        /// Return a value to override the series color.
        /// </summary>
        /// <param name="rSeries">The source <see cref="IRenderableSeries" />.</param>
        /// <param name="index">The index of the data-point. To get X,Y values use rSeries.DataSeries.XValues[index] etc...</param>
        /// <param name="metadata">The PointMetadata associated with this X,Y data-point.</param>
        /// <returns></returns>
        public Color?OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata)
        {
            // Note: Since IPointMetadata is now passed to palette provider, we can use this too to affect coloring.
            // In this case we use only YValue but #justsaying

            var currentValue = (double)rSeries.DataSeries.YValues[index];

            var isLoss = currentValue < _previousValue;

            _previousValue = currentValue;

            return(isLoss ? LossColor : GainColor);
        }
示例#9
0
        public Color?OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata)
        {
            if (rSeries.IsSelected)
            {
                return(Colors.Aqua);
            }

            if (index == SelectedIndex)
            {
                return(Colors.Goldenrod);
            }

            return(null);
        }
        public PointPaletteInfo?OverridePointMarker(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            var isOverridden = IsColorOverridden(index);

            if (isOverridden)
            {
                _pointMarkerColorOverrides.Fill   = PointMarkerFillOverride;
                _pointMarkerColorOverrides.Stroke = PointMarkerStrokeOverride;

                return(_pointMarkerColorOverrides);
            }

            return(null);
        }
        public Color?OverrideCellColor(IRenderableSeries rSeries, int xIndex, int yIndex, IComparable zValue, Color cellColor, IPointMetadata metadata)
        {
            if ((double)zValue >= ThresholdValue)
            {
                cellColor = _overheatColor;
            }

            return(cellColor);
        }
示例#12
0
        public Color? OverrideCellColor(IRenderableSeries rSeries, int xIndex, int yIndex, IComparable zValue, Color cellColor, IPointMetadata metadata)
        {
           if (metadata != null)
            {
                cellColor = ((UniformHeatmapMetaData)metadata).CellColor;
            }

            return cellColor;
        }
示例#13
0
        public PointPaletteInfo?OverridePointMarker(IRenderableSeries series, int index, IPointMetadata metadata)
        {
            // Called for every data-point to draw
            // you can access data from series.DataSeries.XValues and YValues
            // the index is the index to the data
            //
            // the metadata is an optional object you can pass in to DataSeries
            // remember to cast it!

            var buysell = ((SciChartViewModel.MyMetadata)metadata).Buysell;

            if (buysell == "B")
            {
                return(new PointPaletteInfo
                {
                    Stroke = Colors.DarkGreen
                });
            }
            else if (buysell == "S")
            {
                return(new PointPaletteInfo
                {
                    Stroke = Colors.DarkRed
                });
            }
            // Else, use series default stroke
            else
            {
                return(null); // default line stroke
            }
        }
 public Color? OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata)
 {
     return colors[index];
 }
 public Brush OverrideFillBrush(IRenderableSeries rSeries, int index, IPointMetadata metadata)
 {
     return new SolidColorBrush(colors[index]);
 }