Cluster Bar Graph (how to have common labels on x axis)


Author
Message
Theodore Kang
Theodore Kang
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 2, Visits: 5
Example:  distance travelled by transportation type

With the sample data below, how does one achieve a common category for the transportation type such that the bars for each series are side by side and commonly labelled.

Series 1:

Ndatapoint(10, "Car")
Ndatapoint(20, "Bus")
Ndatapoint(40, "Plane")

Series 2:

Ndatapoint(30, "Car")
Ndatapoint(30, "Bus")
Ndatapoint(50, "Plane")



Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi,
The following code shows how to create a cluster bar with custom x category labels:
   NChart chart = nChartControl1.Charts[0];

    NBarSeries bar1 = new NBarSeries();

    bar1.Values.Add(10);
    bar1.Values.Add(20);
    bar1.Values.Add(30);

    chart.Series.Add(bar1);

    NBarSeries bar2 = new NBarSeries();

    bar2.MultiBarMode = MultiBarMode.Clustered;
    bar2.Values.Add(30);
    bar2.Values.Add(30);
    bar2.Values.Add(40);

    chart.Series.Add(bar2);

    NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;

    scaleX.AutoLabels = false;
    scaleX.Labels.Add("Car");
    scaleX.Labels.Add("Bus");
    scaleX.Labels.Add("Plane");

Hope this helps - let us know if you meet any problems.

Best Regards,
Nevron Support Team


Theodore Kang
Theodore Kang
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 2, Visits: 5

Thanks for the quick response on this, that worked.
I have another question.  Some of the labels are rather long in length.  I saw the example that used a linearscaleconfigurator.  Is there a way to wrap the text for the custom labels for the ordinalscaleconfigurator?


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Theodore,

Yes - you need to replace the value scale label style of the configurator (which is the default) to range:
    NRangeScaleLabelStyle labelStyle = new NRangeScaleLabelStyle();
    labelStyle.TickMode = RangeLabelTickMode.None;
    scaleX.LabelStyle = labelStyle;

That way labels will wrap to their respective category range.

Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search