Skip to content

Commit

Permalink
added basic chartData constructors for data sources which happen to b…
Browse files Browse the repository at this point in the history
…e maps
  • Loading branch information
jurgenvinju committed Jan 23, 2024
1 parent f5e15d4 commit ee2422c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/org/rascalmpl/library/vis/Charts.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ ChartDataSet chartDataSet(str label, rel[num x, num y] r)
label=label
);

ChartDataSet chartDataSet(str label, map[num x, num y] r)
= chartDataSet([point(x,r[x]) | x <- r],
label=label
);

ChartDataSet chartDataSet(str label, rel[num x, num y, num rad] r)
= chartDataSet([point(x,y,r=rad) | <x,y,rad> <- r],
label=label
Expand All @@ -206,7 +211,15 @@ ChartData chartData(rel[str label, num val] v)
datasets=[
chartDataSet([n | <_, n> <- v])
]
);
);

ChartData chartData(map[str label, num val] v)
= chartData(
labels=[l | l <- v],
datasets=[
chartDataSet([v[l] | l <- v])
]
);

ChartData chartData(lrel[str label, num val] v)
= chartData(
Expand Down Expand Up @@ -273,6 +286,13 @@ ChartData chartData(str label, lrel[num x, num y] values)
]
);

ChartData chartData(str label, map[num x, num y] values)
= chartData(
datasets=[
chartDataSet(label, values)
]
);

ChartData chartData(str label, lrel[num x, num y, num r] values)
= chartData(
datasets=[
Expand Down

0 comments on commit ee2422c

Please sign in to comment.