public void Broker(object?value, IVisualizationBrokerContext context)
        {
            if (value is IEnumerable <int> intItems)
            {
                context.Add(() => PlotlyData.From(intItems.Select(i => (double)i)),
                            new VisualizationBrokerInfo("plot-int-array", "Plot Int Array", 1000));
            }

            if (value is IEnumerable <double> doubleItems)
            {
                context.Add(() => PlotlyData.From(doubleItems.Select(i => i)),
                            new VisualizationBrokerInfo("plot-double-array", "Plot Double Array", 1000));
            }

            if (value is IEnumerable <float> floatItems)
            {
                context.Add(() => PlotlyData.From(floatItems.Select(i => (double)i)),
                            new VisualizationBrokerInfo("plot-float-array", "Plot Float Array", 1000));
            }

            if (value is IEnumerable <decimal> decimalItems)
            {
                context.Add(() => PlotlyData.From(decimalItems.Select(i => (double)i)),
                            new VisualizationBrokerInfo("plot-decimal-array", "Plot Decimal Array", 1000));
            }
        }
Ejemplo n.º 2
0
        static PlotlyData Plot(Func <double, double, double> fn)
        {
            var plot = new PlotlyPlotData()
            {
                Y = new List <double>(), X = new List <double>(), Z = new List <double>(), Type = PlotType.Mesh3D
            };
            var plotly = new PlotlyData(new[] { plot });

            for (var i = 0.0; i < 10; i += 0.1)
            {
                for (var j = 0.0; j < 10; j += 0.1)
                {
                    plot.X.Add(i);
                    plot.Y.Add(j);
                    plot.Z.Add(fn(i, j));
                }
            }

            return(plotly);
        }