Jump to content
Software FX Community

Duplicate value on the x-axis


Recommended Posts

Hi Everyone, 

I am using ChartFx v2.0.50727, However my problem is the duplicate value on the x-axis such: "04-201304-201304-2013", "05-201305-2013".... and so on, when one should be: "04-2013", "05-2013", the data type of MyRowHeading is string, 

 my values are:

 MySeries MyRowHeading MyValue

1 04-2013 3

1 05-2013 2

1 06-2013 6

2 03-2013 152

2 04-2013 221

2 05-2013 226

2 06-2013 203

2 07-2013 186

2 08-2013 37

3 03-2013 127

3 04-2013 109

4 03-2013 2

4 04-2013 1

4 06-2013 3 ........ and so on 

my code:

        Dim valoresGrafico As List(Of GraficasMiDax)

        valoresGrafico = "Getmyvalues...."

        Dim crossTab As New ChartFX.WebForms.DataProviders.CrosstabDataProvider(valoresGrafico.ToArray)

        crossTab.RowHeadingSettings = RowHeadingSettings.CompressedXValues

        ChartTicketsSD.DataSourceSettings.Fields.Add(New FieldMap("MySeries", FieldUsage.ColumnHeading))

        ChartTicketsSD.DataSourceSettings.Fields.Add(New FieldMap("MyRowHeading", FieldUsage.RowHeading))

        ChartTicketsSD.DataSourceSettings.Fields.Add(New FieldMap("MyValue", FieldUsage.Value))

        ChartTicketsSD.DataSource = crossTab



I am check the post http://community.softwarefx.com/forums/p/12428/29315.aspx#29315 without success 


  Any advice, will be appreciated, thank you





Link to comment
Share on other sites

Yes, each load the chart1 ("GetValuesChart1()") add one value to the x-axis label, 

 Here my code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebChartFX_vb._Default" %>

<%@ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms" TagPrefix="chartfx7" %>

<%@ Register Assembly="ChartFX.WebForms.Adornments" Namespace="ChartFX.WebForms.Adornments"

    TagPrefix="chartfxadornments" %>

<%@ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms.Galleries" TagPrefix="chartfx7galleries" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>



    <form id="form1" runat="server">


        <chartfx7:Chart ID="Chart1" runat="server" Height="350px" Width="430px" BackColor="#FFFFFF"

            Palette="Nature.Sky" PlotAreaColor="White" RandomData-Points="0" RandomData-Series="0">

            <AxisY Title-Text="No. Title AxisY">

                <Grids Major-Visible="False" />


            <AxisX Title-Text="AxisX title" Staggered="True">

                <Grids Major-Visible="False" />



                <chartfxadornments:ImageBorder AssemblyName="ChartFX.WebForms.Adornments" Color="White"

                    Type="Embed" />

                <chartfxadornments:SolidBackground AssemblyName="ChartFX.WebForms.Adornments" />

                <chartfx7galleries:Bar />


            <AllSeries Gallery="Bar" PointLabels-BackColor="Transparent" PointLabels-BorderColor="Transparent"

                PointLabels-Font="Arial, 8pt" PointLabels-TextColor="Black" PointLabels-Visible="True"



            <LegendBox Dock="Bottom">


            <View3D Enabled="True" />

            <MainPane AxisY-Title-Text="No. AxisY Title" />


                <chartfx7:SeriesAttributes Color="66, 00, 66" />

                <chartfx7:SeriesAttributes Color="100, 100, 255" />

                <chartfx7:SeriesAttributes Color="200, 200, 255" />



                <chartfx7:TitleDockable Font="Arial, 11pt, style=Bold" Text="Title dockable" />

                <chartfx7:TitleDockable Text="" />



        <br />

        <asp:Button ID="btnLoadChart" runat="server" Text="LoadChart" />





Code behind:

Imports ChartFX.WebForms.DataProviders

Imports ChartFX.WebForms

Partial Public Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub GetValuesChart1()

        Dim valoresGrafico As New List(Of MyCrossTabData)

        valoresGrafico.Add(New MyCrossTabData(1002, "01-2006", 10))

        valoresGrafico.Add(New MyCrossTabData(1002, "02-2006", 20))

        valoresGrafico.Add(New MyCrossTabData(1002, "03-2006", 70))

        valoresGrafico.Add(New MyCrossTabData(1002, "04-2006", 80))

        valoresGrafico.Add(New MyCrossTabData(1002, "05-2006", 30))

        valoresGrafico.Add(New MyCrossTabData(1003, "01-2006", 10))

        valoresGrafico.Add(New MyCrossTabData(1003, "02-2006", 20))

        valoresGrafico.Add(New MyCrossTabData(1003, "03-2006", 70))

        valoresGrafico.Add(New MyCrossTabData(1002, "04-2006", 80))

        valoresGrafico.Add(New MyCrossTabData(1003, "05-2006", 30))

        valoresGrafico.Add(New MyCrossTabData(1004, "01-2006", 10))

        valoresGrafico.Add(New MyCrossTabData(1004, "02-2006", 20))

        valoresGrafico.Add(New MyCrossTabData(1004, "03-2006", 70))

        valoresGrafico.Add(New MyCrossTabData(1004, "04-2006", 80))

        valoresGrafico.Add(New MyCrossTabData(1004, "05-2006", 30))

        valoresGrafico.Add(New MyCrossTabData(1005, "01-2006", 30))

        valoresGrafico.Add(New MyCrossTabData(1005, "02-2006", 60))

        valoresGrafico.Add(New MyCrossTabData(1005, "03-2006", 45))

        valoresGrafico.Add(New MyCrossTabData(1005, "04-2006", 75))

        valoresGrafico.Add(New MyCrossTabData(1005, "05-2006", 30))

        Dim crossTab As New ChartFX.WebForms.DataProviders.CrosstabDataProvider(New ListProvider(valoresGrafico.ToArray))


        Chart1.Gallery = Gallery.Bar

        Chart1.DataSourceSettings.Fields.Add(New FieldMap("MySeries", FieldUsage.ColumnHeading))

        Chart1.DataSourceSettings.Fields.Add(New FieldMap("MyMonthYear", FieldUsage.RowHeading))

        Chart1.DataSourceSettings.Fields.Add(New FieldMap("MyValue", FieldUsage.Value))

        Chart1.DataSource = crossTab

    End Sub

    Public Class MyCrossTabData

        Private m_series As String

        Private m_date As String

        Private m_value As Double

        Public Sub New(ByVal series As String, ByVal fecha As String, ByVal value As Double)

            m_series = series

            m_date = fecha

            m_value = value

        End Sub

        Property MyValue() As Double


                Return m_value

            End Get

            Set(ByVal Value As Double)

                m_value = Value

            End Set

        End Property

        Property MySeries() As String


                Return m_series

            End Get

            Set(ByVal value As String)

                m_series = value

            End Set

        End Property

        Property MyMonthYear() As String


                Return m_date

            End Get

            Set(ByVal value As String)

                m_date = value

            End Set

        End Property

    End Class

    Protected Sub btnLoadChart_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLoadChart.Click

        Call GetValuesChart1()

    End Sub

End Class 

Link to comment
Share on other sites

Chart1.Data.Clear() is not clearing the labels in the X axis (since that is not necessarily data). I would just reset the chart before passing new data to it Chart1.Reset(). Note that if you do that you will need to reconfigure all the properties you set in markup, including the size of the chart. Maybe export all properties and then import them back after a reset?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...