Welcome Guest Search | Active Topics |

Non-Linear Y-axis in spline chart
Topsolutions
#1 Posted : Sunday, March 25, 2018 6:59:44 AM(UTC)
Rank: Newbie

Groups: DataVizJQuery, jQueryGauges, Registered
Joined: 8/6/2013(UTC)
Posts: 2

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

Is it possible to create a chart with a category/string Y-axis in a spline chart?
All my attemps to create such a chart ended with 0 data points in the chart
(The only time I can see values in the chart is when i switch to linear/numeric values in the Y-axis)

X- axis contains DateTime values
Dragan
#2 Posted : Tuesday, March 27, 2018 2:25:33 PM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

You can "axisLabelCreating" event to customize your y-axis labels:
http://www.jqchart.com/jquery/chart/CustomizingChart/AxisLabelCreatingEvent

Here is a sample code:
Code:
$(document).ready(function () {

            $('#jqChart').bind('axisLabelCreating', function (event, data) {
                if (data.context.axis.location == 'left') {

                    switch (data.text) {
                        case '1':
                            data.text = 'A';
                            break;
                        case '2':
                            data.text = 'B';
                            break;
                        case '3':
                            data.text = 'C';
                            break;
                        default:
                            data.text = '';
                            break;
                    }
                }
            });


            $('#jqChart').jqChart({
                title: { text: 'Line Chart' },
                tooltips: { type: 'shared' },
                animation: { duration: 1 },
                axes: [
                    {
                        location: 'left',
                        minimum: 0,
                        maximum: 4,
                        interval: 1
                    }
                ],
                series: [
                    {
                        type: 'spline',
                        data: [[new Date(2010, 0, 1), 1], [new Date(2010, 0, 2), 2],
                               [new Date(2010, 0, 3), 3], [new Date(2010, 0, 4), 2]]
                    }
                ]
            });
        });
Best Regards,
Dragan Matek
jqChart Inc.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.066 seconds.