Skip to content

Commit

Permalink
Add axis types as chart operator flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dit7ya committed Apr 25, 2024
1 parent 901c003 commit e07df71
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libtenzir/builtins/operators/chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,14 @@ chart_definition chart_definitions[] = {
{.attr = "x", .flag = "-x,--x-axis", .type = flag_type::field_name, .default_ = nth_field{0}, .allow_lists = false, .req = requirement::strictly_increasing,},
{.attr = "y", .flag = "-y,--y-axis", .type = flag_type::field_name, .default_ = nth_field{1, nth_field::all_the_rest}, .allow_lists = true,},
{.attr = "position", .flag = "--position", .type = flag_type::attribute_value, .default_ = attribute_value{"grouped"}, .allow_lists = false,},
{.attr = "xAxisType", .flag = "--x-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
{.attr = "yAxisType", .flag = "--y-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
},
.verifications = {
disallow_mixmatch_between_explicit_and_implicit_arguments({"x", "y"}),
require_attribute_value_one_of("position", {"grouped", "stacked"}),
require_attribute_value_one_of("xAxisType", {"log", "linear"}),
require_attribute_value_one_of("yAxisType", {"log", "linear"}),
},
},
// `area` is equivalent to `line`.
Expand All @@ -738,10 +742,14 @@ chart_definition chart_definitions[] = {
{.attr = "x", .flag = "-x,--x-axis", .type = flag_type::field_name, .default_ = nth_field{0}, .allow_lists = false, .req = requirement::strictly_increasing,},
{.attr = "y", .flag = "-y,--y-axis", .type = flag_type::field_name, .default_ = nth_field{1, nth_field::all_the_rest}, .allow_lists = true,},
{.attr = "position", .flag = "--position", .type = flag_type::attribute_value, .default_ = attribute_value{"grouped"}, .allow_lists = false,},
{.attr = "xAxisType", .flag = "--x-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
{.attr = "yAxisType", .flag = "--y-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
},
.verifications = {
disallow_mixmatch_between_explicit_and_implicit_arguments({"x", "y"}),
require_attribute_value_one_of("position", {"grouped", "stacked"}),
require_attribute_value_one_of("xAxisType", {"log", "linear"}),
require_attribute_value_one_of("yAxisType", {"log", "linear"}),
},
},
// `bar` is equivalent to `line`, except the requirement on `x` is for the values to be unique.
Expand All @@ -752,10 +760,14 @@ chart_definition chart_definitions[] = {
{.attr = "x", .flag = "-x,--x-axis", .type = flag_type::field_name, .default_ = nth_field{0}, .allow_lists = false, .req = requirement::unique,},
{.attr = "y", .flag = "-y,--y-axis", .type = flag_type::field_name, .default_ = nth_field{1, nth_field::all_the_rest}, .allow_lists = true,},
{.attr = "position", .flag = "--position", .type = flag_type::attribute_value, .default_ = attribute_value{"grouped"}, .allow_lists = false,},
{.attr = "xAxisType", .flag = "--x-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
{.attr = "yAxisType", .flag = "--y-axis-type", .type = flag_type::attribute_value, .default_ = attribute_value{"linear"}, .allow_lists = false,},
},
.verifications = {
disallow_mixmatch_between_explicit_and_implicit_arguments({"x", "y"}),
require_attribute_value_one_of("position", {"grouped", "stacked"}),
require_attribute_value_one_of("xAxisType", {"log", "linear"}),
require_attribute_value_one_of("yAxisType", {"log", "linear"}),
},
},
// `pie` chart is equivalent to `line` and `bar`, except
Expand Down

0 comments on commit e07df71

Please sign in to comment.