Line Chart - Inconsistent color scheme

Hi everyone,

I have a line chart showing the number of cases created/ closed within the day, and I want the color scheme of the trend lines and legends consistent, which are:

Case Closed: Blue,

Case Created: Green

I have a filter list for case type, and this is where I found the inconsistent issue.

For example: If I choose case type = 1, the color theme is consistent with above setting (Closed: Blue, Created: Green)

                      However, if I choose another case type = 3, the color is other way round (Close: Green, Created: Blue), which might confuse users.

If I set pre-defined color scheme different than CLASSIC (E.g. SUNSET), the color scheme will be consistent after applying filter, but then it become inconsistent again if there is any new closed/created case.

 a!lineChartField(
            data: a!recordData(
              recordType: 'recordType!Case Status',
              filters: {
                a!queryFilter(
                  field: 'recordType!Case Status.fields.caseTypeId',
                  operator: "IN",
                  value: ri!caseTypeId,
                  applywhen: not(rule!AAA_CMN_IsEmpty(ri!caseTypeId))
                ),
                a!queryFilter(
                  field: 'recordType!Case Status.fields.dateTime',
                  operator: ">=",
                  value: subtractdays(
                    datetime(
                      year(now()),
                      month(now()),
                      day(now()),
                      0,
                      0,
                      0
                    ),
                    local!days
                  )
                )
              }
            ),
            config: a!lineChartConfig(
              primaryGrouping: a!grouping(
                field: 'recordType!Case Status.fields.dateTime',
                alias: "CaseDateTime",
                interval: "DATE",
                formatValue: cast(typeof(""), todate(fv!value))
              ),
              secondaryGrouping: a!grouping(
                field: 'recordType!Case Status.fields.status',
                alias: "CaseStatus"
              ),
              link: a!dynamicLink(
                value: fv!selection,
                saveInto: {
                  local!selectedDataRecord,
                  a!save(
                    local!selectedDate,
                    fv!selection.CaseDateTime
                  ),
                  a!save(
                    local!selectedType,
                    if(
                      fv!selection.CaseStatus = "Cases Created",
                      "CREATED",
                      "CLOSED"
                    )
                  )
                }
              )
            ),
            label: "",
            labelPosition: "ABOVE",
            yAxisTitle: "Cases",
            showLegend: true,
            showDataLabels: true,
            showTooltips: true,
            showWhen: rule!AAA_CMN_IsEmpty(local!selectedDate),
            colorScheme: "CLASSIC",
            height: "MEDIUM",
            xAxisStyle: "STANDARD",
            yAxisStyle: "STANDARD"
          )

In below photos, you can see the inconsistent color in the the legent and lines:

   

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    The reason is the order in the recordData is returning those values. 
    Colors are assigned per order of the data which should be shown. 

    so a!grouping is one time providing the group data for "created" as the first value and for  "case closed" and when you are changing the casetype is just randomly the other way around. 
    -> use sorting  in recorddata. this should provide a straight order for grouping. :)  sortfield "status"

Reply
  • 0
    Certified Senior Developer

    The reason is the order in the recordData is returning those values. 
    Colors are assigned per order of the data which should be shown. 

    so a!grouping is one time providing the group data for "created" as the first value and for  "case closed" and when you are changing the casetype is just randomly the other way around. 
    -> use sorting  in recorddata. this should provide a straight order for grouping. :)  sortfield "status"

Children