Profile Picture

Populate diagram from database fail

Posted By Hendra Permana 13 Years Ago
Author
Message
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Rao,

You can take a look at the Diagram examples (WebForm):

Import >> Graph Data Import

Import >> Tree Data Import

Demo Diagrams >> Business Company (Org. Chart)

You can also check the online examples here: http://examplesaspnetdiagram.nevron.com/



Best Regards,
Nevron Support Team



Rao K
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 1, Visits: 1
If anyone has similar example using ASP.NET, can you please post?

Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hello Hendra,

You must be missing something in the code example. By using your sample data, you can COPY/PASTE the following code:

Imports Nevron.GraphicsCore

Imports Nevron.Diagram

Imports Nevron.Diagram.Shapes

Imports Nevron.Diagram.WinForm

Imports Nevron.Diagram.Layout

Imports Nevron.Diagram.DataImport

Imports System.Data.OleDb

...

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ' begin view init 

    DrawingView.BeginInit()

 

    ' display the document in the view 

    DrawingView.Document = DrawingDocument

 

    ' configure the view 

    DrawingView.ViewLayout = ViewLayout.Fit

    DrawingView.Grid.Visible = False

    DrawingView.GlobalVisibility.ShowPorts = False

    DrawingView.HorizontalRuler.Visible = False

    DrawingView.VerticalRuler.Visible = False

 

    ' create two stylesheets - one for the vertices and one for the edges 

    Dim vertexStyleSheet As New NStyleSheet()

    vertexStyleSheet.Name = "Vertices"

    DrawingDocument.StyleSheets.AddChild(vertexStyleSheet)

    Dim edgeStyleSheet As New NStyleSheet()

    edgeStyleSheet.Name = "Edges"

    edgeStyleSheet.Style.StartArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Circle, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))

    edgeStyleSheet.Style.EndArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Arrow, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))

    DrawingDocument.StyleSheets.AddChild(edgeStyleSheet)

 

    ' configure the graph data source importer 

    Dim GraphImporter As New NGraphDataSourceImporter()

 

    ' set the document in the active layer of which the shapes will be imported 

    GraphImporter.Document = DrawingDocument

 

    ' set the connection string, data sources and DataAdapters 

    ' in this example we have created two OleDbDataAdapters:  

    ' the PagesDataAdapter selects all records and columns from the Pages table of the SiteMap.mdb 

    ' the LinksDataAdapter selects all records and columns from the Links table of the SiteMap.mdb 

    Dim connString As String = "Data Source=""" + Application.StartupPath + "\SiteMap.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";"

    Dim PagesDataAdapter As New OleDbDataAdapter("SELECT * FROM Pages", connString)

    Dim LinksDataAdapter As New OleDbDataAdapter("SELECT * FROM Links", connString)

 

    GraphImporter.VertexDataSource = PagesDataAdapter

    GraphImporter.EdgeDataSource = LinksDataAdapter

 

    ' vertex records are uniquely identified by their Id (in the Pages table) 

    ' edges link the vertices with the FromPageId and ToPageId (in the Links table) 

    GraphImporter.VertexIdColumnName = "Id"

    GraphImporter.FromVertexIdColumnName = "FromPageId"

    GraphImporter.ToVertexIdColumnName = "ToPageId"

 

    ' create vertices as rectangles shapes, with default size (60, 30) 

    Dim shapesFactory As New NBasicShapesFactory()

    shapesFactory.DefaultSize = New NSizeF(60, 30)

    GraphImporter.VertexShapesFactory = shapesFactory

    GraphImporter.VertexShapesName = BasicShapes.Rectangle.ToString()

 

    ' set stylesheets to be applied to imported vertices and edges 

    GraphImporter.VertexStyleSheetName = "Vertices"

    GraphImporter.EdgeStyleSheetName = "Edges"

 

    ' use layered graph layout 

    Dim layout As New NLayeredGraphLayout()

    layout.Direction = LayoutDirection.TopToBottom

    layout.LayerAlignment = RelativeAlignment.Near

    GraphImporter.Layout = layout

 

    ' subscribe for the vertex imported event, 

    ' which is raised when a shape was created for a data source record 

    AddHandler GraphImporter.VertexImported, AddressOf OnVertexImported

 

    ' import 

    GraphImporter.Import()

 

    ' end view init 

    DrawingView.EndInit()

