Hi all!
Using SDK, I would to create a StackedColumn Chart with multi values in the same column ; like this.
Actually, I have a SDK to create a Chart with only 1 value by column.
I wish to adapt the script but idk how to do.
I need your helps please.
This is the script.
Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Data.SqlClient Imports System.Text Imports Laserfiche.RepositoryAccess Imports System.Windows.Forms.DataVisualization.Charting Imports System.Drawing Namespace WorkflowActivity.Scripting.ScriptSDKpourgénérerlegraphique2 '''<summary> '''Offre une ou plusieurs méthodes qui peuvent être exécutées au moment de l'exécution de l'activité de scriptage du flux de travail. '''</summary> Public Class Script1 Inherits RAScriptClass102 '''<summary> '''Cette méthode est exécutée quand l'activité est effectuée. '''</summary> Protected Overrides Sub Execute() 'Rédigez votre code ici. La propriété BoundEntryInfo accèdera à l'entrée, RASession obtiendra la section de Repository Access 'Get the tokens for values and labels... Dim valuesToken as List(Of Object) = Me.GetTokenValue("ChartValues2") Dim labelsToken As List(Of Object) = Me.GetTokenValue("ChartLabels2") Dim count As Integer = valuesToken.Count-1 'Convert the multivalue tokens to arrays... Dim chartValues(count) As Double Dim chartLabels(count) As String For i As Integer = 0 to count chartValues(i) = CDbl(valuesToken(i)) chartLabels(i) = labelsToken(i).ToString Next 'Create a new chart... Dim chart As Chart = New Chart() chart.Width = 700 chart.Height = 300 'Add a title to the chart... Dim title As New Title(Me.GetTokenValue("ChartTitle2")) title.Alignment = ContentAlignment.TopLeft title.Font = New Font("Arial", 14, FontStyle.Bold) chart.Titles.Add(title) 'Add the legend for the data... Dim legend As New Legend(Me.GetTokenValue("LegendTitle2")) chart.Legends.Add(legend) 'Create a new data series and set the chart type to a StackedColumn chart... Dim series As Series = New Series("OI") series.ChartType = SeriesChartType.StackedColumn series.IsValueShownAsLabel = True chart.Series.Add(series) 'Bind the labels and values as datapoints... chart.Series("OI").Points.DataBindXY(chartLabels, chartValues) 'Create a new chart area and add it to the chart object... Dim chartArea As ChartArea = New ChartArea() Dim yAxis As Axis = New Axis(chartArea, AxisName.Y) Dim xAxis As Axis = New Axis(chartArea, AxisName.X) chartArea.AxisX.Interval = 1 chart.ChartAreas.Add(chartArea) 'Now write the chart image to the document... Using docInfo As DocumentInfo = Me.BoundEntryInfo() 'Read the chart image into a byte array... Dim imageData() As Byte Using ms As New System.IO.MemoryStream chart.SaveImage(ms, ChartImageFormat.Tiff) imageData = ms.ToArray End Using 'Lock the document and append a blank page... docInfo.Lock(LockType.Exclusive) Dim pInfo As PageInfo = docinfo.AppendPage 'Write the image to the new page... Using writer As System.IO.Stream = pInfo.WritePagePart(PagePart.Image, imageData.Length) writer.Write(imageData, 0, imageData.Length) End Using 'Save and unlock the document... docInfo.Save() docInfo.Unlock() End Using End Sub End Class End Namespace
Thanks in advance.
Regards