Skip to main content
June 12, 2023
Solved

Select specific color in a pie chart

  • June 12, 2023
  • 2 replies
  • 0 views

Hi all,

i want to select a speficic color for this pie chart, for example if the status is "DA RIASSEGNARE" the related colour is orange and so on. 

Here is the code, and in attachment the pie chart.

Thank in advance.

a!localVariables(
    local!save,
    local!save2: a!refreshVariable(value: local!save,refreshInterval: 0.5),
    local!array,
    local!record2: 'recordType!{2def5f7f-c651-48be-9fce-fe502682f30f}GEC_Dettaglio_Task',
    a!sectionLayout(
      label: "",
      contents: {
        
        a!pieChartField(
          data: a!recordData(
            recordType: 'recordType!{2def5f7f-c651-48be-9fce-fe502682f30f}GEC_Dettaglio_Task'
          ),
          config: a!pieChartConfig(
            primaryGrouping: a!grouping(
              field: 'recordType!{2def5f7f-c651-48be-9fce-fe502682f30f}GEC_Dettaglio_Task.fields.{6d87248b-9f66-495a-b736-3e539bcad481}STATO',

              alias: "vehicleMake_primaryGrouping"
            ),
            measures: {
              a!measure(
                function: "COUNT",
                field: 'recordType!{2def5f7f-c651-48be-9fce-fe502682f30f}GEC_Dettaglio_Task.fields.{fcb3a015-b7a3-44ff-979c-61a4974b47a4}ID',
                alias: "vehicleid_count_measure1"
              )
            },
            sort: {
              a!sortInfo(
                field: "vehicleid_count_measure1"
              )
            },
            dataLimit: 10,
            link: a!dynamicLink(
              value: fv!selection,
              saveInto: local!save
            )
          ),
          label: "TASK PER STATO LAVORAZIONE",
          labelPosition: "ABOVE",
          helpTooltip: "Permette di visualizzare, mediante un grafico, i task complessivi dellâ`™ufficio per ciascuno stato di completamento (Da lavorare, Visualizzato, In lavorazione, In attesa, Chiuso, Da riassegnare).",
          showDataLabels: true,
          showTooltips: true,
          showAsPercentage: false,
          showWhen: true,
          colorScheme:
          a!colorSchemeCustom(
            colors:
            
            {
              "#FFA500",
              "#85200c",
              "#A9A9A9",
              "#FFFF00",
              "#D2691E",
              "#A52A2A",
              "#800000",
              "#FFA07A",
              "#FF0000"
            }
          ),
          style: "DONUT",
          seriesLabelStyle: "LEGEND",
          height: "MEDIUM",
          refreshAfter: "RECORD_ACTION"
        ),
        a!progressBarField(
          label: local!save["vehicleMake_primaryGrouping"],
          labelPosition: "ABOVE",
          percentage: if(a!isNotNullOrEmpty(local!save),100*(local!save["vehicleid_count_measure1"]/rule!GEC_somma_stati_task()),{}),
          showWhen: 1=0,
          style: "THICK"
        ),
        {
	        a!localVariables(
            local!record: 
            a!forEach(
              items: enumerate(rule!GEC_somma_stati_task())+1,
              expression: {
                a!map(vehicleMake_primaryGrouping: index(rule!GEC_PROVE_GENERALI(),fv!item,{}),
                vehicleid_count_measure1:fv!item)
              }
            ),
            local!confronto:a!forEach(
              items: enumerate(rule!GEC_somma_stati_task())+1,
              expression: if(index(local!record["vehicleMake_primaryGrouping"],fv!item,{})<>local!save2["vehicleMake_primaryGrouping"],
              index(local!record["vehicleMake_primaryGrouping"],fv!item,{}),{})
            ),
            local!contatore: length(local!confronto),
	          {
	            a!textField(
  	            label: "",
  	            labelPosition: "ABOVE",
	              value: concat("IL NUMERO TOTALE DI TASK È ", length(local!record)),
  	            saveInto: {},
  	            refreshAfter: "UNFOCUS",
	              showWhen: 1=0,
  	            validations: {}
	            ),
	            a!columnsLayout(
	              columns: {
	                a!columnLayout(),
	                a!columnLayout(),
	                  width: "WIDE"
	                ),
	                a!columnLayout()
	              }
	            )
	          }
	        )
        }
      }
    )
   
  ) 
   
 
  
  
  
  
  

    Best answer by harshitb6843

    I guess Appian's pie chart will not provide you control over the conditional colors of every pie. What you can try is add this conditions in your colorScheme and change the color of a particular index. 

    Or 

    You can use google charts.

    2 replies

    harshitb6843
    June 12, 2023

    I guess Appian's pie chart will not provide you control over the conditional colors of every pie. What you can try is add this conditions in your colorScheme and change the color of a particular index. 

    Or 

    You can use google charts.

    June 12, 2023

    Thanks sir for the reply