End Sub

 

Private Sub OnVertexImported(ByVal dataSourceImporter As NDataSourceImporter, ByVal shape As NShape, ByVal record As INDataRecord)

    ' display the page title in the shape 

    Dim text As Object = record.GetColumnValue("Title")

    If text Is Nothing Then

        shape.Text = "Title not specified"

    Else

        shape.Text = text.ToString()

    End If

 

    shape.SizeToText(New NMarginsF(10))

End Sub

 

Following is the generated diagram:



Best Regards,
Nevron Support Team



Hendra Permana
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1

i have included the screenshot and the output.

Code is already attached in previous post.

Regards

  



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi,

Can you provide us with a snapshot of the pages and links tables schemas and data.



Best Regards,
Nevron Support Team



Hendra Permana
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1
I have set it all correctly. But the output is just like this one http://i52.tinypic.com/2jb2vie.jpg

below is the code:

Private Sub loadData()

view.BeginInit()

view.Document = document

view.ViewLayout = ViewLayout.Fit
view.Grid.Visible = False
view.GlobalVisibility.ShowPorts = False
view.HorizontalRuler.Visible = False
view.VerticalRuler.Visible = False

Dim vertexStyleSheet As New NStyleSheet()
vertexStyleSheet.Name = "Vertices"
document.StyleSheets.AddChild(vertexStyleSheet)

Dim edgeStyleSheet As New NStyleSheet()
edgeStyleSheet.Name = "Edges"
edgeStyleSheet.Style.StartArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Circle, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))
edgeStyleSheet.Style.EndArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Arrow, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))
document.StyleSheets.AddChild(edgeStyleSheet)

Dim GraphImporter As New NGraphDataSourceImporter()

GraphImporter.Document = document

Dim connString As String = System.Configuration.ConfigurationManager.ConnectionStrings(1).ConnectionString

Dim PagesDataAdapter As New System.Data.SqlClient.SqlDataAdapter("select * from pages", connString)
Dim LinksDataAdapter As New System.Data.SqlClient.SqlDataAdapter("select * from links", connString)

GraphImporter.VertexDataSource = PagesDataAdapter
GraphImporter.EdgeDataSource = LinksDataAdapter

GraphImporter.VertexIdColumnName = "ID"
GraphImporter.FromVertexIdColumnName = "FromPageId"
GraphImporter.ToVertexIdColumnName = "ToPageId"


Dim shapesFactory As New NBasicShapesFactory()
shapesFactory.DefaultSize = New NSizeF(60, 30)
GraphImporter.VertexShapesFactory = shapesFactory
GraphImporter.VertexShapesName = BasicShapes.Rectangle.ToString()

GraphImporter.VertexStyleSheetName = "Vertices"
GraphImporter.EdgeStyleSheetName = "Edges"

Dim layout As New NLayeredGraphLayout()
layout.Direction = LayoutDirection.TopToBottom
layout.LayerAlignment = RelativeAlignment.Near

GraphImporter.Layout = layout

AddHandler GraphImporter.VertexImported, AddressOf OnVertexImported

GraphImporter.Import()

view.EndInit()
End Sub

Is there something i missed? please advise.

Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi,

Check out if your edges data adapter is correct and loads any data at all. If it is, make sure that you have also set correctly the FromVertexIdColumnName and the ToVertexIdColumnName properties of the importer.



Best Regards,
Nevron Support Team



Hendra Permana
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1

Hello,

I try to re-create the sample from http://support.nevron.com/KB/a27/automatically-create-a-diagram-from-a-database.aspx

But the output diagram is not as i'm expected. There's no line connector and shapes is just stack up. Any advise?





Similar Topics


Reading This Topic