This is a migrated thread and some comments may be shown as answers.

RadChart and AJAXPro

2 Answers 81 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 07 Aug 2008, 06:17 PM
Hi,

I've got a .Net 2.0 application that already implements ajaxpro (schwarz version) and has a whole host of code working well. 

I'm adding a radChart to this functionality, but dont really want to change (to radAjax) any of the ajaxpro code I've already got working.  I need to make the chart update / be called on through my already implemented ajaxpro callbacks.

The callbacks work and I can call the functions that will create the chart programatically, but I cant return this to the page mainly because its an object.  I can add it during normal postbacks / page loads through the page.controls.add method, but obviously the standard ajax method requires a string (bool / int etc.) variable.  I know that the control mainly returns an IMG html string which is what i need access to in order to integrate it with ajaxpro.

Are there any commands i can use to get access to this rendered string so i can update my page via my already implemented ajaxpro methods?  Is there anyway to access the rendered content of the control that i can then inject into my page?

2 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 1
answered on 08 Aug 2008, 09:29 AM
Im not doing anything massively automated / fancy at the moment, i need to see whether this will work via ajax pro or whether its not going to be possible. Just to show you the vb code i am working with is as follows; 

    <AjaxPro.AjaxMethod()> _
    Public Function createChart() As String
        ' Define chart and title
        Dim radChart As New RadChart()
        radChart.ChartTitle.TextBlock.Text = "My RadChart"
        radChart.ChartTitle.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Blue

        ' Define chart series
        Dim chartSeries As New ChartSeries()
        chartSeries.Appearance.LabelAppearance.Visible = False
        chartSeries.Name = "GDP"
        chartSeries.Type = ChartSeriesType.Line
        chartSeries.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.BlueViolet
        ' Define the items in the series
        chartSeries.AddItem(1)
        chartSeries.AddItem(1.5)
        chartSeries.AddItem(2)
        chartSeries.AddItem(2.5)
        chartSeries.AddItem(3.5)
        ' visually enhance the data points
        chartSeries.Appearance.PointMark.Dimensions.Width = 5
        chartSeries.Appearance.PointMark.Dimensions.Height = 5
        chartSeries.Appearance.PointMark.FillStyle.MainColor = System.Drawing.Color.Black
        chartSeries.Appearance.PointMark.Visible = True
        ' Define chart series
        Dim chartSeries2 As New ChartSeries()
        chartSeries2.Appearance.LabelAppearance.Visible = False
        chartSeries2.Name = "GNP"
        chartSeries2.Type = ChartSeriesType.Line
        chartSeries2.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.Green
        ' Define the items in the series
        chartSeries2.AddItem(2)
        chartSeries2.AddItem(3)
        chartSeries2.AddItem(3.5)
        chartSeries2.AddItem(4)
        chartSeries2.AddItem(4.5)
        ' visually enhance the data points
        chartSeries2.Appearance.PointMark.Dimensions.Width = 5
        chartSeries2.Appearance.PointMark.Dimensions.Height = 5
        chartSeries2.Appearance.PointMark.FillStyle.MainColor = System.Drawing.Color.Black
        chartSeries2.Appearance.PointMark.Visible = True
        ' set the plot area gradient background fill
        radChart.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Gradient
        radChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.FromArgb(65, 201, 254)
        radChart.PlotArea.Appearance.FillStyle.SecondColor = System.Drawing.Color.FromArgb(0, 107, 186)
        ' Set text and line for X axis
        radChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Years"
        radChart.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red
        radChart.PlotArea.XAxis.Appearance.Width = 3
        radChart.PlotArea.XAxis.Appearance.Color = System.Drawing.Color.Red
        ' Set text and line for Y axis
        radChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "%"
        radChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red
        radChart.PlotArea.YAxis.Appearance.Width = 3
        radChart.PlotArea.YAxis.Appearance.Color = System.Drawing.Color.Red
        ' Add the series to the chart, chart to page.
        radChart.Series.Add(chartSeries)
        radChart.Series.Add(chartSeries2)

        ' Dim test As String = AjaxPro.JavaScriptSerializer.Serialize(radChart)

        Return radChart.ClientID


    End Function

I've tried a number of things, but cant seem to get this to return a parsable object.  The serializer didnt return anything! 

My javascript calls are made through ajax pro via JS as follows

function loadGraphNew(){
    SysRep.repgrid.createChart(loadGraphNew_response)
   }
function loadGraphNew_response(response){
    var graphbox = document.getElementById('graphbox')
    graphbox.innerHTML = response.value
}
Can anyone help with this, or point me in the direction if it is possible or not?

Thanks

Marc

0
Ves
Telerik team
answered on 11 Aug 2008, 07:09 AM
Hello Marc,

You can use HttpHandler, it would be similar to what RadChart does. Please, find attached an example (I have stripped the .dlls).

Hope this helps.

All the best,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
Marc
Top achievements
Rank 1
Answers by
Marc
Top achievements
Rank 1
Ves
Telerik team
Share this question
or