Profile Picture

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

Posted By Theodore Kang 8 Years Ago
Author
Message
Theodore Kang
Question Posted 8 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 8 Years Ago
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
Posted 8 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
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
Posted 8 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 8 Years Ago
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
Posted 8 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
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





Similar Topics


Reading This Topic