DBIx-Class-Visualizer

 view release on metacpan or  search on metacpan

lib/DBIx/Class/Visualizer.pm  view on Meta::CPAN


=over 4

=item *

All layout attributes (eg. C<fill>, C<stroke>, C<font-family>) are removed so that styling can be done using css.

=item *

There are occasional minor gaps between the various elements in edges, these are removed (or at least reduced).

=item *

This distribution adds some padding between texts and borders to avoid overlapping. These are removed so that no unnecessary elements remain.

=item *

All edges, nodes and column name elements get relevant values for their id attributes.

=item *

Several C<data-> attributes are added to edges, nodes and column attributes containing a lot of information about the schema.

=back

As an example, this is a column element as rendered by C<graphviz> (whitespace added for readability:

    <text text-anchor="start"
           x="700.391"
           y="-17.9"
           font-family="Helvetica,sans-Serif"
           font-weight="bold"
           font-size="10.00"
           fill="#222222">a_column_id</text>

After passing through C<transformed_svg> the same column looks like this:

    <text id="column-TableName-a_column_id"
          class="column-name"
          y="-17.9"
          x="700.391"
          text-anchor="start"
          data-is-primary="1"
          data-column-name="a_column_id"
          data-column-info="{
            "name": "a_column_id",
            "data_type": "integer",
            "is_primary_key": 1
            "is_auto_increment": 1,
            "is_nullable": 0,
            "is_foreign_key": 0,
            "is_numeric": 1,
            "extra": {},
            "relations":[
                {
                    "origin_table": "TableName",
                    "origin_column": "a_column_id",
                    "destination_table": "AnotherTableName"
                    "destination_column": "a_column_id",
                    "relation_type": "has_many",
                    "cascade_delete": 1,
                },
                ...
            ],
          }">a_column_id</text>

The C<data-column-info> attribute is a json object that is directly usable by something like jQuery:

    # has_many
    $('#column-TableName-a_column_id').data('column-info').relations[0].relation_type;

=head1 SEE ALSO

=over 4

=item *

L<Mojolicious::Plugin::DbicSchemaViewer> - A L<Mojolicious> plugin that uses this class

=item *

L<GraphViz2::DBI> - Visualizes a schema by inspecting the database.

=back

=head1 SOURCE

L<https://github.com/Csson/p5-DBIx-Class-Visualizer>

=head1 HOMEPAGE

L<https://metacpan.org/release/DBIx-Class-Visualizer>

=head1 AUTHOR

Erik Carlsson <info@code301.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.854 second using v1.01-cache-2.11-cpan-56fb94df46f )