Ask AI
Skip to main content

Add slice to piechart

Function: Add slice to piechart

This function allows you to dynamically add a new segment, or "slice," to an existing pie chart displayed on your application's page. This is useful for updating charts with new data points without needing to recreate the entire chart.

Input,

  • UI element (PART): The specific pie chart component on your page where you want to add a new slice. You will typically select this from a list of available UI elements.
  • Code (STRING): A unique identifier for this new slice. This helps the system keep track of individual slices within the chart.
  • Name (STRING): The label or name that will be displayed for this slice on the pie chart, often appearing in the legend or as a tooltip.
  • Color (STRING): The color you want to use for this specific slice on the chart. This is usually provided as a hexadecimal color code (e.g., #FF0000 for red).
  • Value (NUMBER): The numerical size or proportion of this slice relative to the other slices in the pie chart. The chart will automatically adjust to show this value as part of the whole.

Output,

This function does not produce a direct output value. Instead, it modifies the selected pie chart UI element directly on your application's page, adding the new slice as specified.

Execution Flow,

Real-Life Examples,

Example 1: Updating Monthly Sales Data

Imagine you have a pie chart showing sales distribution by product category, and you want to add a new category's sales for the current month.

  • Inputs:
    • UI element: Monthly Sales Chart
    • Code: ACCESSORIES_SALES
    • Name: Accessories
    • Color: #8A2BE2 (a shade of blue-violet)
    • Value: 7500
  • Result: The Monthly Sales Chart will now display a new segment labeled "Accessories" with a value of 7,500, colored blue-violet, alongside your existing product categories.

Example 2: Tracking Project Task Status

You are managing a project and want to dynamically update a pie chart that visualizes the status of different task types (e.g., "Design," "Development," "Testing"). You've just completed a new "Deployment" phase.

  • Inputs:
    • UI element: Project Status Overview
    • Code: DEPLOYMENT_PHASE
    • Name: Deployment
    • Color: #FFD700 (gold)
    • Value: 20
  • Result: The Project Status Overview chart will update to include a "Deployment" segment, showing 20 units (e.g., 20% of project effort or 20 tasks), displayed in gold.

Example 3: Analyzing Customer Feedback Channels

Your marketing team uses a pie chart to see where customer feedback originates (e.g., "Email," "Social Media," "Website Form"). A new "In-App Survey" channel has just been launched and needs to be added.

  • Inputs:
    • UI element: Customer Feedback Channels
    • Code: IN_APP_SURVEYS
    • Name: In-App Surveys
    • Color: #32CD32 (lime green)
    • Value: 150
  • Result: A new segment for "In-App Surveys" feedback, valued at 150, will be added to the Customer Feedback Channels pie chart, displayed in lime green.