إنتهى!

أمثلة على التعليمات البرمجية ل IronPython لتعديل ألوان المخطط في Spotfire

التكنولوجيا
البرمجة
تصور البيانات
بايثون
تحليل البيانات

الخطوات

تم الانتهاء من 6 خطوات!١٦٫٦٥ ث

الجواب

IronPython هي لغة برمجة نصية شائعة لتعديل وتخصيص TIBCO Spotfire. فيما يلي بعض الأمثلة على كيفية تعديل ألوان المخطط في Spotfire باستخدام IronPython:

مثال 1: تغيير لون مخطط شريطي استنادا إلى قيم الأعمدة

from Spotfire.Dxp.Application.Visuals import BarChart from Spotfire.Dxp.Application.Visuals import ColorRule from Spotfire.Dxp.Application.Visuals.VisualContent import BackgroundRule # Get the Bar Chart visualization barChart = vis.As[BarChart]() # Define a color rule colorRule = ColorRule("YourColumnName", "Categorical") colorRule.AddCategoryExpression("\"YourFirstCategory\"", Color.Yellow) colorRule.AddCategoryExpression("\"YourSecondCategory\"", Color.Green) colorRule.AddCategoryExpression("\"YourThirdCategory\"", Color.Blue) # Apply the color rule to the data barChart.ColorRules.Add(colorRule)

مثال 2: تعيين لون معين لجميع الأشرطة

from Spotfire.Dxp.Application.Visuals import BarChart, ColorRule from System.Drawing import Color # Get the Bar Chart visualization barChart = vis.As[BarChart]() # Define a global color rule for all bars globalColorRule = ColorRule(Color.FromArgb(255, 0, 128, 128)) # Teal color # Apply the global color rule barChart.ColorRules.Add(globalColorRule)

مثال 3: تغيير ألوان المخطط الخطي

from Spotfire.Dxp.Application.Visuals import LineChart, ColorRule from System.Drawing import Color # Get the Line Chart visualization lineChart = vis.As[LineChart]() # Define a color rule lineColorRule = ColorRule("YourColumnName", "Categorical") lineColorRule.AddCategoryExpression("\"YourFirstCategory\"", Color.Red) lineColorRule.AddCategoryExpression("\"YourSecondCategory\"", Color.Green) lineColorRule.AddCategoryExpression("\"YourThirdCategory\"", Color.Blue) # Apply the color rule to the data lineChart.ColorRules.Add(lineColorRule)

مثال 4: التنسيق الشرطي للون الخلفية

from Spotfire.Dxp.Application.Visuals import BarChart, BackgroundRule from System.Drawing import Color # Get the Bar Chart visualization barChart = vis.As[BarChart]() # Define a background color rule based on a condition backgroundRule = BackgroundRule("YourColumnName") backgroundRule.AddCategoryExpressio backgroundRule.AddBackgroundExpression("[YourColumnName] > 10", Color.FromArgb(255, 255, 0, 0)) # Red for values > 10 backgroundRule.AddBackgroundExpression("[YourColumnName] <= 10", Color.FromArgb(255, 0, 255, 0)) # Green for values <= 10 # Apply the background rule barChart.BackgroundRules.Add(backgroundRule)

ملاحظات هامة:

  • استبدل "YourColumnName" باسم العمود الفعلي في مجموعة البيانات الخاصة بك.
  • استبدل "YourFirstCategory" و "YourSecondCategory" و "YourThirdCategory" بأسماء الفئات الفعلية المتوفرة في مجموعة البيانات الخاصة بك.
  • تأكد من ضبط الألوان بناء على تفضيلاتك عن طريق تغيير قيم ARGB.

يجب أن تساعدك هذه الأمثلة على البدء في تعديل ألوان المخطط في Spotfire باستخدام IronPython.