ctreePages function
- WidgetRef ref
Ctree tree displays.
Implementation
List<Widget> ctreePages(
WidgetRef ref,
) {
String stdout = ref.watch(stdoutProvider);
// Begin the list of pages to display with the introduction markdown text.
List<Widget> pages = [];
// Temporary storage for page content or image.
String content = '';
String image = '';
////////////////////////////////////////////////////////////////////////
// Default tree text.
content = rExtract(stdout, 'print(model_ctree)');
if (content.isNotEmpty) {
pages.add(
TextPage(
title: '''
# Decision Tree Model
Built using [partykit::ctree()](https://www.rdocumentation.org/packages/partykit/topics/ctree).
''',
content: '\n$content',
),
);
}
////////////////////////////////////////////////////////////////////////
// Tree visualisation.
image = '$tempDir/model_tree_ctree.svg';
if (imageExists(image)) {
pages.add(
ImagePage(
title: '''
# Decision Tree Visualisation
Built using
[partykit::plot()](https://www.rdocumentation.org/packages/partykit/topics/party-plot).
''',
path: image,
),
);
}
////////////////////////////////////////////////////////////////////////
return pages;
}