Theme with chart

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Jul 12, 2009 at 4:51 PM

Hi all,

I am using the zedgraph along with sharpmap v0.9 in a Desktop application, not web application.

I follows the code on the simplechart example ( )

I saved the bmps that should displayed nad they seem to be fine.

I am not sure why Sharpmap does not display them :(

I guess that this has something to do with the layer used ? it's a polygon layer not a point layer.



Dim chartTheme As New CustomTheme(AddressOf GetChartingStyle)
        Dim defaultstyle As New VectorStyle()
        defaultstyle.Fill = Brushes.Gray
        chartTheme.DefaultStyle = defaultstyle
        vl.Theme = chartTheme


Public Function GetChartingStyle(ByVal dr As FeatureDataRow) As IStyle
        Dim style As New VectorStyle()
        Dim valueOfID As String = dr.Item(WATERSHED_ID).ToString
        Dim valueOfNAME As String = dr.Item(WATERSHED_NAME)
        Dim n As String = valueOfID & " " & valueOfNAME
        style.Fill = Brushes.Gray
        style.Symbol = Me.GetChart(n)
        'style.SymbolOffset = 0
        style.SymbolScale = 1
        style.Enabled = True
        style.EnableOutline = True
        Return style
    End Function

Private Function GetChart(ByVal name As String) As System.Drawing.Bitmap
        Dim zgc As New ZedGraphControl()
        Dim myPane As GraphPane = zgc.GraphPane
        '  new GraphPane();
        zgc.Size = New Size(100, 100)

        myPane.Title.IsVisible = False
        ' no title
        myPane.Border.IsVisible = False
        ' no border
        myPane.Chart.Border.IsVisible = False
        ' no x-axis
        myPane.YAxis.IsVisible = False
        ' no y-axis
        myPane.Legend.IsVisible = False
        ' no legend
        myPane.Chart.Fill.Type = FillType.None
        myPane.Fill.Type = FillType.None

        ' Pie Chart

        If mWSWithAllPressures.ContainsKey(name) Then
            Dim pInfo As AllPressuresInfo = mWSWithAllPressures.Item(name)
            ' no border around the chart
            myPane.XAxis.IsVisible = True
            myPane.XAxis.Title.Text = "Πιέσεις"
            myPane.XAxis.Type = AxisType.Text
            Dim labels As String() = {"N", "P", "TSS", "BOD"}
            myPane.XAxis.Scale.TextLabels = labels

            Dim VALS_N As Double() = {pInfo.Nsum, 0, 0, 0}
            Dim VALS_P As Double() = {0, pInfo.Psum, 0, 0}
            Dim VALS_TSS As Double() = {0, 0, pInfo.TSSsum, 0}
            Dim VALS_BOD As Double() = {0, 0, 0, pInfo.BODsum}

            Dim barN As BarItem = myPane.AddBar("N", Nothing, VALS_N, Color.Blue)
            Dim barP As BarItem = myPane.AddBar("P", Nothing, VALS_P, Color.Red)
            Dim barTSS As BarItem = myPane.AddBar("TSS", Nothing, VALS_TSS, Color.Green)
            Dim barBOD As BarItem = myPane.AddBar("BOD", Nothing, VALS_BOD, Color.Yellow)

        End If
        'Hides the slice labels
        PieItem.[Default].LabelType = PieLabelType.None

        zgc.BackColor = Color.Transparent

        Dim tobmp As Image = zgc.GetImage()
        tobmp.Save("c:\temp\" & name & ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
        Dim bmp As Bitmap = tobmp
        Return bmp
    End Function


Jul 13, 2009 at 9:24 AM

Hi Agelos, you are correct, the bitmaps are used to symbolize points so you will need to add a new point layer over your polygon layer and symbolize that.. hth jd