asked on July 22, 2019
Hi all,
I need your help to create a specific chart using sdk (vb).
This is what I have.
and this is what I need.
I'm using tokens and SDK from Workflow.
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.Générerlegraphique '''<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... '################### DEBUT SERIE Dim valuesToken as List(Of Object) = Me.GetTokenValue("ChartValues") '################### FIN SERIE Dim labelsToken As List(Of Object) = Me.GetTokenValue("ChartLabels") '################### DEBUT SERIE Dim count As Integer = valuesToken.Count-1 '################### FIN SERIE 'Convert the multivalue tokens to arrays... '################### DEBUT SERIE Dim chartValues(count) As Double '################### FIN SERIE Dim chartLabels(count) As String '################### DEBUT SERIE For i As Integer = 0 to count if CDbl(valuesToken(i)) > 0 Then chartValues(i) = CDbl(valuesToken(i)) chartLabels(i) = labelsToken(i).ToString end if Next '################### FIN SERIE 'Create a new chart... Dim chart As Chart = New Chart() chart.Width = 690 chart.Height = 460 'Add a title to the chart... Dim title As New Title(Me.GetTokenValue("ChartTitle")) 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("LegendTitle")) chart.Legends.Add(legend) 'Create a new data series and set the chart type to a pie chart... '################### DEBUT SERIE Dim series As Series = New Series("Elémentaire") '################### FIN SERIE '################### DEBUT SERIE series.ChartType = SeriesChartType.StackedColumn series.IsValueShownAsLabel = False chart.Series.Add(series) '################### FIN SERIE 'Bind the labels and values as datapoints... '################### DEBUT SERIE chart.Series("Elémentaire").Points.DataBindXY(chartLabels, chartValues) '################### FIN SERIE '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
Thank you for your helps.
Regards