This example demonstrates how a document color scheme can be saved and applied in the dxp using a MemoryStream
Introduction
This example demonstrates how a document color scheme can be saved and applied in the dxp using a MemoryStream
Code Sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from Spotfire.Dxp.Application.Visuals import * from System.IO import MemoryStream, FileStream, FileMode as fm, SeekOrigin as so, FileAccess as fa #Save the current coloring scheme in a memorystream s = MemoryStream() for vis in Application.Document.Pages[0].Visuals: if vis.Title == "Chart 1": myColor = vis.As[BarChart]().ColorAxis.Coloring myColor.SaveAs(s) #Optional - Save the document color scheme to a file if required p=System.IO.Path.GetTempPath() + "mydxp.dxpcolor"; fileStream = FileStream(p, fm.Create, fa.Write) s.Seek(0, so.Begin) s.WriteTo(fileStream) fileStream.Close() #Saving the coloring scheme using the memorystream new=Document.ColoringTemplates.AddFromStream(s) s.Close() #Apply the newly created coloring scheme to the required visualization ,vis2 is a visualization parameter vis2 = viz.As[BarChart]() vis2.ColorAxis.Coloring.Apply(new) print "color scheme applied"
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.