Posts

Spotfire: How to add Gaussian Curve Fit to a chart using C# or IronPython code

Image
 Here is a Spotfire ScatterPlot with a Gaussian Curve.  It is straightforward to add it from the UI by right clicking on the chart, opening up properties dialog and adding a Gaussian Curve Fir from the Lines & Curves section: Here is how you would add it from the code:  var gaussianFittingModel = scatterPlot.FittingModels.AddNew<GaussianFittingModel>();

Spotfire: How to create Chart Categorical expression with Display Name? (C#, IronPython)

 Example of Categorical Expression with Display Name This works: $"<LandQuality{duration} as [Land Quality]>" This doesn't work: $"<LandQuality{duration}>    as [Land Quality] " Example: BarChart.XAxis.Expression =  $"<LandQuality{duration} as [Land Quality]>"; Let's compare this to Continuous Expression BarChart.XAxis.Expression =  $"[LandQuality{duration}] as [Land Quality]";

Spotfire: How to set Combination Chart Series color? IronPython C#

             combinationChart.ColorAxis.Coloring.Clear();             var categories = combinationChart.ColorAxis.Coloring.AddCategoricalColorRule().GetExplicitCategories();             foreach (var categoryKey in categories)             { // Your business rules here ...                 if(categoryKey.ToString().Contains("completion"))                     combinationChart.ColorAxis.Coloring.SetColorForCategory(categoryKey, ColorTranslator.FromHtml("#17295f"));                 else if(categoryKey.ToString().Contains("location"))                     combinationChart.ColorAxis.Coloring.SetColorForCategory(categoryKey, ColorTranslator.FromHtml("#f51908"));                 else                     combinationChart.ColorAxis.Coloring.SetColorForCategory(categoryKey, ColorTranslator.FromHtml("#232323"));             }

Spotfire Data Limiting - How to limit data using markings (C#, Ironpython)

Image
  Code: public static void LimitDataUsingMarking(this Visualization chart, Document document)         {             chart.Data.Filterings.Add(document.Data.Markings["Marking"]);         }

Spotfire CombinationChart Setting Series Type (Bar or Line) C# IronPython

 IndexedCombinationChartSeriesType indexedSeriesType = combinationChart.IndexedSeriesType;             indexedSeriesType[new CategoryKey("BOE (Mstb)")] = CombinationChartSeriesType.Line;

Spotfire How to control number of decimals displayed on Value Axis? How to apply number format to Chart axis?

Image
  If you want to apply a specific number format to the Spotfire Chart Axis, here is how you can accomplish it using the C# code:                if (DataType.Real.CreateLocalizedFormatter() is NumberFormatter realFormatter)             {                 realFormatter.DecimalDigits = 5; // Number of decimals                 barChart.YAxis.Scale.Formatting.RealFormatter = realFormatter;             } Here is how you can apply this changes in Spotfire:

Spotfire ScatterPlot Set Color By Category (C#, IronPython)

Image
                var coloring = scatterPlot.ColorAxis.Coloring;             coloring.Clear();             coloring.DefaultColor = Color.White;             var categoricalColorRule = coloring.AddCategoricalColorRule();             var colorKeys = categoricalColorRule.GetExplicitCategories();             scatterPlot.ColorAxis.Coloring.SetColorForCategory(colorKeys[0], Color.ForestGreen);             scatterPlot.ColorAxis.Coloring.SetColorForCategory(colorKeys[1], Color.Blue);             scatterPlot.ColorAxis.Coloring.SetColorForCategory(colorKeys[2], Color.Orange);

Images not showing up in Spotfire JSViz

- Images with relative path will not show up in Spotfire JSViz - Either use absolute path for the image or < img  src ="https://www.w3schools.com/images/picture.jpg"  alt ="Mountain" > - Base64 encode image data and use it  https://css-tricks.com/data-uris/